2025-01-31 11:38:06 +01:00
|
|
|
mod collated_grid ;
|
|
|
|
|
mod collation_menu ;
|
|
|
|
|
|
|
|
|
|
use gtk4 :: { * , Orientation :: * , prelude :: * } ;
|
2024-11-20 17:18:22 +01:00
|
|
|
|
|
|
|
|
use crate :: {
|
2025-02-05 00:03:26 +01:00
|
|
|
data_manager :: * ,
|
2024-11-27 15:22:55 +01:00
|
|
|
ui :: {
|
2025-01-31 15:34:09 +01:00
|
|
|
component :: * , utility :: * ,
|
2025-01-31 11:38:06 +01:00
|
|
|
collatable_container :: { collated_grid :: * , collation_menu :: * } ,
|
2024-11-27 15:22:55 +01:00
|
|
|
} ,
|
2024-11-20 17:18:22 +01:00
|
|
|
utility :: * ,
|
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
2024-11-26 16:49:19 +01:00
|
|
|
|
2025-01-31 16:24:22 +01:00
|
|
|
# [ derive ( Clone , Copy , PartialEq ) ] pub enum FilmProperty { Name , ReleaseDate , Runtime }
|
|
|
|
|
# [ derive ( Clone , Copy , PartialEq ) ] pub enum SeriesProperty { Name , FirstReleaseDate }
|
2025-01-31 15:34:09 +01:00
|
|
|
# [ derive ( Clone , Copy , PartialEq ) ] pub enum SortingDirection { Ascending , Descending }
|
|
|
|
|
|
2025-01-31 17:38:52 +01:00
|
|
|
# [ derive ( Clone , Copy ) ] pub struct FilmsSorting {
|
|
|
|
|
property : FilmProperty ,
|
|
|
|
|
direction : SortingDirection ,
|
|
|
|
|
}
|
|
|
|
|
# [ derive ( Clone , Copy ) ] pub struct SeriesSorting {
|
|
|
|
|
property : SeriesProperty ,
|
|
|
|
|
direction : SortingDirection ,
|
|
|
|
|
}
|
2025-01-31 16:24:22 +01:00
|
|
|
|
|
|
|
|
impl FilmsSorting {
|
2025-01-31 17:38:52 +01:00
|
|
|
pub fn new ( property : FilmProperty , direction : SortingDirection ) -> Self {
|
|
|
|
|
Self { property , direction }
|
|
|
|
|
}
|
2025-01-31 16:24:22 +01:00
|
|
|
}
|
|
|
|
|
impl SeriesSorting {
|
2025-01-31 17:38:52 +01:00
|
|
|
pub fn new ( property : SeriesProperty , direction : SortingDirection ) -> Self {
|
|
|
|
|
Self { property , direction }
|
|
|
|
|
}
|
2025-01-31 16:24:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for FilmsSorting {
|
|
|
|
|
fn default () -> Self { Self {
|
|
|
|
|
property : FilmProperty :: Name ,
|
|
|
|
|
direction : SortingDirection :: Ascending ,
|
|
|
|
|
} }
|
|
|
|
|
}
|
|
|
|
|
impl Default for SeriesSorting {
|
|
|
|
|
fn default () -> Self { Self {
|
|
|
|
|
property : SeriesProperty :: Name ,
|
|
|
|
|
direction : SortingDirection :: Ascending ,
|
|
|
|
|
} }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-01-31 11:38:06 +01:00
|
|
|
|
2024-11-26 17:20:53 +01:00
|
|
|
pub struct CollatableFilmsContainer {
|
2024-11-27 11:47:20 +01:00
|
|
|
collated_grid : & 'static CollatedFilmsGrid ,
|
2024-11-27 15:22:55 +01:00
|
|
|
widget : Box ,
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|
2024-11-26 17:20:53 +01:00
|
|
|
pub struct CollatableSeriesContainer {
|
2024-11-27 11:47:20 +01:00
|
|
|
collated_grid : & 'static CollatedSeriesGrid ,
|
2024-11-27 15:22:55 +01:00
|
|
|
widget : Box ,
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-26 17:20:53 +01:00
|
|
|
impl CollatableFilmsContainer {
|
2025-02-05 13:51:22 +01:00
|
|
|
pub fn new () -> Self {
|
|
|
|
|
let collated_grid = leak ( CollatedFilmsGrid :: new () ) ;
|
2025-01-31 16:24:22 +01:00
|
|
|
let film_collation_menu = FilmCollationMenu :: new ( |sorting|
|
|
|
|
|
collated_grid . set_sorting (sorting) ) ;
|
2024-11-27 15:22:55 +01:00
|
|
|
|
2025-01-31 11:38:06 +01:00
|
|
|
let widget = g_box ! (
|
2025-02-04 15:02:58 +01:00
|
|
|
@ orientation : Vertical ;
|
2025-01-31 15:34:09 +01:00
|
|
|
* film_collation_menu . get_widget () ,
|
2025-01-31 16:24:22 +01:00
|
|
|
scrolled_window ! (
|
2025-02-04 15:02:58 +01:00
|
|
|
@ propagate_natural_height : true ;
|
2025-01-31 16:24:22 +01:00
|
|
|
vertically_filling ! ( * collated_grid . get_widget () ) ,
|
|
|
|
|
) ,
|
2024-11-20 17:18:22 +01:00
|
|
|
) ;
|
|
|
|
|
|
2024-11-27 11:47:20 +01:00
|
|
|
Self { collated_grid , widget }
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 13:51:22 +01:00
|
|
|
pub async fn set_films ( & self , films : Vec <FilmOverview> ) {
|
|
|
|
|
self . collated_grid . set_films ( films , FilmsSorting :: default () ) . await ;
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-26 17:20:53 +01:00
|
|
|
impl CollatableSeriesContainer {
|
2025-02-05 13:51:22 +01:00
|
|
|
pub fn new () -> Self {
|
|
|
|
|
let collated_grid = leak ( CollatedSeriesGrid :: new () ) ;
|
2025-01-31 17:09:22 +01:00
|
|
|
let series_collation_menu = SeriesCollationMenu :: new ( |sorting| {
|
|
|
|
|
collated_grid . set_sorting (sorting) ;
|
2024-11-27 15:22:55 +01:00
|
|
|
} ) ;
|
|
|
|
|
|
2025-01-31 11:38:06 +01:00
|
|
|
let widget = g_box ! (
|
2025-02-04 15:02:58 +01:00
|
|
|
@ orientation : Vertical ;
|
2025-01-31 15:34:09 +01:00
|
|
|
* series_collation_menu . get_widget () ,
|
2025-01-31 17:09:22 +01:00
|
|
|
scrolled_window ! (
|
2025-02-04 15:02:58 +01:00
|
|
|
@ propagate_natural_height : true ;
|
2025-01-31 17:09:22 +01:00
|
|
|
vertically_filling ! ( * collated_grid . get_widget () ) ,
|
|
|
|
|
) ,
|
2024-11-20 17:18:22 +01:00
|
|
|
) ;
|
|
|
|
|
|
2024-11-27 11:47:20 +01:00
|
|
|
Self { collated_grid , widget }
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 13:51:22 +01:00
|
|
|
pub async fn set_series ( & self , series : Vec <SeriesOverview> ) {
|
|
|
|
|
self . collated_grid . set_series ( series , SeriesSorting :: default () ) . await ;
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|
2024-11-27 15:22:55 +01:00
|
|
|
}
|
2024-11-20 17:18:22 +01:00
|
|
|
|
2024-11-27 15:22:55 +01:00
|
|
|
impl Component <Box> for CollatableFilmsContainer {
|
|
|
|
|
fn get_widget ( & self ) -> & Box { & self . widget }
|
|
|
|
|
}
|
|
|
|
|
impl Component <Box> for CollatableSeriesContainer {
|
|
|
|
|
fn get_widget ( & self ) -> & Box { & self . widget }
|
2024-11-20 17:18:22 +01:00
|
|
|
}
|