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 {
|
#series-collation-menu row:not(:selected) image {
|
||||||
opacity : 0 ;
|
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 {
|
pub struct CollatedFilmsGrid {
|
||||||
film_widget_pairs : RefCell < Vec < ( FilmOverview , Box ) > > ,
|
film_widget_pairs : RefCell < Vec < ( FilmOverview , Button ) > > ,
|
||||||
grid_widget : FlowBox ,
|
grid_widget : FlowBox ,
|
||||||
}
|
}
|
||||||
pub struct CollatedSeriesGrid {
|
pub struct CollatedSeriesGrid {
|
||||||
series_widget_pairs : RefCell < Vec < ( SeriesOverview , Box ) > > ,
|
series_widget_pairs : RefCell < Vec < ( SeriesOverview , Button ) > > ,
|
||||||
grid_widget : FlowBox ,
|
grid_widget : FlowBox ,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,7 @@ impl CollatedFilmsGrid {
|
||||||
for film in films . as_slice () {
|
for film in films . as_slice () {
|
||||||
widgets . push ( create_film_entry (film) . await ) ;
|
widgets . push ( create_film_entry (film) . await ) ;
|
||||||
}
|
}
|
||||||
* self . film_widget_pairs . borrow_mut () = zip ( films , widgets )
|
self . film_widget_pairs . replace ( zip ( films , widgets ) . collect () ) ;
|
||||||
. collect () ;
|
|
||||||
|
|
||||||
for ( _ , film_widget ) in self . sort_film_widget_pairs (sorting) {
|
for ( _ , film_widget ) in self . sort_film_widget_pairs (sorting) {
|
||||||
self . grid_widget . append ( & film_widget ) ;
|
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 (
|
let mut sorted = Vec :: from (
|
||||||
self . film_widget_pairs . borrow () . as_slice () ) ;
|
self . film_widget_pairs . borrow () . as_slice () ) ;
|
||||||
|
|
||||||
|
@ -93,8 +92,7 @@ impl CollatedSeriesGrid {
|
||||||
for series in series . as_slice () {
|
for series in series . as_slice () {
|
||||||
widgets . push ( create_series_entry (series) . await ) ;
|
widgets . push ( create_series_entry (series) . await ) ;
|
||||||
}
|
}
|
||||||
* self . series_widget_pairs . borrow_mut () = zip ( series , widgets )
|
self . series_widget_pairs . replace ( zip ( series , widgets ) . collect () ) ;
|
||||||
. collect () ;
|
|
||||||
|
|
||||||
for ( _ , series_widget ) in self . sort_series_widget_pairs (sorting) {
|
for ( _ , series_widget ) in self . sort_series_widget_pairs (sorting) {
|
||||||
self . grid_widget . append ( & series_widget ) ;
|
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 (
|
let mut sorted = Vec :: from (
|
||||||
self . series_widget_pairs . borrow () . as_slice () ) ;
|
self . series_widget_pairs . borrow () . as_slice () ) ;
|
||||||
|
|
||||||
|
@ -133,21 +131,29 @@ impl Component <FlowBox> for CollatedSeriesGrid {
|
||||||
fn get_widget ( & self ) -> & FlowBox { & self . grid_widget }
|
fn get_widget ( & self ) -> & FlowBox { & self . grid_widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_film_entry ( film : & FilmOverview ) -> Box {
|
async fn create_film_entry ( film : & FilmOverview ) -> Button {
|
||||||
create_collection_item (
|
button ! (
|
||||||
|
@ css_classes : & [ "flat" , "open-collection-item-button" ] ;
|
||||||
|
@ connect_clicked : |_| todo ! () ;
|
||||||
|
& create_collection_item (
|
||||||
film . name . as_str () ,
|
film . name . as_str () ,
|
||||||
film . original_name . as_deref () ,
|
film . original_name . as_deref () ,
|
||||||
film . poster_file_path . as_deref () ,
|
film . poster_file_path . as_deref () ,
|
||||||
& create_film_details (film) ,
|
& create_film_details (film) ,
|
||||||
) . await
|
) . await ,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
pub async fn create_series_entry ( series : & SeriesOverview ) -> Box {
|
async fn create_series_entry ( series : & SeriesOverview ) -> Button {
|
||||||
create_collection_item (
|
button ! (
|
||||||
|
@ css_classes : & [ "flat" , "open-collection-item-button" ] ;
|
||||||
|
@ connect_clicked : |_| todo ! () ;
|
||||||
|
& create_collection_item (
|
||||||
series . name . as_str () ,
|
series . name . as_str () ,
|
||||||
series . original_name . as_deref () ,
|
series . original_name . as_deref () ,
|
||||||
series . poster_file_path . as_deref () ,
|
series . poster_file_path . as_deref () ,
|
||||||
& create_series_details (series) ,
|
& create_series_details (series) ,
|
||||||
) . await
|
) . await ,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_collection_item (
|
async fn create_collection_item (
|
||||||
|
|
|
@ -90,6 +90,18 @@ macro_rules ! list_box { (
|
||||||
container
|
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 { (
|
macro_rules ! split_button { (
|
||||||
$ ( @ popover : $ popover : expr ; ) ?
|
$ ( @ popover : $ popover : expr ; ) ?
|
||||||
$ child : expr $ (,) ?
|
$ child : expr $ (,) ?
|
||||||
|
@ -214,6 +226,7 @@ pub (crate) use {
|
||||||
g_box ,
|
g_box ,
|
||||||
view_stack ,
|
view_stack ,
|
||||||
list_box ,
|
list_box ,
|
||||||
|
button ,
|
||||||
split_button ,
|
split_button ,
|
||||||
popover ,
|
popover ,
|
||||||
image ,
|
image ,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue