diff --git a/masonry/README.md b/masonry/README.md index c1e66ef77..f0e3b9f1c 100644 --- a/masonry/README.md +++ b/masonry/README.md @@ -51,9 +51,9 @@ impl AppDriver for Driver { match action { Action::ButtonPressed(_) => { let mut root: WidgetMut>> = ctx.get_root(); - let mut root = root.child_mut(); - let mut flex = root.child_mut(); - flex.add_child(Label::new(self.next_task.clone())); + let mut portal = RootWidget::child_mut(&mut root); + let mut flex = Portal::child_mut(&mut portal); + Flex::add_child(&mut flex, Label::new(self.next_task.clone())); } Action::TextChanged(new_text) => { self.next_task = new_text.clone(); diff --git a/masonry/examples/calc_masonry.rs b/masonry/examples/calc_masonry.rs index e0fce9565..92b2c57b0 100644 --- a/masonry/examples/calc_masonry.rs +++ b/masonry/examples/calc_masonry.rs @@ -147,7 +147,7 @@ impl Widget for CalcButton { let color = self.active_color; // See on_status_change for why we use `mutate_later` here. ctx.mutate_later(&mut self.inner, move |mut inner| { - inner.set_background(color); + SizedBox::set_background(&mut inner, color); }); ctx.capture_pointer(); trace!("CalcButton {:?} pressed", ctx.widget_id()); @@ -158,7 +158,7 @@ impl Widget for CalcButton { let color = self.base_color; // See on_status_change for why we use `mutate_later` here. ctx.mutate_later(&mut self.inner, move |mut inner| { - inner.set_background(color); + SizedBox::set_background(&mut inner, color); }); ctx.submit_action(Action::Other(Box::new(self.action))); trace!("CalcButton {:?} released", ctx.widget_id()); @@ -190,7 +190,7 @@ impl Widget for CalcButton { match event { Update::HoveredChanged(true) => { ctx.mutate_later(&mut self.inner, move |mut inner| { - inner.set_border(Color::WHITE, 3.0); + SizedBox::set_border(&mut inner, Color::WHITE, 3.0); }); // FIXME - This is a monkey-patch for a problem where the mutate pass isn't run after this. // Should be fixed once the pass spec RFC is implemented. @@ -198,7 +198,7 @@ impl Widget for CalcButton { } Update::HoveredChanged(false) => { ctx.mutate_later(&mut self.inner, move |mut inner| { - inner.set_border(Color::TRANSPARENT, 3.0); + SizedBox::set_border(&mut inner, Color::TRANSPARENT, 3.0); }); // FIXME - This is a monkey-patch for a problem where the mutate pass isn't run after this. // Should be fixed once the pass spec RFC is implemented. @@ -254,12 +254,11 @@ impl AppDriver for CalcState { _ => unreachable!(), } - ctx.get_root::>() - .child_mut() - .child_mut(1) - .unwrap() - .downcast::