Rename Drawable::boxed to into_element and make containers generic

Multi-element are now generic over any drawable child, which can be converted
into an element.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Antonio Scandurra 2023-04-21 18:36:21 +02:00 committed by Nathan Sobo
parent 4d433663bd
commit 03619dfa55
80 changed files with 1132 additions and 1434 deletions

View file

@ -77,9 +77,9 @@ impl View for Toolbar {
.contained()
.with_margin_right(spacing);
if let Some((flex, expanded)) = flex {
primary_left_items.push(left_item.flex(flex, expanded).boxed());
primary_left_items.push(left_item.flex(flex, expanded).into_element());
} else {
primary_left_items.push(left_item.boxed());
primary_left_items.push(left_item.into_element());
}
}
@ -90,9 +90,9 @@ impl View for Toolbar {
.with_margin_left(spacing)
.flex_float();
if let Some((flex, expanded)) = flex {
primary_right_items.push(right_item.flex(flex, expanded).boxed());
primary_right_items.push(right_item.flex(flex, expanded).into_element());
} else {
primary_right_items.push(right_item.boxed());
primary_right_items.push(right_item.into_element());
}
}
@ -101,7 +101,7 @@ impl View for Toolbar {
ChildView::new(item.as_any(), cx)
.constrained()
.with_height(theme.height)
.boxed(),
.into_element(),
);
}
}
@ -151,13 +151,12 @@ impl View for Toolbar {
.with_children(primary_left_items)
.with_children(primary_right_items)
.constrained()
.with_height(height)
.boxed(),
.with_height(height),
)
.with_children(secondary_item)
.contained()
.with_style(container_style)
.boxed()
.into_named_element("toolbar")
}
}
@ -190,7 +189,6 @@ fn nav_button<A: Action + Clone>(
.with_width(style.button_width)
.with_height(style.button_width)
.aligned()
.boxed()
})
.with_cursor_style(if enabled {
CursorStyle::PointingHand
@ -209,7 +207,7 @@ fn nav_button<A: Action + Clone>(
)
.contained()
.with_margin_right(spacing)
.boxed()
.into_named_element("nav button")
}
impl Toolbar {