orbtk: example popup update
@@ -67,13 +67,9 @@ impl MainViewState {
let placement: Placement = ctx.child(ID_POPUP).clone_or_default("placement");
match selected_index {
0 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.bottom()),
- 1 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.bottom_left()),
- 2 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.bottom_right()),
- 3 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.left()),
- 4 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.right()),
- 5 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.top()),
- 6 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.top_left()),
- 7 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.top_right()),
+ 1 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.left()),
+ 2 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.right()),
+ 3 => Popup::placement_set(&mut ctx.child(ID_POPUP), placement.top()),
_ => panic!(),
}
if cfg!(debug) {
@@ -102,8 +98,10 @@ impl MainViewState {
impl State for MainViewState {
fn init(&mut self, _registry: &mut Registry, ctx: &mut Context) {
// initialize the popup properties
- ctx.child(ID_POPUP).set("open", false);
- ctx.child(ID_POPUP).set("visibility", Visibility::Collapsed);
+ let offset: f64 = ctx.child(ID_PLACEMENT_OFFSET).clone("val");
+ Popup::offset_set(&mut ctx.child(ID_POPUP), offset);
+ Popup::open_set(&mut ctx.child(ID_POPUP), false);
+ Popup::visibility_set(&mut ctx.child(ID_POPUP), Visibility::Collapsed);
}
fn messages(
@@ -158,13 +156,9 @@ impl Template for MainView {
let placements = vec![
// TODO: make it sort independent
"Bottom".to_string(),
- "BottomLeft".to_string(),
- "BottomRight".to_string(),
"Left".to_string(),
"Right".to_string(),
"Top".to_string(),
- "TopLeft".to_string(),
- "TopRight".to_string(),
];
let count_placements = placements.len();
@@ -282,7 +276,7 @@ impl Template for MainView {
.attach(Grid::row(0))
.attach(Grid::column(2))
.count(count_placements)
- //.style("combo_box")
+ .style("combo_box")
.items_builder(move |ibc, index| {
let text = MainView::placements_ref(&ibc.get_widget(id))
[index]
