Introduce image UI macro, require explicit borrowing in UI macros

This commit is contained in:
Reinout Meliesie 2025-02-07 13:36:14 +01:00
commit 38adb5f4b9
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
7 changed files with 88 additions and 75 deletions

View file

@ -156,11 +156,11 @@ async fn create_collection_item (
poster_file_path : Option < & Path > ,
details_widget : & Box ,
) -> Box {
let container = Box :: builder ()
. orientation (Vertical)
. margin_top (20)
. margin_bottom (20)
. build () ;
let container = g_box ! (
@ orientation : Vertical ;
@ margin_top : 20 ;
@ margin_bottom : 20 ;
) ;
if let Some (poster_file_path) = poster_file_path {
let poster_file_path = PathBuf :: from (poster_file_path) ; // God forbid `Path` would work with `clone ! ()`
@ -169,12 +169,12 @@ async fn create_collection_item (
) . await . unwrap () ;
container . append (
& Image :: builder ()
. paintable ( & poster_texture )
. width_request (300)
. height_request (300)
. margin_bottom (10)
. build ()
& image ! (
@ paintable : & poster_texture ;
@ width_request : 300 ;
@ height_request : 300 ;
@ margin_bottom : 10 ;
)
) ;
}
@ -209,8 +209,8 @@ fn create_film_details ( film : & FilmOverview ) -> Box {
@ orientation : Horizontal ;
@ halign : Center ;
@ spacing : 20 ;
label ! ( film . release_date . as_str () ) ,
label ! ( format ! ( "{}m" , film . runtime_minutes ) . as_str () ) ,
& label ! ( film . release_date . as_str () ) ,
& label ! ( format ! ( "{}m" , film . runtime_minutes ) . as_str () ) ,
)
}
fn create_series_details ( series : & SeriesOverview ) -> Box {
@ -218,6 +218,6 @@ fn create_series_details ( series : & SeriesOverview ) -> Box {
@ orientation : Horizontal ;
@ halign : Center ;
@ spacing : 20 ;
label ! ( series . first_release_date . as_str () ) ,
& label ! ( series . first_release_date . as_str () ) ,
)
}