Move collation components into submodules
This commit is contained in:
parent
5cccefbd4a
commit
ebc8bc0d2f
7 changed files with 85 additions and 44 deletions
|
@ -9,14 +9,10 @@ use {
|
||||||
std :: { cell :: * , iter :: * , path :: Path } ,
|
std :: { cell :: * , iter :: * , path :: Path } ,
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
use crate :: { collection :: * , ui :: component :: * } ;
|
use crate :: { collection :: * , ui :: { collatable_container :: * , component :: * } } ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [ derive (PartialEq) ] pub enum FilmsSortedBy { Name , ReleaseDate , Runtime }
|
|
||||||
# [ derive (PartialEq) ] pub enum SeriesSortedBy { Name , FirstReleaseDate }
|
|
||||||
# [ derive (PartialEq) ] pub enum SortingDirection { Ascending , Descending }
|
|
||||||
|
|
||||||
pub struct CollatedFilmsGrid {
|
pub struct CollatedFilmsGrid {
|
||||||
film_widget_pairs : RefCell < Vec < ( Film , Box ) > > ,
|
film_widget_pairs : RefCell < Vec < ( Film , Box ) > > ,
|
||||||
grid_widget : FlowBox ,
|
grid_widget : FlowBox ,
|
|
@ -1,3 +1,5 @@
|
||||||
|
mod sort_button ;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
gtk4 :: {
|
gtk4 :: {
|
||||||
Box , Image , Label , ListBox , ListBoxRow , Popover ,
|
Box , Image , Label , ListBox , ListBoxRow , Popover ,
|
||||||
|
@ -10,7 +12,7 @@ use {
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
use crate :: {
|
use crate :: {
|
||||||
ui :: { collated_grid :: * , component :: * , utility :: * } ,
|
ui :: { collatable_container :: * , component :: * , utility :: * } ,
|
||||||
utility :: * ,
|
utility :: * ,
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ impl Component <Box> for SeriesCollationMenu {
|
||||||
|
|
||||||
fn create_sort_button ( sort_menu : & Popover ) -> SplitButton {
|
fn create_sort_button ( sort_menu : & Popover ) -> SplitButton {
|
||||||
SplitButton :: builder ()
|
SplitButton :: builder ()
|
||||||
. child ( & create_label ("Sort") )
|
. child ( & label ! ("Sort") )
|
||||||
. popover (sort_menu)
|
. popover (sort_menu)
|
||||||
. build ()
|
. build ()
|
||||||
}
|
}
|
||||||
|
@ -122,7 +124,8 @@ fn create_sort_menu_entry ( label : & str , reverse : bool ) -> ListBoxRow {
|
||||||
true => Image :: from_icon_name ("view-sort-descending-symbolic") ,
|
true => Image :: from_icon_name ("view-sort-descending-symbolic") ,
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
let container = create_horizontal_box ! (
|
let container = g_box ! (
|
||||||
|
@ orientation : Horizontal ,
|
||||||
& Label :: builder ()
|
& Label :: builder ()
|
||||||
. label (label)
|
. label (label)
|
||||||
. hexpand (true)
|
. hexpand (true)
|
21
src/ui/collatable_container/collation_menu/sort_button.rs
Normal file
21
src/ui/collatable_container/collation_menu/sort_button.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use libadwaita :: * ;
|
||||||
|
|
||||||
|
use crate :: ui :: { * , utility :: * } ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub struct FilmSortButton { widget : SplitButton }
|
||||||
|
|
||||||
|
impl FilmSortButton {
|
||||||
|
pub fn new () -> Self {
|
||||||
|
let widget = SplitButton :: builder ()
|
||||||
|
. child ( & label ! ("Sort") )
|
||||||
|
. build () ;
|
||||||
|
|
||||||
|
Self { widget }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Component <SplitButton> for FilmSortButton {
|
||||||
|
fn get_widget ( & self ) -> & SplitButton { & self . widget }
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
use gtk4 :: { * , prelude :: * } ;
|
mod collated_grid ;
|
||||||
|
mod collation_menu ;
|
||||||
|
|
||||||
|
use gtk4 :: { * , Orientation :: * , prelude :: * } ;
|
||||||
|
|
||||||
use crate :: {
|
use crate :: {
|
||||||
collection :: * ,
|
collection :: * ,
|
||||||
ui :: {
|
ui :: {
|
||||||
collated_grid :: * ,
|
collatable_container :: { collated_grid :: * , collation_menu :: * } ,
|
||||||
collation_menu :: * ,
|
|
||||||
component :: * ,
|
component :: * ,
|
||||||
utility :: * ,
|
utility :: * ,
|
||||||
} ,
|
} ,
|
||||||
|
@ -13,6 +15,10 @@ use crate :: {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [ derive (PartialEq) ] pub enum FilmsSortedBy { Name , ReleaseDate , Runtime }
|
||||||
|
# [ derive (PartialEq) ] pub enum SeriesSortedBy { Name , FirstReleaseDate }
|
||||||
|
# [ derive (PartialEq) ] pub enum SortingDirection { Ascending , Descending }
|
||||||
|
|
||||||
pub struct CollatableFilmsContainer {
|
pub struct CollatableFilmsContainer {
|
||||||
collated_grid : & 'static CollatedFilmsGrid ,
|
collated_grid : & 'static CollatedFilmsGrid ,
|
||||||
widget : Box ,
|
widget : Box ,
|
||||||
|
@ -29,7 +35,8 @@ impl CollatableFilmsContainer {
|
||||||
let film_collation_menu = FilmCollationMenu :: new ( | sorting , direction |
|
let film_collation_menu = FilmCollationMenu :: new ( | sorting , direction |
|
||||||
collated_grid . set_sorting ( sorting , direction ) ) ;
|
collated_grid . set_sorting ( sorting , direction ) ) ;
|
||||||
|
|
||||||
let widget = create_vertical_box ! (
|
let widget = g_box ! (
|
||||||
|
@ orientation : Vertical ,
|
||||||
film_collation_menu . get_widget () ,
|
film_collation_menu . get_widget () ,
|
||||||
& create_collection_scrolled_window ( collated_grid . get_widget () ) ,
|
& create_collection_scrolled_window ( collated_grid . get_widget () ) ,
|
||||||
) ;
|
) ;
|
||||||
|
@ -49,7 +56,8 @@ impl CollatableSeriesContainer {
|
||||||
collated_grid . set_sorting (sorted_by) ;
|
collated_grid . set_sorting (sorted_by) ;
|
||||||
} ) ;
|
} ) ;
|
||||||
|
|
||||||
let widget = create_vertical_box ! (
|
let widget = g_box ! (
|
||||||
|
@ orientation : Vertical ,
|
||||||
series_collation_menu . get_widget () ,
|
series_collation_menu . get_widget () ,
|
||||||
& create_collection_scrolled_window ( collated_grid . get_widget () ) ,
|
& create_collection_scrolled_window ( collated_grid . get_widget () ) ,
|
||||||
) ;
|
) ;
|
||||||
|
@ -71,7 +79,7 @@ impl Component <Box> for CollatableSeriesContainer {
|
||||||
|
|
||||||
fn create_collection_scrolled_window ( child : & FlowBox ) -> ScrolledWindow {
|
fn create_collection_scrolled_window ( child : & FlowBox ) -> ScrolledWindow {
|
||||||
ScrolledWindow :: builder ()
|
ScrolledWindow :: builder ()
|
||||||
. child ( & create_vertical_filler_container (child) )
|
. child ( & vertically_filling ! (child) )
|
||||||
. propagate_natural_height (true)
|
. propagate_natural_height (true)
|
||||||
. build ()
|
. build ()
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ impl CollectionViewStack {
|
||||||
films_container : & CollatableFilmsContainer ,
|
films_container : & CollatableFilmsContainer ,
|
||||||
series_container : & CollatableSeriesContainer ,
|
series_container : & CollatableSeriesContainer ,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let widget = create_view_stack ! (
|
let widget = view_stack ! (
|
||||||
"Films" , "camera-video-symbolic" , films_container . get_widget () ,
|
"Films" , "camera-video-symbolic" , films_container . get_widget () ,
|
||||||
"Series" , "video-display-symbolic" , series_container . get_widget () ,
|
"Series" , "video-display-symbolic" , series_container . get_widget () ,
|
||||||
) ;
|
) ;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
mod application_header_bar ;
|
mod application_header_bar ;
|
||||||
mod collatable_container ;
|
mod collatable_container ;
|
||||||
mod collated_grid ;
|
|
||||||
mod collation_menu ;
|
|
||||||
mod collection_view_stack ;
|
mod collection_view_stack ;
|
||||||
mod component ;
|
mod component ;
|
||||||
mod utility ;
|
mod utility ;
|
||||||
|
|
|
@ -1,45 +1,60 @@
|
||||||
use { gtk4 :: { Label , Widget , prelude :: * } , libadwaita :: * } ;
|
macro_rules ! label { (
|
||||||
|
$ ( @ hexpand : $ hexpand : expr , ) ?
|
||||||
|
$ ( @ vexpand : $ vexpand : expr , ) ?
|
||||||
|
$ ( @ halign : $ halign : expr , ) ?
|
||||||
|
$ ( @ valign : $ valign : expr , ) ?
|
||||||
|
$ ( $ label : expr ) ? $ (,) ?
|
||||||
|
) => { {
|
||||||
|
let label = gtk4 :: Label :: builder () . build () ;
|
||||||
|
$ ( label . set_hexpand ( $ hexpand ) ; ) ?
|
||||||
|
$ ( label . set_vexpand ( $ vexpand ) ; ) ?
|
||||||
|
$ ( label . set_halign ( $ halign ) ; ) ?
|
||||||
|
$ ( label . set_valign ( $ valign ) ; ) ?
|
||||||
|
$ ( label . set_label ( $ label ) ; ) ?
|
||||||
|
label
|
||||||
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! g_box { (
|
||||||
|
$ ( @ orientation : $ orientation : expr , ) ?
|
||||||
pub fn create_label ( label : & str ) -> Label {
|
$ ( $ child : expr ) , * $ (,) ?
|
||||||
Label :: builder () . label (label) . build ()
|
) => { {
|
||||||
}
|
let container = gtk4 :: Box :: builder () . build () ;
|
||||||
|
$ ( container . set_orientation ( $ orientation ) ; ) ?
|
||||||
macro_rules ! create_horizontal_box { ( $ ( $ child : expr , ) * ) => { {
|
|
||||||
let container = gtk4 :: Box :: builder ()
|
|
||||||
. orientation ( gtk4 :: Orientation :: Horizontal )
|
|
||||||
. build () ;
|
|
||||||
$ ( container . append ( $ child ) ; ) *
|
$ ( container . append ( $ child ) ; ) *
|
||||||
container
|
container
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
macro_rules ! create_vertical_box { ( $ ( $ child : expr , ) * ) => { {
|
macro_rules ! view_stack { (
|
||||||
let container = gtk4 :: Box :: builder ()
|
|
||||||
. orientation ( gtk4 :: Orientation :: Vertical)
|
|
||||||
. build () ;
|
|
||||||
$ ( container . append ( $ child ) ; ) *
|
|
||||||
container
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! create_view_stack { (
|
|
||||||
$ ( $ title : expr , $ icon : expr , $ widget : expr , ) *
|
$ ( $ title : expr , $ icon : expr , $ widget : expr , ) *
|
||||||
) => { {
|
) => { {
|
||||||
let container = ViewStack :: new () ;
|
let container = libadwaita :: ViewStack :: new () ;
|
||||||
$ ( container . add_titled_with_icon ( $ widget , None , $ title , $ icon ) ; ) *
|
$ ( container . add_titled_with_icon ( $ widget , None , $ title , $ icon ) ; ) *
|
||||||
container
|
container
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
pub fn create_vertical_filler_container ( child : & impl IsA <Widget> ) -> gtk4 :: Box {
|
macro_rules ! list_box { ( $ ( $ child : expr , ) * ) => { {
|
||||||
create_vertical_box ! (
|
let container = gtk4 :: ListBox :: new () ;
|
||||||
child ,
|
$ ( container . append ( $ child ) ; ) *
|
||||||
& Bin :: builder ()
|
container
|
||||||
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! vertically_filling { ( $ child : expr ) => {
|
||||||
|
g_box ! (
|
||||||
|
@ orientation : gtk4 :: Orientation :: Vertical ,
|
||||||
|
$ child ,
|
||||||
|
& libadwaita :: Bin :: builder ()
|
||||||
. css_name ("filler")
|
. css_name ("filler")
|
||||||
. vexpand (true)
|
. vexpand (true)
|
||||||
. build () ,
|
. build () ,
|
||||||
)
|
)
|
||||||
}
|
} }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub (crate) use { create_horizontal_box , create_vertical_box , create_view_stack } ;
|
pub (crate) use {
|
||||||
|
label ,
|
||||||
|
g_box ,
|
||||||
|
view_stack ,
|
||||||
|
list_box ,
|
||||||
|
vertically_filling ,
|
||||||
|
} ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue