Move collation components into submodules

This commit is contained in:
Reinout Meliesie 2025-01-31 11:38:06 +01:00
commit ebc8bc0d2f
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
7 changed files with 85 additions and 44 deletions

View file

@ -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
} } }
pub fn create_label ( label : & str ) -> Label {
Label :: builder () . label (label) . build ()
}
macro_rules ! create_horizontal_box { ( $ ( $ child : expr , ) * ) => { {
let container = gtk4 :: Box :: builder ()
. orientation ( gtk4 :: Orientation :: Horizontal )
. build () ;
macro_rules ! g_box { (
$ ( @ orientation : $ orientation : expr , ) ?
$ ( $ child : expr ) , * $ (,) ?
) => { {
let container = gtk4 :: Box :: builder () . build () ;
$ ( container . set_orientation ( $ orientation ) ; ) ?
$ ( container . append ( $ child ) ; ) *
container
} } }
macro_rules ! create_vertical_box { ( $ ( $ child : expr , ) * ) => { {
let container = gtk4 :: Box :: builder ()
. orientation ( gtk4 :: Orientation :: Vertical)
. build () ;
$ ( container . append ( $ child ) ; ) *
container
} } }
macro_rules ! create_view_stack { (
macro_rules ! view_stack { (
$ ( $ 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
} } }
pub fn create_vertical_filler_container ( child : & impl IsA <Widget> ) -> gtk4 :: Box {
create_vertical_box ! (
child ,
& Bin :: builder ()
macro_rules ! list_box { ( $ ( $ child : expr , ) * ) => { {
let container = gtk4 :: ListBox :: new () ;
$ ( container . append ( $ child ) ; ) *
container
} } }
macro_rules ! vertically_filling { ( $ child : expr ) => {
g_box ! (
@ orientation : gtk4 :: Orientation :: Vertical ,
$ child ,
& libadwaita :: Bin :: builder ()
. css_name ("filler")
. vexpand (true)
. 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 ,
} ;