Introduce flow_box macro

This commit is contained in:
Reinout Meliesie 2025-01-31 17:38:52 +01:00
commit a845c0c1fa
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
3 changed files with 55 additions and 37 deletions

View file

@ -24,7 +24,11 @@ pub struct CollatedSeriesGrid {
impl CollatedFilmsGrid {
pub fn new ( films : Vec <Film> , sorting : FilmsSorting ) -> Self {
let grid_widget = create_flow_box () ;
let grid_widget = flow_box ! (
@ orientation : Horizontal ,
@ homogeneous : true ,
@ selection_mode : SelectionMode :: None ,
) ;
let film_widget_pairs = RefCell :: new ( vec ! () ) ;
let component = Self { film_widget_pairs , grid_widget } ;
@ -73,7 +77,11 @@ impl CollatedFilmsGrid {
}
impl CollatedSeriesGrid {
pub fn new ( series : Vec <Series> , sorting : SeriesSorting ) -> Self {
let grid_widget = create_flow_box () ;
let grid_widget = flow_box ! (
@ orientation : Horizontal ,
@ homogeneous : true ,
@ selection_mode : SelectionMode :: None ,
) ;
let series_widget_pairs = RefCell :: new ( vec ! () ) ;
let component = Self { series_widget_pairs , grid_widget } ;
@ -126,14 +134,6 @@ impl Component <FlowBox> for CollatedSeriesGrid {
fn get_widget ( & self ) -> & FlowBox { & self . grid_widget }
}
fn create_flow_box () -> FlowBox {
FlowBox :: builder ()
. orientation (Horizontal)
. homogeneous (true)
. selection_mode ( SelectionMode :: None )
. build ()
}
pub fn create_film_entry ( film : & Film ) -> Box {
create_collection_item (
film . name . as_str () ,
@ -202,29 +202,20 @@ fn create_collection_item (
}
fn create_film_details ( film : & Film ) -> Box {
let container = Box :: builder ()
. orientation (Horizontal)
. halign (Center)
. spacing (20)
. build () ;
container . append (
& Label :: builder () . label ( & film . release_date ) . build ()
) ;
container . append (
& Label :: builder () . label ( format ! ( "{}m" , film . runtime_minutes ) ) . build ()
) ;
container
g_box ! (
@ orientation : Horizontal ,
@ halign : Center ,
@ spacing : 20 ,
label ! ( film . release_date . as_str () ) ,
label ! ( format ! ( "{}m" , film . runtime_minutes ) . as_str () ) ,
)
}
fn create_series_details ( series : & Series ) -> Box {
let container = Box :: builder ()
. orientation (Horizontal)
. halign (Center)
. spacing (20)
. build () ;
// TODO
container
g_box ! (
@ orientation : Horizontal ,
@ halign : Center ,
@ spacing : 20 ,
// TODO
label ! ("????") ,
)
}