Give widget access to taffy layout

This commit is contained in:
Joscha 2024-03-09 00:07:59 +01:00
parent f4a6435e6f
commit 4f14d70152
3 changed files with 26 additions and 8 deletions

View file

@ -55,13 +55,13 @@ impl<C> Tree<C> {
node: NodeId,
view: &mut View<'_>,
) -> anyhow::Result<()> {
let layout = self.tree.layout(node)?;
let layout = *self.tree.layout(node)?;
let area = Rect::from_nw(point_to_vec2(layout.location), size_to_vec2(layout.size));
let mut view = view.dup().zoom(area);
// First pass
if let Some(widget) = self.tree.get_node_context_mut(node) {
widget.draw_below(ctx, &mut view)?;
widget.draw_below(ctx, &mut view, &layout)?;
}
// Render children
@ -77,7 +77,7 @@ impl<C> Tree<C> {
// Second pass
if let Some(widget) = self.tree.get_node_context_mut(node) {
widget.draw_above(ctx, &mut view)?;
widget.draw_above(ctx, &mut view, &layout)?;
}
Ok(())