Collection items are now clickable
This commit is contained in:
parent
a9ec7bdcc9
commit
c3dfa5b459
3 changed files with 45 additions and 22 deletions
|
@ -12,3 +12,7 @@
|
|||
#series-collation-menu row:not(:selected) image {
|
||||
opacity : 0 ;
|
||||
}
|
||||
|
||||
.open-collection-item-button {
|
||||
font-weight : normal ; /* No bold text by default for this kind of button */
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ use crate :: ui :: component :: * ;
|
|||
|
||||
|
||||
pub struct CollatedFilmsGrid {
|
||||
film_widget_pairs : RefCell < Vec < ( FilmOverview , Box ) > > ,
|
||||
film_widget_pairs : RefCell < Vec < ( FilmOverview , Button ) > > ,
|
||||
grid_widget : FlowBox ,
|
||||
}
|
||||
pub struct CollatedSeriesGrid {
|
||||
series_widget_pairs : RefCell < Vec < ( SeriesOverview , Box ) > > ,
|
||||
series_widget_pairs : RefCell < Vec < ( SeriesOverview , Button ) > > ,
|
||||
grid_widget : FlowBox ,
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,7 @@ impl CollatedFilmsGrid {
|
|||
for film in films . as_slice () {
|
||||
widgets . push ( create_film_entry (film) . await ) ;
|
||||
}
|
||||
* self . film_widget_pairs . borrow_mut () = zip ( films , widgets )
|
||||
. collect () ;
|
||||
self . film_widget_pairs . replace ( zip ( films , widgets ) . collect () ) ;
|
||||
|
||||
for ( _ , film_widget ) in self . sort_film_widget_pairs (sorting) {
|
||||
self . grid_widget . append ( & film_widget ) ;
|
||||
|
@ -58,7 +57,7 @@ impl CollatedFilmsGrid {
|
|||
}
|
||||
}
|
||||
|
||||
fn sort_film_widget_pairs ( & self , sorting : FilmsSorting ) -> Vec < ( FilmOverview , Box ) > {
|
||||
fn sort_film_widget_pairs ( & self , sorting : FilmsSorting ) -> Vec < ( FilmOverview , Button ) > {
|
||||
let mut sorted = Vec :: from (
|
||||
self . film_widget_pairs . borrow () . as_slice () ) ;
|
||||
|
||||
|
@ -93,8 +92,7 @@ impl CollatedSeriesGrid {
|
|||
for series in series . as_slice () {
|
||||
widgets . push ( create_series_entry (series) . await ) ;
|
||||
}
|
||||
* self . series_widget_pairs . borrow_mut () = zip ( series , widgets )
|
||||
. collect () ;
|
||||
self . series_widget_pairs . replace ( zip ( series , widgets ) . collect () ) ;
|
||||
|
||||
for ( _ , series_widget ) in self . sort_series_widget_pairs (sorting) {
|
||||
self . grid_widget . append ( & series_widget ) ;
|
||||
|
@ -109,7 +107,7 @@ impl CollatedSeriesGrid {
|
|||
}
|
||||
}
|
||||
|
||||
fn sort_series_widget_pairs ( & self , sorting : SeriesSorting ) -> Vec < ( SeriesOverview , Box ) > {
|
||||
fn sort_series_widget_pairs ( & self , sorting : SeriesSorting ) -> Vec < ( SeriesOverview , Button ) > {
|
||||
let mut sorted = Vec :: from (
|
||||
self . series_widget_pairs . borrow () . as_slice () ) ;
|
||||
|
||||
|
@ -133,21 +131,29 @@ impl Component <FlowBox> for CollatedSeriesGrid {
|
|||
fn get_widget ( & self ) -> & FlowBox { & self . grid_widget }
|
||||
}
|
||||
|
||||
pub async fn create_film_entry ( film : & FilmOverview ) -> Box {
|
||||
create_collection_item (
|
||||
film . name . as_str () ,
|
||||
film . original_name . as_deref () ,
|
||||
film . poster_file_path . as_deref () ,
|
||||
& create_film_details (film) ,
|
||||
) . await
|
||||
async fn create_film_entry ( film : & FilmOverview ) -> Button {
|
||||
button ! (
|
||||
@ css_classes : & [ "flat" , "open-collection-item-button" ] ;
|
||||
@ connect_clicked : |_| todo ! () ;
|
||||
& create_collection_item (
|
||||
film . name . as_str () ,
|
||||
film . original_name . as_deref () ,
|
||||
film . poster_file_path . as_deref () ,
|
||||
& create_film_details (film) ,
|
||||
) . await ,
|
||||
)
|
||||
}
|
||||
pub async fn create_series_entry ( series : & SeriesOverview ) -> Box {
|
||||
create_collection_item (
|
||||
series . name . as_str () ,
|
||||
series . original_name . as_deref () ,
|
||||
series . poster_file_path . as_deref () ,
|
||||
& create_series_details (series) ,
|
||||
) . await
|
||||
async fn create_series_entry ( series : & SeriesOverview ) -> Button {
|
||||
button ! (
|
||||
@ css_classes : & [ "flat" , "open-collection-item-button" ] ;
|
||||
@ connect_clicked : |_| todo ! () ;
|
||||
& create_collection_item (
|
||||
series . name . as_str () ,
|
||||
series . original_name . as_deref () ,
|
||||
series . poster_file_path . as_deref () ,
|
||||
& create_series_details (series) ,
|
||||
) . await ,
|
||||
)
|
||||
}
|
||||
|
||||
async fn create_collection_item (
|
||||
|
|
|
@ -90,6 +90,18 @@ macro_rules ! list_box { (
|
|||
container
|
||||
} } }
|
||||
|
||||
macro_rules ! button { (
|
||||
$ ( @ css_classes : $ css_classes : expr ; ) ?
|
||||
$ ( @ connect_clicked : $ connect_clicked : expr ; ) ?
|
||||
$ ( $ child : expr ) ? $ (,) ?
|
||||
) => { {
|
||||
let button = gtk4 :: Button :: new () ;
|
||||
$ ( button . set_css_classes ( $ css_classes ) ; ) ?
|
||||
$ ( button . connect_clicked ( $ connect_clicked ) ; ) ?
|
||||
$ ( button . set_child ( Some ( $ child ) ) ; ) ?
|
||||
button
|
||||
} } }
|
||||
|
||||
macro_rules ! split_button { (
|
||||
$ ( @ popover : $ popover : expr ; ) ?
|
||||
$ child : expr $ (,) ?
|
||||
|
@ -214,6 +226,7 @@ pub (crate) use {
|
|||
g_box ,
|
||||
view_stack ,
|
||||
list_box ,
|
||||
button ,
|
||||
split_button ,
|
||||
popover ,
|
||||
image ,
|
||||
|
|
Loading…
Add table
Reference in a new issue