macro_rules! layout {
[ $ui:expr ,
let $ctl:ident = Button ( $text:expr )
] => { ... };
[ $ui:expr ,
let $ctl:ident = Checkbox ( $text:expr $( , checked: $checked:expr )? )
] => { ... };
[ $ui:expr ,
let $ctl:ident = ColorButton ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = Combobox ( $( selected: $selected:expr )? )
{ $( $option:expr ),* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = DateTimePicker ( $kind:ident )
] => { ... };
[ $ui:expr ,
let $ctl:ident = EditableCombobox ()
{ $( $option:expr ),* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = Entry ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = FontButton ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = HorizontalSeparator ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = Label ( $text:expr )
] => { ... };
[ $ui:expr ,
let $ctl:ident = MultilineEntry ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = MultilineEntry ( wrapping: $wrapping:expr )
] => { ... };
[ $ui:expr ,
let $ctl:ident = PasswordEntry ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = RadioButtons ( $( selected: $selected:expr )? )
{ $( $option:expr ),* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = SearchEntry ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = Slider ( $min:expr , $max:expr )
] => { ... };
[ $ui:expr ,
let $ctl:ident = Spacer ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = Spinbox ( $min:expr , $max:expr )
] => { ... };
[ $ui:expr ,
let $ctl:ident = Spinbox ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = ProgressBar ()
] => { ... };
[ $ui:expr ,
let $ctl:ident = Form ( $( padded: $padded:expr )? )
{ $(
( $strategy:ident, $name:expr ) :
let $child:ident = $type:ident ($($opt:tt)*) $({$($body:tt)*})?
)* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = Group ( $title:expr $( , margined: $margined:expr )? )
{ $(
let $child:ident = $type:ident ($($opt:tt)*) $({$($body:tt)*})?
)? }
] => { ... };
[ $ui:expr ,
let $ctl:ident = HorizontalBox ( $( padded: $padded:expr )? )
{ $(
$strategy:ident :
let $child:ident = $type:ident ($($opt:tt)*) $({$($body:tt)*})?
)* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = LayoutGrid ( $( padded: $padded:expr )? )
{ $(
( $x:expr , $y:expr ) ( $xspan:expr , $yspan:expr )
$expand:ident ( $halign:ident , $valign:ident ) :
let $child:ident = $type:ident ($($opt:tt)*) $({$($body:tt)*})?
)* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = TabGroup ()
{ $(
( $name:expr $( , margined: $margined:expr )? ) :
let $child:ident = $type:ident ($($opt:tt)*) $({$($body:tt)*})?
)* }
] => { ... };
[ $ui:expr ,
let $ctl:ident = VerticalBox ( $( padded: $padded:expr )? )
{ $(
$strategy:ident :
let $child:ident = $type:ident ($($opt:tt)*) $({$($body:tt)*})?
)* }
] => { ... };
}Expand description
Creates layout code from a compact, declarative and hierarchical UI description.
ยงExample
For a more example, see the builder example application in the repository.
extern crate libui;
use libui::prelude::*;
fn main() {
let ui = UI::init().unwrap();
libui::layout! { &ui,
let layout = VerticalBox(padded: true) {
Compact: let form = Form(padded: true) {
(Compact, "User"): let tb_user = Entry()
(Compact, "Password"): let tb_passwd = Entry()
}
Stretchy: let bt_submit = Button("Submit")
}
}
let mut window = Window::new(&ui, "Builder Example", 320, 200,
WindowType::NoMenubar);
window.set_child(layout);
window.show();
ui.main();
}