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

@ -343,20 +343,18 @@ impl View for ActivityIndicator {
.contained() .contained()
.with_margin_right(style.icon_spacing) .with_margin_right(style.icon_spacing)
.aligned() .aligned()
.named("activity-icon") .into_named_element("activity-icon")
})) }))
.with_child( .with_child(
Text::new(message, style.message.clone()) Text::new(message, style.message.clone())
.with_soft_wrap(false) .with_soft_wrap(false)
.aligned() .aligned(),
.boxed(),
) )
.constrained() .constrained()
.with_height(style.height) .with_height(style.height)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.aligned() .aligned()
.boxed()
}); });
if let Some(action) = action { if let Some(action) = action {
@ -367,7 +365,7 @@ impl View for ActivityIndicator {
}); });
} }
element.boxed() element.into_element()
} }
} }

View file

@ -46,8 +46,7 @@ impl View for UpdateNotification {
.aligned() .aligned()
.top() .top()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<Cancel, _>::new(0, cx, |state, _| { MouseEventHandler::<Cancel, _>::new(0, cx, |state, _| {
@ -62,7 +61,6 @@ impl View for UpdateNotification {
.constrained() .constrained()
.with_width(style.button_width) .with_width(style.button_width)
.with_height(style.button_width) .with_height(style.button_width)
.boxed()
}) })
.with_padding(Padding::uniform(5.)) .with_padding(Padding::uniform(5.))
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -73,26 +71,22 @@ impl View for UpdateNotification {
.with_height(cx.font_cache().line_height(theme.message.text.font_size)) .with_height(cx.font_cache().line_height(theme.message.text.font_size))
.aligned() .aligned()
.top() .top()
.flex_float() .flex_float(),
.boxed(), ),
)
.boxed(),
) )
.with_child({ .with_child({
let style = theme.action_message.style_for(state, false); let style = theme.action_message.style_for(state, false);
Text::new("View the release notes", style.text.clone()) Text::new("View the release notes", style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.contained() .contained()
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(ViewReleaseNotes) cx.dispatch_action(ViewReleaseNotes)
}) })
.boxed() .into_named_element("update notification")
} }
} }

View file

@ -44,7 +44,7 @@ impl View for Breadcrumbs {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
let active_item = match &self.active_item { let active_item = match &self.active_item {
Some(active_item) => active_item, Some(active_item) => active_item,
None => return Empty::new().boxed(), None => return Empty::new().into_element(),
}; };
let not_editor = active_item.downcast::<editor::Editor>().is_none(); let not_editor = active_item.downcast::<editor::Editor>().is_none();
@ -53,24 +53,21 @@ impl View for Breadcrumbs {
let breadcrumbs = match active_item.breadcrumbs(&theme, cx) { let breadcrumbs = match active_item.breadcrumbs(&theme, cx) {
Some(breadcrumbs) => breadcrumbs, Some(breadcrumbs) => breadcrumbs,
None => return Empty::new().boxed(), None => return Empty::new().into_element(),
} }
.into_iter() .into_iter()
.map(|breadcrumb| { .map(|breadcrumb| {
let text = Text::new( Text::new(
breadcrumb.text, breadcrumb.text,
theme.workspace.breadcrumbs.default.text.clone(), theme.workspace.breadcrumbs.default.text.clone(),
); )
if let Some(highlights) = breadcrumb.highlights { .with_highlights(breadcrumb.highlights.unwrap_or_default())
text.with_highlights(highlights).boxed() .into_element()
} else {
text.boxed()
}
}); });
let crumbs = Flex::row() let crumbs = Flex::row()
.with_children(Itertools::intersperse_with(breadcrumbs, || { .with_children(Itertools::intersperse_with(breadcrumbs, || {
Label::new("", style.default.text.clone()).boxed() Label::new("", style.default.text.clone()).into_element()
})) }))
.constrained() .constrained()
.with_height(theme.workspace.breadcrumb_height) .with_height(theme.workspace.breadcrumb_height)
@ -81,12 +78,12 @@ impl View for Breadcrumbs {
.with_style(style.default.container) .with_style(style.default.container)
.aligned() .aligned()
.left() .left()
.boxed(); .into_element();
} }
MouseEventHandler::<Breadcrumbs, Breadcrumbs>::new(0, cx, |state, _| { MouseEventHandler::<Breadcrumbs, Breadcrumbs>::new(0, cx, |state, _| {
let style = style.style_for(state, false); let style = style.style_for(state, false);
crumbs.with_style(style.container).boxed() crumbs.with_style(style.container)
}) })
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(outline::Toggle); cx.dispatch_action(outline::Toggle);
@ -100,7 +97,7 @@ impl View for Breadcrumbs {
) )
.aligned() .aligned()
.left() .left()
.boxed() .into_element()
} }
} }

View file

@ -72,7 +72,7 @@ impl View for CollabTitlebarItem {
let workspace = if let Some(workspace) = self.workspace.upgrade(cx) { let workspace = if let Some(workspace) = self.workspace.upgrade(cx) {
workspace workspace
} else { } else {
return Empty::new().boxed(); return Empty::new().into_element();
}; };
let project = workspace.read(cx).project().read(cx); let project = workspace.read(cx).project().read(cx);
@ -97,8 +97,7 @@ impl View for CollabTitlebarItem {
.contained() .contained()
.with_margin_right(theme.workspace.titlebar.item_spacing) .with_margin_right(theme.workspace.titlebar.item_spacing)
.aligned() .aligned()
.left() .left(),
.boxed(),
); );
let user = workspace.read(cx).user_store().read(cx).current_user(); let user = workspace.read(cx).user_store().read(cx).current_user();
@ -128,9 +127,9 @@ impl View for CollabTitlebarItem {
} }
Stack::new() Stack::new()
.with_child(left_container.boxed()) .with_child(left_container)
.with_child(right_container.aligned().right().boxed()) .with_child(right_container.aligned().right())
.boxed() .into_element()
} }
} }
@ -294,13 +293,13 @@ impl CollabTitlebarItem {
Color::transparent_black(), Color::transparent_black(),
) )
})) }))
.with_child( .with_child(Label::new(
Label::new(user.github_login.clone(), item_style.label.clone()) user.github_login.clone(),
.boxed(), item_style.label.clone(),
) ))
.contained() .contained()
.with_style(item_style.container) .with_style(item_style.container)
.boxed() .into_element()
})), })),
ContextMenuItem::item("Sign out", SignOut), ContextMenuItem::item("Sign out", SignOut),
ContextMenuItem::item("Send Feedback", feedback::feedback_editor::GiveFeedback), ContextMenuItem::item("Send Feedback", feedback::feedback_editor::GiveFeedback),
@ -345,8 +344,7 @@ impl CollabTitlebarItem {
.contained() .contained()
.with_margin_left(titlebar.toggle_contacts_button.default.icon_width) .with_margin_left(titlebar.toggle_contacts_button.default.icon_width)
.with_margin_top(titlebar.toggle_contacts_button.default.icon_width) .with_margin_top(titlebar.toggle_contacts_button.default.icon_width)
.aligned() .aligned(),
.boxed(),
) )
}; };
@ -366,7 +364,6 @@ impl CollabTitlebarItem {
.with_height(style.button_width) .with_height(style.button_width)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -378,12 +375,11 @@ impl CollabTitlebarItem {
Some(Box::new(ToggleContactsMenu)), Some(Box::new(ToggleContactsMenu)),
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
) ),
.boxed(),
) )
.with_children(badge) .with_children(badge)
.with_children(self.render_contacts_popover_host(titlebar, cx)) .with_children(self.render_contacts_popover_host(titlebar, cx))
.boxed() .into_element()
} }
fn render_toggle_screen_sharing_button( fn render_toggle_screen_sharing_button(
@ -415,7 +411,6 @@ impl CollabTitlebarItem {
.with_height(style.button_width) .with_height(style.button_width)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -429,7 +424,7 @@ impl CollabTitlebarItem {
cx, cx,
) )
.aligned() .aligned()
.boxed() .into_element()
} }
fn render_in_call_share_unshare_button( fn render_in_call_share_unshare_button(
@ -463,7 +458,6 @@ impl CollabTitlebarItem {
Label::new(label, style.text.clone()) Label::new(label, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -479,13 +473,12 @@ impl CollabTitlebarItem {
None, None,
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
) ),
.boxed(),
) )
.aligned() .aligned()
.contained() .contained()
.with_margin_left(theme.workspace.titlebar.item_spacing) .with_margin_left(theme.workspace.titlebar.item_spacing)
.boxed(), .into_element(),
) )
} }
@ -506,7 +499,6 @@ impl CollabTitlebarItem {
.with_height(style.button_width) .with_height(style.button_width)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -520,17 +512,15 @@ impl CollabTitlebarItem {
cx, cx,
) )
.contained() .contained()
.with_margin_left(theme.workspace.titlebar.item_spacing) .with_margin_left(theme.workspace.titlebar.item_spacing),
.boxed(),
) )
.with_child( .with_child(
ChildView::new(&self.user_menu, cx) ChildView::new(&self.user_menu, cx)
.aligned() .aligned()
.bottom() .bottom()
.right() .right(),
.boxed(),
) )
.boxed() .into_element()
} }
fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> Element<Self> { fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> Element<Self> {
@ -540,13 +530,12 @@ impl CollabTitlebarItem {
Label::new("Sign In", style.text.clone()) Label::new("Sign In", style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(SignIn); cx.dispatch_action(SignIn);
}) })
.boxed() .into_element()
} }
fn render_contacts_popover_host<'a>( fn render_contacts_popover_host<'a>(
@ -555,14 +544,14 @@ impl CollabTitlebarItem {
cx: &'a ViewContext<Self>, cx: &'a ViewContext<Self>,
) -> Option<Element<Self>> { ) -> Option<Element<Self>> {
self.contacts_popover.as_ref().map(|popover| { self.contacts_popover.as_ref().map(|popover| {
Overlay::new(ChildView::new(popover, cx).boxed()) Overlay::new(ChildView::new(popover, cx))
.with_fit_mode(OverlayFitMode::SwitchAnchor) .with_fit_mode(OverlayFitMode::SwitchAnchor)
.with_anchor_corner(AnchorCorner::TopRight) .with_anchor_corner(AnchorCorner::TopRight)
.with_z_index(999) .with_z_index(999)
.aligned() .aligned()
.bottom() .bottom()
.right() .right()
.boxed() .into_element()
}) })
} }
@ -572,7 +561,7 @@ impl CollabTitlebarItem {
theme: &Theme, theme: &Theme,
room: &ModelHandle<Room>, room: &ModelHandle<Room>,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) -> Vec<Element<Self>> { ) -> Vec<Container<Self>> {
let mut participants = room let mut participants = room
.read(cx) .read(cx)
.remote_participants() .remote_participants()
@ -600,8 +589,7 @@ impl CollabTitlebarItem {
theme, theme,
cx, cx,
)) ))
.with_margin_right(theme.workspace.titlebar.face_pile_spacing) .with_margin_right(theme.workspace.titlebar.face_pile_spacing),
.boxed(),
) )
}) })
.collect() .collect()
@ -626,7 +614,7 @@ impl CollabTitlebarItem {
cx, cx,
)) ))
.with_margin_right(theme.workspace.titlebar.item_spacing) .with_margin_right(theme.workspace.titlebar.item_spacing)
.boxed() .into_element()
} }
fn render_face_pile( fn render_face_pile(
@ -730,7 +718,7 @@ impl CollabTitlebarItem {
} }
} }
container.boxed() container
})) }))
.with_children((|| { .with_children((|| {
let replica_id = replica_id?; let replica_id = replica_id?;
@ -741,11 +729,10 @@ impl CollabTitlebarItem {
.with_width(theme.workspace.titlebar.avatar_ribbon.width) .with_width(theme.workspace.titlebar.avatar_ribbon.width)
.with_height(theme.workspace.titlebar.avatar_ribbon.height) .with_height(theme.workspace.titlebar.avatar_ribbon.height)
.aligned() .aligned()
.bottom() .bottom(),
.boxed(),
) )
})()) })())
.boxed(); .into_element();
if let Some(location) = location { if let Some(location) = location {
if let Some(replica_id) = replica_id { if let Some(replica_id) = replica_id {
@ -769,7 +756,7 @@ impl CollabTitlebarItem {
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
) )
.boxed(); .into_element();
} else if let ParticipantLocation::SharedProject { project_id } = location { } else if let ParticipantLocation::SharedProject { project_id } = location {
let user_id = user.id; let user_id = user.id;
content = MouseEventHandler::<JoinProject, Self>::new( content = MouseEventHandler::<JoinProject, Self>::new(
@ -791,7 +778,7 @@ impl CollabTitlebarItem {
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
) )
.boxed(); .into_element();
} }
} }
content content
@ -831,7 +818,7 @@ impl CollabTitlebarItem {
.with_width(avatar_style.outer_width) .with_width(avatar_style.outer_width)
.with_height(avatar_style.outer_width) .with_height(avatar_style.outer_width)
.aligned() .aligned()
.boxed() .into_element()
} }
fn render_connection_status( fn render_connection_status(
@ -848,20 +835,14 @@ impl CollabTitlebarItem {
| client::Status::Reauthenticating { .. } | client::Status::Reauthenticating { .. }
| client::Status::Reconnecting { .. } | client::Status::Reconnecting { .. }
| client::Status::ReconnectionError { .. } => Some( | client::Status::ReconnectionError { .. } => Some(
Container::new(
Align::new(
ConstrainedBox::new(
Svg::new("icons/cloud_slash_12.svg") Svg::new("icons/cloud_slash_12.svg")
.with_color(theme.workspace.titlebar.offline_icon.color) .with_color(theme.workspace.titlebar.offline_icon.color)
.boxed(), .constrained()
)
.with_width(theme.workspace.titlebar.offline_icon.width) .with_width(theme.workspace.titlebar.offline_icon.width)
.boxed(), .aligned()
) .contained()
.boxed(),
)
.with_style(theme.workspace.titlebar.offline_icon.container) .with_style(theme.workspace.titlebar.offline_icon.container)
.boxed(), .into_element(),
), ),
client::Status::UpgradeRequired => Some( client::Status::UpgradeRequired => Some(
MouseEventHandler::<ConnectionStatusButton, Self>::new(0, cx, |_, _| { MouseEventHandler::<ConnectionStatusButton, Self>::new(0, cx, |_, _| {
@ -872,13 +853,12 @@ impl CollabTitlebarItem {
.contained() .contained()
.with_style(theme.workspace.titlebar.outdated_warning.container) .with_style(theme.workspace.titlebar.outdated_warning.container)
.aligned() .aligned()
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(auto_update::Check); cx.dispatch_action(auto_update::Check);
}) })
.boxed(), .into_element(),
), ),
_ => None, _ => None,
} }

View file

@ -40,12 +40,11 @@ impl View for CollaboratorListPopover {
.constrained() .constrained()
.with_width(theme.contacts_popover.width) .with_width(theme.contacts_popover.width)
.with_height(theme.contacts_popover.height) .with_height(theme.contacts_popover.height)
.boxed()
}) })
.on_down_out(MouseButton::Left, move |_, _, cx| { .on_down_out(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(ToggleCollaboratorList); cx.dispatch_action(ToggleCollaboratorList);
}) })
.boxed() .into_element()
} }
fn focus_out(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_out(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {
@ -129,7 +128,7 @@ fn render_collaborator_list_entry<UA: Action + Clone, IA: Action + Clone>(
let username = let username =
MouseEventHandler::<Username, CollaboratorListPopover>::new(index, cx, |_, _| { MouseEventHandler::<Username, CollaboratorListPopover>::new(index, cx, |_, _| {
Label::new(username.to_owned(), username_theme.clone()).boxed() Label::new(username.to_owned(), username_theme.clone())
}) })
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
if let Some(username_action) = username_action.clone() { if let Some(username_action) = username_action.clone() {
@ -147,17 +146,16 @@ fn render_collaborator_list_entry<UA: Action + Clone, IA: Action + Clone>(
tooltip_theme.clone(), tooltip_theme.clone(),
cx, cx,
) )
.boxed() .into_element()
} else { } else {
username.boxed() username.into_element()
}) })
.with_child( .with_child(
MouseEventHandler::<Icon, CollaboratorListPopover>::new(index, cx, |_, _| icon.boxed()) MouseEventHandler::<Icon, CollaboratorListPopover>::new(index, cx, |_, _| icon)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(icon_action.clone()) cx.dispatch_action(icon_action.clone())
}) })
.with_tooltip::<IconTooltip>(index, icon_tooltip, None, tooltip_theme, cx) .with_tooltip::<IconTooltip>(index, icon_tooltip, None, tooltip_theme, cx),
.boxed(),
) )
.boxed() .into_element()
} }

View file

@ -124,15 +124,13 @@ impl PickerDelegate for ContactFinderDelegate {
.with_style(theme.contact_finder.contact_avatar) .with_style(theme.contact_finder.contact_avatar)
.aligned() .aligned()
.left() .left()
.boxed()
})) }))
.with_child( .with_child(
Label::new(user.github_login.clone(), style.label.clone()) Label::new(user.github_login.clone(), style.label.clone())
.contained() .contained()
.with_style(theme.contact_finder.contact_username) .with_style(theme.contact_finder.contact_username)
.aligned() .aligned()
.left() .left(),
.boxed(),
) )
.with_children(icon_path.map(|icon_path| { .with_children(icon_path.map(|icon_path| {
Svg::new(icon_path) Svg::new(icon_path)
@ -147,12 +145,11 @@ impl PickerDelegate for ContactFinderDelegate {
.with_height(button_style.button_width) .with_height(button_style.button_width)
.aligned() .aligned()
.flex_float() .flex_float()
.boxed()
})) }))
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.constrained() .constrained()
.with_height(theme.contact_finder.row_height) .with_height(theme.contact_finder.row_height)
.boxed() .into_element()
} }
} }

View file

@ -755,7 +755,6 @@ impl ContactList {
.with_style(theme.contact_avatar) .with_style(theme.contact_avatar)
.aligned() .aligned()
.left() .left()
.boxed()
})) }))
.with_child( .with_child(
Label::new( Label::new(
@ -766,16 +765,14 @@ impl ContactList {
.with_style(theme.contact_username.container) .with_style(theme.contact_username.container)
.aligned() .aligned()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_children(if is_pending { .with_children(if is_pending {
Some( Some(
Label::new("Calling", theme.calling_indicator.text.clone()) Label::new("Calling", theme.calling_indicator.text.clone())
.contained() .contained()
.with_style(theme.calling_indicator.container) .with_style(theme.calling_indicator.container)
.aligned() .aligned(),
.boxed(),
) )
} else { } else {
None None
@ -788,7 +785,7 @@ impl ContactList {
.contact_row .contact_row
.style_for(&mut Default::default(), is_selected), .style_for(&mut Default::default(), is_selected),
) )
.boxed() .into_element()
} }
fn render_participant_project( fn render_participant_project(
@ -826,10 +823,9 @@ impl ContactList {
Flex::row() Flex::row()
.with_child( .with_child(
Stack::new() Stack::new()
.with_child( .with_child(Canvas::new(move |scene, bounds, _, _, _| {
Canvas::new(move |scene, bounds, _, _, _| { let start_x =
let start_x = bounds.min_x() + (bounds.width() / 2.) bounds.min_x() + (bounds.width() / 2.) - (tree_branch.width / 2.);
- (tree_branch.width / 2.);
let end_x = bounds.max_x(); let end_x = bounds.max_x();
let start_y = bounds.min_y(); let start_y = bounds.min_y();
let end_y = bounds.min_y() + baseline_offset - (cap_height / 2.); let end_y = bounds.min_y() + baseline_offset - (cap_height / 2.);
@ -855,12 +851,9 @@ impl ContactList {
border: gpui::Border::default(), border: gpui::Border::default(),
corner_radius: 0., corner_radius: 0.,
}); });
}) }))
.boxed(),
)
.constrained() .constrained()
.with_width(host_avatar_height) .with_width(host_avatar_height),
.boxed(),
) )
.with_child( .with_child(
Label::new(project_name, row.name.text.clone()) Label::new(project_name, row.name.text.clone())
@ -868,14 +861,12 @@ impl ContactList {
.left() .left()
.contained() .contained()
.with_style(row.name.container) .with_style(row.name.container)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.constrained() .constrained()
.with_height(theme.row_height) .with_height(theme.row_height)
.contained() .contained()
.with_style(row.container) .with_style(row.container)
.boxed()
}) })
.with_cursor_style(if !is_current { .with_cursor_style(if !is_current {
CursorStyle::PointingHand CursorStyle::PointingHand
@ -890,7 +881,7 @@ impl ContactList {
}); });
} }
}) })
.boxed() .into_element()
} }
fn render_participant_screen( fn render_participant_screen(
@ -923,14 +914,12 @@ impl ContactList {
Flex::row() Flex::row()
.with_child( .with_child(
Stack::new() Stack::new()
.with_child( .with_child(Canvas::new(move |scene, bounds, _, _, _| {
Canvas::new(move |scene, bounds, _, _, _| {
let start_x = bounds.min_x() + (bounds.width() / 2.) let start_x = bounds.min_x() + (bounds.width() / 2.)
- (tree_branch.width / 2.); - (tree_branch.width / 2.);
let end_x = bounds.max_x(); let end_x = bounds.max_x();
let start_y = bounds.min_y(); let start_y = bounds.min_y();
let end_y = let end_y = bounds.min_y() + baseline_offset - (cap_height / 2.);
bounds.min_y() + baseline_offset - (cap_height / 2.);
scene.push_quad(gpui::Quad { scene.push_quad(gpui::Quad {
bounds: RectF::from_points( bounds: RectF::from_points(
@ -953,12 +942,9 @@ impl ContactList {
border: gpui::Border::default(), border: gpui::Border::default(),
corner_radius: 0., corner_radius: 0.,
}); });
}) }))
.boxed(),
)
.constrained() .constrained()
.with_width(host_avatar_height) .with_width(host_avatar_height),
.boxed(),
) )
.with_child( .with_child(
Svg::new("icons/disable_screen_sharing_12.svg") Svg::new("icons/disable_screen_sharing_12.svg")
@ -968,8 +954,7 @@ impl ContactList {
.aligned() .aligned()
.left() .left()
.contained() .contained()
.with_style(row.icon.container) .with_style(row.icon.container),
.boxed(),
) )
.with_child( .with_child(
Label::new("Screen", row.name.text.clone()) Label::new("Screen", row.name.text.clone())
@ -977,21 +962,19 @@ impl ContactList {
.left() .left()
.contained() .contained()
.with_style(row.name.container) .with_style(row.name.container)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.constrained() .constrained()
.with_height(theme.row_height) .with_height(theme.row_height)
.contained() .contained()
.with_style(row.container) .with_style(row.container)
.boxed()
}, },
) )
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(OpenSharedScreen { peer_id }); cx.dispatch_action(OpenSharedScreen { peer_id });
}) })
.boxed() .into_element()
} }
fn render_header( fn render_header(
@ -1020,11 +1003,9 @@ impl ContactList {
Label::new("Leave Call", style.text.clone()) Label::new("Leave Call", style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_click(MouseButton::Left, |_, _, cx| cx.dispatch_action(LeaveCall)) .on_click(MouseButton::Left, |_, _, cx| cx.dispatch_action(LeaveCall))
.aligned() .aligned(),
.boxed(),
) )
} else { } else {
None None
@ -1045,8 +1026,7 @@ impl ContactList {
.with_max_height(icon_size) .with_max_height(icon_size)
.aligned() .aligned()
.constrained() .constrained()
.with_width(icon_size) .with_width(icon_size),
.boxed(),
) )
.with_child( .with_child(
Label::new(text, header_style.text.clone()) Label::new(text, header_style.text.clone())
@ -1054,21 +1034,19 @@ impl ContactList {
.left() .left()
.contained() .contained()
.with_margin_left(theme.contact_username.container.margin.left) .with_margin_left(theme.contact_username.container.margin.left)
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_children(leave_call) .with_children(leave_call)
.constrained() .constrained()
.with_height(theme.row_height) .with_height(theme.row_height)
.contained() .contained()
.with_style(header_style.container) .with_style(header_style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(ToggleExpanded(section)) cx.dispatch_action(ToggleExpanded(section))
}) })
.boxed() .into_element()
} }
fn render_contact( fn render_contact(
@ -1084,7 +1062,7 @@ impl ContactList {
let user_id = contact.user.id; let user_id = contact.user.id;
let github_login = contact.user.github_login.clone(); let github_login = contact.user.github_login.clone();
let initial_project = project.clone(); let initial_project = project.clone();
let mut element = let mut event_handler =
MouseEventHandler::<Contact, Self>::new(contact.user.id as usize, cx, |_, cx| { MouseEventHandler::<Contact, Self>::new(contact.user.id as usize, cx, |_, cx| {
Flex::row() Flex::row()
.with_children(contact.user.avatar.clone().map(|avatar| { .with_children(contact.user.avatar.clone().map(|avatar| {
@ -1098,8 +1076,7 @@ impl ContactList {
} else { } else {
theme.contact_status_free theme.contact_status_free
}) })
.aligned() .aligned(),
.boxed(),
) )
} else { } else {
None None
@ -1109,11 +1086,9 @@ impl ContactList {
Image::from_data(avatar) Image::from_data(avatar)
.with_style(theme.contact_avatar) .with_style(theme.contact_avatar)
.aligned() .aligned()
.left() .left(),
.boxed(),
) )
.with_children(status_badge) .with_children(status_badge)
.boxed()
})) }))
.with_child( .with_child(
Label::new( Label::new(
@ -1124,8 +1099,7 @@ impl ContactList {
.with_style(theme.contact_username.container) .with_style(theme.contact_username.container)
.aligned() .aligned()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<Cancel, Self>::new( MouseEventHandler::<Cancel, Self>::new(
@ -1137,7 +1111,6 @@ impl ContactList {
render_icon_button(button_style, "icons/x_mark_8.svg") render_icon_button(button_style, "icons/x_mark_8.svg")
.aligned() .aligned()
.flex_float() .flex_float()
.boxed()
}, },
) )
.with_padding(Padding::uniform(2.)) .with_padding(Padding::uniform(2.))
@ -1148,16 +1121,14 @@ impl ContactList {
github_login: github_login.clone(), github_login: github_login.clone(),
}) })
}) })
.flex_float() .flex_float(),
.boxed(),
) )
.with_children(if calling { .with_children(if calling {
Some( Some(
Label::new("Calling", theme.calling_indicator.text.clone()) Label::new("Calling", theme.calling_indicator.text.clone())
.contained() .contained()
.with_style(theme.calling_indicator.container) .with_style(theme.calling_indicator.container)
.aligned() .aligned(),
.boxed(),
) )
} else { } else {
None None
@ -1170,7 +1141,6 @@ impl ContactList {
.contact_row .contact_row
.style_for(&mut Default::default(), is_selected), .style_for(&mut Default::default(), is_selected),
) )
.boxed()
}) })
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
if online && !busy { if online && !busy {
@ -1182,10 +1152,10 @@ impl ContactList {
}); });
if online { if online {
element = element.with_cursor_style(CursorStyle::PointingHand); event_handler = event_handler.with_cursor_style(CursorStyle::PointingHand);
} }
element.boxed() event_handler.into_element()
} }
fn render_contact_request( fn render_contact_request(
@ -1206,7 +1176,6 @@ impl ContactList {
.with_style(theme.contact_avatar) .with_style(theme.contact_avatar)
.aligned() .aligned()
.left() .left()
.boxed()
})) }))
.with_child( .with_child(
Label::new( Label::new(
@ -1217,8 +1186,7 @@ impl ContactList {
.with_style(theme.contact_username.container) .with_style(theme.contact_username.container)
.aligned() .aligned()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
); );
let user_id = user.id; let user_id = user.id;
@ -1227,16 +1195,14 @@ impl ContactList {
let button_spacing = theme.contact_button_spacing; let button_spacing = theme.contact_button_spacing;
if is_incoming { if is_incoming {
row.add_children([ row.add_child(
MouseEventHandler::<Decline, Self>::new(user.id as usize, cx, |mouse_state, _| { MouseEventHandler::<Decline, Self>::new(user.id as usize, cx, |mouse_state, _| {
let button_style = if is_contact_request_pending { let button_style = if is_contact_request_pending {
&theme.disabled_button &theme.disabled_button
} else { } else {
theme.contact_button.style_for(mouse_state, false) theme.contact_button.style_for(mouse_state, false)
}; };
render_icon_button(button_style, "icons/x_mark_8.svg") render_icon_button(button_style, "icons/x_mark_8.svg").aligned()
.aligned()
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -1246,8 +1212,10 @@ impl ContactList {
}) })
}) })
.contained() .contained()
.with_margin_right(button_spacing) .with_margin_right(button_spacing),
.boxed(), );
row.add_child(
MouseEventHandler::<Accept, Self>::new(user.id as usize, cx, |mouse_state, _| { MouseEventHandler::<Accept, Self>::new(user.id as usize, cx, |mouse_state, _| {
let button_style = if is_contact_request_pending { let button_style = if is_contact_request_pending {
&theme.disabled_button &theme.disabled_button
@ -1257,7 +1225,6 @@ impl ContactList {
render_icon_button(button_style, "icons/check_8.svg") render_icon_button(button_style, "icons/check_8.svg")
.aligned() .aligned()
.flex_float() .flex_float()
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -1265,9 +1232,8 @@ impl ContactList {
user_id, user_id,
accept: true, accept: true,
}) })
}) }),
.boxed(), );
]);
} else { } else {
row.add_child( row.add_child(
MouseEventHandler::<Cancel, Self>::new(user.id as usize, cx, |mouse_state, _| { MouseEventHandler::<Cancel, Self>::new(user.id as usize, cx, |mouse_state, _| {
@ -1279,7 +1245,6 @@ impl ContactList {
render_icon_button(button_style, "icons/x_mark_8.svg") render_icon_button(button_style, "icons/x_mark_8.svg")
.aligned() .aligned()
.flex_float() .flex_float()
.boxed()
}) })
.with_padding(Padding::uniform(2.)) .with_padding(Padding::uniform(2.))
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -1289,8 +1254,7 @@ impl ContactList {
github_login: github_login.clone(), github_login: github_login.clone(),
}) })
}) })
.flex_float() .flex_float(),
.boxed(),
); );
} }
@ -1302,7 +1266,7 @@ impl ContactList {
.contact_row .contact_row
.style_for(&mut Default::default(), is_selected), .style_for(&mut Default::default(), is_selected),
) )
.boxed() .into_element()
} }
fn call(&mut self, action: &Call, cx: &mut ViewContext<Self>) { fn call(&mut self, action: &Call, cx: &mut ViewContext<Self>) {
@ -1342,8 +1306,7 @@ impl View for ContactList {
ChildView::new(&self.filter_editor, cx) ChildView::new(&self.filter_editor, cx)
.contained() .contained()
.with_style(theme.contact_list.user_query_editor.container) .with_style(theme.contact_list.user_query_editor.container)
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<AddContact, Self>::new(0, cx, |_, _| { MouseEventHandler::<AddContact, Self>::new(0, cx, |_, _| {
@ -1351,7 +1314,6 @@ impl View for ContactList {
&theme.contact_list.add_contact_button, &theme.contact_list.add_contact_button,
"icons/user_plus_16.svg", "icons/user_plus_16.svg",
) )
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
@ -1363,15 +1325,13 @@ impl View for ContactList {
None, None,
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
) ),
.boxed(),
) )
.constrained() .constrained()
.with_height(theme.contact_list.user_query_editor_height) .with_height(theme.contact_list.user_query_editor_height),
.boxed(),
) )
.with_child(List::new(self.list_state.clone()).flex(1., false).boxed()) .with_child(List::new(self.list_state.clone()).flex(1., false))
.boxed() .into_element()
} }
fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {

View file

@ -105,18 +105,17 @@ impl View for ContactsPopover {
MouseEventHandler::<ContactsPopover, Self>::new(0, cx, |_, _| { MouseEventHandler::<ContactsPopover, Self>::new(0, cx, |_, _| {
Flex::column() Flex::column()
.with_child(child.flex(1., true).boxed()) .with_child(child.flex(1., true))
.contained() .contained()
.with_style(theme.contacts_popover.container) .with_style(theme.contacts_popover.container)
.constrained() .constrained()
.with_width(theme.contacts_popover.width) .with_width(theme.contacts_popover.width)
.with_height(theme.contacts_popover.height) .with_height(theme.contacts_popover.height)
.boxed()
}) })
.on_down_out(MouseButton::Left, move |_, _, cx| { .on_down_out(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(ToggleContactsMenu); cx.dispatch_action(ToggleContactsMenu);
}) })
.boxed() .into_element()
} }
fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {

View file

@ -112,7 +112,6 @@ impl IncomingCallNotification {
Image::from_data(avatar) Image::from_data(avatar)
.with_style(theme.caller_avatar) .with_style(theme.caller_avatar)
.aligned() .aligned()
.boxed()
})) }))
.with_child( .with_child(
Flex::column() Flex::column()
@ -122,8 +121,7 @@ impl IncomingCallNotification {
theme.caller_username.text.clone(), theme.caller_username.text.clone(),
) )
.contained() .contained()
.with_style(theme.caller_username.container) .with_style(theme.caller_username.container),
.boxed(),
) )
.with_child( .with_child(
Label::new( Label::new(
@ -138,8 +136,7 @@ impl IncomingCallNotification {
theme.caller_message.text.clone(), theme.caller_message.text.clone(),
) )
.contained() .contained()
.with_style(theme.caller_message.container) .with_style(theme.caller_message.container),
.boxed(),
) )
.with_children(if initial_project.worktree_root_names.is_empty() { .with_children(if initial_project.worktree_root_names.is_empty() {
None None
@ -150,19 +147,17 @@ impl IncomingCallNotification {
theme.worktree_roots.text.clone(), theme.worktree_roots.text.clone(),
) )
.contained() .contained()
.with_style(theme.worktree_roots.container) .with_style(theme.worktree_roots.container),
.boxed(),
) )
}) })
.contained() .contained()
.with_style(theme.caller_metadata) .with_style(theme.caller_metadata)
.aligned() .aligned(),
.boxed(),
) )
.contained() .contained()
.with_style(theme.caller_container) .with_style(theme.caller_container)
.flex(1., true) .flex(1., true)
.boxed() .into_element()
} }
fn render_buttons(&self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render_buttons(&self, cx: &mut ViewContext<Self>) -> Element<Self> {
@ -177,14 +172,12 @@ impl IncomingCallNotification {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.accept_button.container) .with_style(theme.accept_button.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(RespondToCall { accept: true }); cx.dispatch_action(RespondToCall { accept: true });
}) })
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<Decline, Self>::new(0, cx, |_, cx| { MouseEventHandler::<Decline, Self>::new(0, cx, |_, cx| {
@ -193,14 +186,12 @@ impl IncomingCallNotification {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.decline_button.container) .with_style(theme.decline_button.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(RespondToCall { accept: false }); cx.dispatch_action(RespondToCall { accept: false });
}) })
.flex(1., true) .flex(1., true),
.boxed(),
) )
.constrained() .constrained()
.with_width( .with_width(
@ -209,7 +200,7 @@ impl IncomingCallNotification {
.incoming_call_notification .incoming_call_notification
.button_width, .button_width,
) )
.boxed() .into_element()
} }
} }
@ -235,6 +226,6 @@ impl View for IncomingCallNotification {
.contained() .contained()
.with_background_color(background) .with_background_color(background)
.expanded() .expanded()
.boxed() .into_element()
} }
} }

View file

@ -35,7 +35,6 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
) )
.aligned() .aligned()
.top() .top()
.boxed()
})) }))
.with_child( .with_child(
Text::new( Text::new(
@ -47,8 +46,7 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
.aligned() .aligned()
.top() .top()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<Dismiss, V>::new(user.id as usize, cx, |state, _| { MouseEventHandler::<Dismiss, V>::new(user.id as usize, cx, |state, _| {
@ -63,7 +61,6 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
.constrained() .constrained()
.with_width(style.button_width) .with_width(style.button_width)
.with_height(style.button_width) .with_height(style.button_width)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.with_padding(Padding::uniform(5.)) .with_padding(Padding::uniform(5.))
@ -78,16 +75,14 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
) )
.aligned() .aligned()
.top() .top()
.flex_float() .flex_float(),
.boxed(),
) )
.named("contact notification header"), .into_named_element("contact notification header"),
) )
.with_children(body.map(|body| { .with_children(body.map(|body| {
Label::new(body, theme.body_message.text.clone()) Label::new(body, theme.body_message.text.clone())
.contained() .contained()
.with_style(theme.body_message.container) .with_style(theme.body_message.container)
.boxed()
})) }))
.with_children(if buttons.is_empty() { .with_children(if buttons.is_empty() {
None None
@ -101,20 +96,17 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
Label::new(message, button.text.clone()) Label::new(message, button.text.clone())
.contained() .contained()
.with_style(button.container) .with_style(button.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_any_action(action.boxed_clone()) cx.dispatch_any_action(action.boxed_clone())
}) })
.boxed()
}, },
)) ))
.aligned() .aligned()
.right() .right(),
.boxed(),
) )
}) })
.contained() .contained()
.boxed() .into_element()
} }

View file

@ -109,7 +109,6 @@ impl ProjectSharedNotification {
Image::from_data(avatar) Image::from_data(avatar)
.with_style(theme.owner_avatar) .with_style(theme.owner_avatar)
.aligned() .aligned()
.boxed()
})) }))
.with_child( .with_child(
Flex::column() Flex::column()
@ -119,8 +118,7 @@ impl ProjectSharedNotification {
theme.owner_username.text.clone(), theme.owner_username.text.clone(),
) )
.contained() .contained()
.with_style(theme.owner_username.container) .with_style(theme.owner_username.container),
.boxed(),
) )
.with_child( .with_child(
Label::new( Label::new(
@ -135,8 +133,7 @@ impl ProjectSharedNotification {
theme.message.text.clone(), theme.message.text.clone(),
) )
.contained() .contained()
.with_style(theme.message.container) .with_style(theme.message.container),
.boxed(),
) )
.with_children(if self.worktree_root_names.is_empty() { .with_children(if self.worktree_root_names.is_empty() {
None None
@ -147,19 +144,17 @@ impl ProjectSharedNotification {
theme.worktree_roots.text.clone(), theme.worktree_roots.text.clone(),
) )
.contained() .contained()
.with_style(theme.worktree_roots.container) .with_style(theme.worktree_roots.container),
.boxed(),
) )
}) })
.contained() .contained()
.with_style(theme.owner_metadata) .with_style(theme.owner_metadata)
.aligned() .aligned(),
.boxed(),
) )
.contained() .contained()
.with_style(theme.owner_container) .with_style(theme.owner_container)
.flex(1., true) .flex(1., true)
.boxed() .into_element()
} }
fn render_buttons(&self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render_buttons(&self, cx: &mut ViewContext<Self>) -> Element<Self> {
@ -177,7 +172,6 @@ impl ProjectSharedNotification {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.open_button.container) .with_style(theme.open_button.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -186,8 +180,7 @@ impl ProjectSharedNotification {
follow_user_id: owner_user_id, follow_user_id: owner_user_id,
}); });
}) })
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<Dismiss, Self>::new(0, cx, |_, cx| { MouseEventHandler::<Dismiss, Self>::new(0, cx, |_, cx| {
@ -196,14 +189,12 @@ impl ProjectSharedNotification {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.dismiss_button.container) .with_style(theme.dismiss_button.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(DismissProject); cx.dispatch_action(DismissProject);
}) })
.flex(1., true) .flex(1., true),
.boxed(),
) )
.constrained() .constrained()
.with_width( .with_width(
@ -212,7 +203,7 @@ impl ProjectSharedNotification {
.project_shared_notification .project_shared_notification
.button_width, .button_width,
) )
.boxed() .into_element()
} }
} }
@ -237,6 +228,6 @@ impl View for ProjectSharedNotification {
.contained() .contained()
.with_background_color(background) .with_background_color(background)
.expanded() .expanded()
.boxed() .into_element()
} }
} }

View file

@ -52,11 +52,10 @@ impl View for SharingStatusIndicator {
.constrained() .constrained()
.with_width(18.) .with_width(18.)
.aligned() .aligned()
.boxed()
}) })
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(ToggleScreenSharing); cx.dispatch_action(ToggleScreenSharing);
}) })
.boxed() .into_element()
} }
} }

View file

@ -188,8 +188,7 @@ impl PickerDelegate for CommandPaletteDelegate {
Flex::row() Flex::row()
.with_child( .with_child(
Label::new(mat.string.clone(), style.label.clone()) Label::new(mat.string.clone(), style.label.clone())
.with_highlights(mat.positions.clone()) .with_highlights(mat.positions.clone()),
.boxed(),
) )
.with_children(command.keystrokes.iter().map(|keystroke| { .with_children(command.keystrokes.iter().map(|keystroke| {
Flex::row() Flex::row()
@ -206,8 +205,7 @@ impl PickerDelegate for CommandPaletteDelegate {
Some( Some(
Label::new(label, key_style.label.clone()) Label::new(label, key_style.label.clone())
.contained() .contained()
.with_style(key_style.container) .with_style(key_style.container),
.boxed(),
) )
} else { } else {
None None
@ -217,17 +215,15 @@ impl PickerDelegate for CommandPaletteDelegate {
.with_child( .with_child(
Label::new(keystroke.key.clone(), key_style.label.clone()) Label::new(keystroke.key.clone(), key_style.label.clone())
.contained() .contained()
.with_style(key_style.container) .with_style(key_style.container),
.boxed(),
) )
.contained() .contained()
.with_margin_left(keystroke_spacing) .with_margin_left(keystroke_spacing)
.flex_float() .flex_float()
.boxed()
})) }))
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .into_element()
} }
} }

View file

@ -144,21 +144,20 @@ impl View for ContextMenu {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
if !self.visible { if !self.visible {
return Empty::new().boxed(); return Empty::new().into_element();
} }
// Render the menu once at minimum width. // Render the menu once at minimum width.
let mut collapsed_menu = self.render_menu_for_measurement(cx).boxed(); let mut collapsed_menu = self.render_menu_for_measurement(cx);
let expanded_menu = self let expanded_menu =
.render_menu(cx) self.render_menu(cx)
.constrained() .constrained()
.dynamically(move |constraint, view, cx| { .dynamically(move |constraint, view, cx| {
SizeConstraint::strict_along( SizeConstraint::strict_along(
Axis::Horizontal, Axis::Horizontal,
collapsed_menu.layout(constraint, view, cx).x(), collapsed_menu.layout(constraint, view, cx).0.x(),
) )
}) });
.boxed();
Overlay::new(expanded_menu) Overlay::new(expanded_menu)
.with_hoverable(true) .with_hoverable(true)
@ -166,7 +165,7 @@ impl View for ContextMenu {
.with_anchor_position(self.anchor_position) .with_anchor_position(self.anchor_position)
.with_anchor_corner(self.anchor_corner) .with_anchor_corner(self.anchor_corner)
.with_position_mode(self.position_mode) .with_position_mode(self.position_mode)
.boxed() .into_element()
} }
fn focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
@ -335,8 +334,7 @@ impl ContextMenu {
let style = cx.global::<Settings>().theme.context_menu.clone(); let style = cx.global::<Settings>().theme.context_menu.clone();
Flex::row() Flex::row()
.with_child( .with_child(
Flex::column() Flex::column().with_children(self.items.iter().enumerate().map(|(ix, item)| {
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
match item { match item {
ContextMenuItem::Item { label, .. } => { ContextMenuItem::Item { label, .. } => {
let style = style.item.style_for( let style = style.item.style_for(
@ -349,7 +347,7 @@ impl ContextMenu {
Label::new(label.to_string(), style.label.clone()) Label::new(label.to_string(), style.label.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .into_element()
} }
ContextMenuItemLabel::Element(element) => { ContextMenuItemLabel::Element(element) => {
element(&mut Default::default(), style) element(&mut Default::default(), style)
@ -365,10 +363,9 @@ impl ContextMenu {
.with_style(style.separator) .with_style(style.separator)
.constrained() .constrained()
.with_height(1.) .with_height(1.)
.boxed(), .into_element(),
} }
})) })),
.boxed(),
) )
.with_child( .with_child(
Flex::column() Flex::column()
@ -394,10 +391,10 @@ impl ContextMenu {
style.keystroke.container, style.keystroke.container,
style.keystroke.text.clone(), style.keystroke.text.clone(),
) )
.boxed() .into_element()
} }
ContextMenuItem::Static(_) => Empty::new().boxed(), ContextMenuItem::Static(_) => Empty::new().into_element(),
ContextMenuItem::Separator => Empty::new() ContextMenuItem::Separator => Empty::new()
.collapsed() .collapsed()
@ -405,12 +402,11 @@ impl ContextMenu {
.with_height(1.) .with_height(1.)
.contained() .contained()
.with_style(style.separator) .with_style(style.separator)
.boxed(), .into_element(),
} }
})) }))
.contained() .contained()
.with_margin_left(style.keystroke_margin) .with_margin_left(style.keystroke_margin),
.boxed(),
) )
.contained() .contained()
.with_style(style.container) .with_style(style.container)
@ -445,7 +441,7 @@ impl ContextMenu {
ContextMenuItemLabel::String(label) => { ContextMenuItemLabel::String(label) => {
Label::new(label.clone(), style.label.clone()) Label::new(label.clone(), style.label.clone())
.contained() .contained()
.boxed() .into_element()
} }
ContextMenuItemLabel::Element(element) => { ContextMenuItemLabel::Element(element) => {
element(state, style) element(state, style)
@ -459,11 +455,9 @@ impl ContextMenu {
style.keystroke.text.clone(), style.keystroke.text.clone(),
) )
.flex_float() .flex_float()
.boxed()
}) })
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_up(MouseButton::Left, |_, _, _| {}) // Capture these events .on_up(MouseButton::Left, |_, _, _| {}) // Capture these events
@ -474,7 +468,7 @@ impl ContextMenu {
cx.dispatch_any_action_at(window_id, view_id, action.boxed_clone()); cx.dispatch_any_action_at(window_id, view_id, action.boxed_clone());
}) })
.on_drag(MouseButton::Left, |_, _, _| {}) .on_drag(MouseButton::Left, |_, _, _| {})
.boxed() .into_element()
} }
ContextMenuItem::Static(f) => f(cx), ContextMenuItem::Static(f) => f(cx),
@ -484,12 +478,11 @@ impl ContextMenu {
.with_height(1.) .with_height(1.)
.contained() .contained()
.with_style(style.separator) .with_style(style.separator)
.boxed(), .into_element(),
} }
})) }))
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_down_out(MouseButton::Left, |_, _, cx| cx.dispatch_action(Cancel)) .on_down_out(MouseButton::Left, |_, _, cx| cx.dispatch_action(Cancel))
.on_down_out(MouseButton::Right, |_, _, cx| cx.dispatch_action(Cancel)) .on_down_out(MouseButton::Right, |_, _, cx| cx.dispatch_action(Cancel))

View file

@ -119,7 +119,7 @@ impl CopilotCodeVerification {
data: &PromptUserDeviceFlow, data: &PromptUserDeviceFlow,
style: &theme::Copilot, style: &theme::Copilot,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) -> Element<Self> { ) -> impl Drawable<Self> {
let copied = cx let copied = cx
.read_from_clipboard() .read_from_clipboard()
.map(|item| item.text() == &data.user_code) .map(|item| item.text() == &data.user_code)
@ -129,14 +129,15 @@ impl CopilotCodeVerification {
MouseEventHandler::<Self, _>::new(0, cx, |state, _cx| { MouseEventHandler::<Self, _>::new(0, cx, |state, _cx| {
Flex::row() Flex::row()
.with_children([ .with_child(
Label::new(data.user_code.clone(), device_code_style.text.clone()) Label::new(data.user_code.clone(), device_code_style.text.clone())
.aligned() .aligned()
.contained() .contained()
.with_style(device_code_style.left_container) .with_style(device_code_style.left_container)
.constrained() .constrained()
.with_width(device_code_style.left) .with_width(device_code_style.left),
.boxed(), )
.with_child(
Label::new( Label::new(
if copied { "Copied!" } else { "Copy" }, if copied { "Copied!" } else { "Copy" },
device_code_style.cta.style_for(state, false).text.clone(), device_code_style.cta.style_for(state, false).text.clone(),
@ -145,12 +146,10 @@ impl CopilotCodeVerification {
.contained() .contained()
.with_style(*device_code_style.right_container.style_for(state, false)) .with_style(*device_code_style.right_container.style_for(state, false))
.constrained() .constrained()
.with_width(device_code_style.right) .with_width(device_code_style.right),
.boxed(), )
])
.contained() .contained()
.with_style(device_code_style.cta.style_for(state, false).container) .with_style(device_code_style.cta.style_for(state, false).container)
.boxed()
}) })
.on_click(gpui::platform::MouseButton::Left, { .on_click(gpui::platform::MouseButton::Left, {
let user_code = data.user_code.clone(); let user_code = data.user_code.clone();
@ -161,7 +160,6 @@ impl CopilotCodeVerification {
} }
}) })
.with_cursor_style(gpui::platform::CursorStyle::PointingHand) .with_cursor_style(gpui::platform::CursorStyle::PointingHand)
.boxed()
} }
fn render_prompting_modal( fn render_prompting_modal(
@ -173,47 +171,44 @@ impl CopilotCodeVerification {
enum ConnectButton {} enum ConnectButton {}
Flex::column() Flex::column()
.with_children([ .with_child(
Flex::column() Flex::column()
.with_children([ .with_children([
Label::new( Label::new(
"Enable Copilot by connecting", "Enable Copilot by connecting",
style.auth.prompting.subheading.text.clone(), style.auth.prompting.subheading.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
Label::new( Label::new(
"your existing license.", "your existing license.",
style.auth.prompting.subheading.text.clone(), style.auth.prompting.subheading.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
]) ])
.align_children_center() .align_children_center()
.contained() .contained()
.with_style(style.auth.prompting.subheading.container) .with_style(style.auth.prompting.subheading.container),
.boxed(), )
Self::render_device_code(data, &style, cx), .with_child(Self::render_device_code(data, &style, cx))
.with_child(
Flex::column() Flex::column()
.with_children([ .with_children([
Label::new( Label::new(
"Paste this code into GitHub after", "Paste this code into GitHub after",
style.auth.prompting.hint.text.clone(), style.auth.prompting.hint.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
Label::new( Label::new(
"clicking the button below.", "clicking the button below.",
style.auth.prompting.hint.text.clone(), style.auth.prompting.hint.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
]) ])
.align_children_center() .align_children_center()
.contained() .contained()
.with_style(style.auth.prompting.hint.container.clone()) .with_style(style.auth.prompting.hint.container.clone()),
.boxed(), )
theme::ui::cta_button_with_click::<ConnectButton, _, _, _>( .with_child(theme::ui::cta_button_with_click::<ConnectButton, _, _, _>(
if connect_clicked { if connect_clicked {
"Waiting for connection..." "Waiting for connection..."
} else { } else {
@ -229,57 +224,52 @@ impl CopilotCodeVerification {
cx.dispatch_action(ClickedConnect) cx.dispatch_action(ClickedConnect)
} }
}, },
) ))
.boxed(),
])
.align_children_center() .align_children_center()
.boxed() .into_element()
} }
fn render_enabled_modal(style: &theme::Copilot, cx: &mut ViewContext<Self>) -> Element<Self> { fn render_enabled_modal(style: &theme::Copilot, cx: &mut ViewContext<Self>) -> Element<Self> {
enum DoneButton {} enum DoneButton {}
let enabled_style = &style.auth.authorized; let enabled_style = &style.auth.authorized;
Flex::column() Flex::column()
.with_children([ .with_child(
Label::new("Copilot Enabled!", enabled_style.subheading.text.clone()) Label::new("Copilot Enabled!", enabled_style.subheading.text.clone())
.contained() .contained()
.with_style(enabled_style.subheading.container) .with_style(enabled_style.subheading.container)
.aligned() .aligned(),
.boxed(), )
.with_child(
Flex::column() Flex::column()
.with_children([ .with_children([
Label::new( Label::new(
"You can update your settings or", "You can update your settings or",
enabled_style.hint.text.clone(), enabled_style.hint.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
Label::new( Label::new(
"sign out from the Copilot menu in", "sign out from the Copilot menu in",
enabled_style.hint.text.clone(), enabled_style.hint.text.clone(),
) )
.aligned() .aligned(),
.boxed(), Label::new("the status bar.", enabled_style.hint.text.clone()).aligned(),
Label::new("the status bar.", enabled_style.hint.text.clone())
.aligned()
.boxed(),
]) ])
.align_children_center() .align_children_center()
.contained() .contained()
.with_style(enabled_style.hint.container) .with_style(enabled_style.hint.container),
.boxed(), )
theme::ui::cta_button_with_click::<DoneButton, _, _, _>( .with_child(theme::ui::cta_button_with_click::<DoneButton, _, _, _>(
"Done", "Done",
style.auth.content_width, style.auth.content_width,
&style.auth.cta_button, &style.auth.cta_button,
cx, cx,
|_, _, cx| cx.remove_window(), |_, _, cx| cx.remove_window(),
) ))
.boxed(),
])
.align_children_center() .align_children_center()
.boxed() .into_element()
} }
fn render_unauthorized_modal( fn render_unauthorized_modal(
style: &theme::Copilot, style: &theme::Copilot,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
@ -287,46 +277,43 @@ impl CopilotCodeVerification {
let unauthorized_style = &style.auth.not_authorized; let unauthorized_style = &style.auth.not_authorized;
Flex::column() Flex::column()
.with_children([ .with_child(
Flex::column() Flex::column()
.with_children([ .with_children([
Label::new( Label::new(
"Enable Copilot by connecting", "Enable Copilot by connecting",
unauthorized_style.subheading.text.clone(), unauthorized_style.subheading.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
Label::new( Label::new(
"your existing license.", "your existing license.",
unauthorized_style.subheading.text.clone(), unauthorized_style.subheading.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
]) ])
.align_children_center() .align_children_center()
.contained() .contained()
.with_style(unauthorized_style.subheading.container) .with_style(unauthorized_style.subheading.container),
.boxed(), )
.with_child(
Flex::column() Flex::column()
.with_children([ .with_children([
Label::new( Label::new(
"You must have an active copilot", "You must have an active copilot",
unauthorized_style.warning.text.clone(), unauthorized_style.warning.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
Label::new( Label::new(
"license to use it in Zed.", "license to use it in Zed.",
unauthorized_style.warning.text.clone(), unauthorized_style.warning.text.clone(),
) )
.aligned() .aligned(),
.boxed(),
]) ])
.align_children_center() .align_children_center()
.contained() .contained()
.with_style(unauthorized_style.warning.container) .with_style(unauthorized_style.warning.container),
.boxed(), )
theme::ui::cta_button_with_click::<CopilotCodeVerification, _, _, _>( .with_child(theme::ui::cta_button_with_click::<Self, _, _, _>(
"Subscribe on GitHub", "Subscribe on GitHub",
style.auth.content_width, style.auth.content_width,
&style.auth.cta_button, &style.auth.cta_button,
@ -335,11 +322,9 @@ impl CopilotCodeVerification {
cx.remove_window(); cx.remove_window();
cx.platform().open_url(COPILOT_SIGN_UP_URL) cx.platform().open_url(COPILOT_SIGN_UP_URL)
}, },
) ))
.boxed(),
])
.align_children_center() .align_children_center()
.boxed() .into_element()
} }
} }
@ -365,10 +350,14 @@ impl View for CopilotCodeVerification {
let style = cx.global::<Settings>().theme.clone(); let style = cx.global::<Settings>().theme.clone();
modal::<ConnectModal, _, _, _>("Connect Copilot to Zed", &style.copilot.modal, cx, |cx| { modal::<ConnectModal, _, _, _, _>(
"Connect Copilot to Zed",
&style.copilot.modal,
cx,
|cx| {
Flex::column() Flex::column()
.with_children([ .with_children([
theme::ui::icon(&style.copilot.auth.header).boxed(), theme::ui::icon(&style.copilot.auth.header).into_element(),
match &self.status { match &self.status {
Status::SigningIn { Status::SigningIn {
prompt: Some(prompt), prompt: Some(prompt),
@ -386,11 +375,12 @@ impl View for CopilotCodeVerification {
self.connect_clicked = false; self.connect_clicked = false;
Self::render_enabled_modal(&style.copilot, cx) Self::render_enabled_modal(&style.copilot, cx)
} }
_ => Empty::new().boxed(), _ => Empty::new().into_element(),
}, },
]) ])
.align_children_center() .align_children_center()
.boxed() },
}) )
.into_element()
} }
} }

View file

@ -159,13 +159,13 @@ impl View for CopilotButton {
let settings = cx.global::<Settings>(); let settings = cx.global::<Settings>();
if !settings.features.copilot { if !settings.features.copilot {
return Empty::new().boxed(); return Empty::new().into_element();
} }
let theme = settings.theme.clone(); let theme = settings.theme.clone();
let active = self.popup_menu.read(cx).visible(); let active = self.popup_menu.read(cx).visible();
let Some(copilot) = Copilot::global(cx) else { let Some(copilot) = Copilot::global(cx) else {
return Empty::new().boxed(); return Empty::new().into_element();
}; };
let status = copilot.read(cx).status(); let status = copilot.read(cx).status();
@ -205,13 +205,12 @@ impl View for CopilotButton {
.constrained() .constrained()
.with_width(style.icon_size) .with_width(style.icon_size)
.aligned() .aligned()
.named("copilot-icon"), .into_named_element("copilot-icon"),
) )
.constrained() .constrained()
.with_height(style.icon_size) .with_height(style.icon_size)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
} }
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -228,17 +227,16 @@ impl View for CopilotButton {
_ => cx.dispatch_action(DeployCopilotStartMenu), _ => cx.dispatch_action(DeployCopilotStartMenu),
} }
}) })
.with_tooltip::<Self>(0, "GitHub Copilot".into(), None, theme.tooltip.clone(), cx) .with_tooltip::<Self>(
.boxed(), 0,
"GitHub Copilot".into(),
None,
theme.tooltip.clone(),
cx,
),
) )
.with_child( .with_child(ChildView::new(&self.popup_menu, cx).aligned().top().right())
ChildView::new(&self.popup_menu, cx) .into_element()
.aligned()
.top()
.right()
.boxed(),
)
.boxed()
} }
} }
@ -322,12 +320,10 @@ impl CopilotButton {
Box::new( Box::new(
move |state: &mut MouseState, style: &theme::ContextMenuItem| { move |state: &mut MouseState, style: &theme::ContextMenuItem| {
Flex::row() Flex::row()
.with_children([ .with_child(Label::new("Copilot Settings", style.label.clone()))
Label::new("Copilot Settings", style.label.clone()).boxed(), .with_child(theme::ui::icon(icon_style.style_for(state, false)))
theme::ui::icon(icon_style.style_for(state, false)).boxed(),
])
.align_children_center() .align_children_center()
.boxed() .into_element()
}, },
), ),
OsOpen::new(COPILOT_SETTINGS_URL), OsOpen::new(COPILOT_SETTINGS_URL),

View file

@ -96,9 +96,9 @@ impl View for ProjectDiagnosticsEditor {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.container) .with_style(theme.container)
.boxed() .into_element()
} else { } else {
ChildView::new(&self.editor, cx).boxed() ChildView::new(&self.editor, cx).into_element()
} }
} }
@ -694,8 +694,7 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
icon.constrained() icon.constrained()
.with_width(icon_width) .with_width(icon_width)
.aligned() .aligned()
.contained() .contained(),
.boxed(),
) )
.with_child( .with_child(
Label::new( Label::new(
@ -706,22 +705,20 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
.contained() .contained()
.with_style(style.message.container) .with_style(style.message.container)
.with_margin_left(cx.gutter_padding) .with_margin_left(cx.gutter_padding)
.aligned() .aligned(),
.boxed(),
) )
.with_children(diagnostic.code.clone().map(|code| { .with_children(diagnostic.code.clone().map(|code| {
Label::new(code, style.code.text.clone().with_font_size(font_size)) Label::new(code, style.code.text.clone().with_font_size(font_size))
.contained() .contained()
.with_style(style.code.container) .with_style(style.code.container)
.aligned() .aligned()
.boxed()
})) }))
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.with_padding_left(cx.gutter_padding) .with_padding_left(cx.gutter_padding)
.with_padding_right(cx.gutter_padding) .with_padding_right(cx.gutter_padding)
.expanded() .expanded()
.named("diagnostic header") .into_named_element("diagnostic header")
}) })
} }
@ -731,21 +728,22 @@ pub(crate) fn render_summary<T: View>(
theme: &theme::ProjectDiagnostics, theme: &theme::ProjectDiagnostics,
) -> Element<T> { ) -> Element<T> {
if summary.error_count == 0 && summary.warning_count == 0 { if summary.error_count == 0 && summary.warning_count == 0 {
Label::new("No problems", text_style.clone()).boxed() Label::new("No problems", text_style.clone()).into_element()
} else { } else {
let icon_width = theme.tab_icon_width; let icon_width = theme.tab_icon_width;
let icon_spacing = theme.tab_icon_spacing; let icon_spacing = theme.tab_icon_spacing;
let summary_spacing = theme.tab_summary_spacing; let summary_spacing = theme.tab_summary_spacing;
Flex::row() Flex::row()
.with_children([ .with_child(
Svg::new("icons/circle_x_mark_12.svg") Svg::new("icons/circle_x_mark_12.svg")
.with_color(text_style.color) .with_color(text_style.color)
.constrained() .constrained()
.with_width(icon_width) .with_width(icon_width)
.aligned() .aligned()
.contained() .contained()
.with_margin_right(icon_spacing) .with_margin_right(icon_spacing),
.named("no-icon"), )
.with_child(
Label::new( Label::new(
summary.error_count.to_string(), summary.error_count.to_string(),
LabelStyle { LabelStyle {
@ -753,8 +751,9 @@ pub(crate) fn render_summary<T: View>(
highlight_text: None, highlight_text: None,
}, },
) )
.aligned() .aligned(),
.boxed(), )
.with_child(
Svg::new("icons/triangle_exclamation_12.svg") Svg::new("icons/triangle_exclamation_12.svg")
.with_color(text_style.color) .with_color(text_style.color)
.constrained() .constrained()
@ -762,8 +761,9 @@ pub(crate) fn render_summary<T: View>(
.aligned() .aligned()
.contained() .contained()
.with_margin_left(summary_spacing) .with_margin_left(summary_spacing)
.with_margin_right(icon_spacing) .with_margin_right(icon_spacing),
.named("warn-icon"), )
.with_child(
Label::new( Label::new(
summary.warning_count.to_string(), summary.warning_count.to_string(),
LabelStyle { LabelStyle {
@ -771,10 +771,9 @@ pub(crate) fn render_summary<T: View>(
highlight_text: None, highlight_text: None,
}, },
) )
.aligned() .aligned(),
.boxed(), )
]) .into_element()
.boxed()
} }
} }

View file

@ -103,23 +103,23 @@ impl View for DiagnosticIndicator {
let mut summary_row = Flex::row(); let mut summary_row = Flex::row();
if self.summary.error_count > 0 { if self.summary.error_count > 0 {
summary_row.add_children([ summary_row.add_child(
Svg::new("icons/circle_x_mark_16.svg") Svg::new("icons/circle_x_mark_16.svg")
.with_color(style.icon_color_error) .with_color(style.icon_color_error)
.constrained() .constrained()
.with_width(style.icon_width) .with_width(style.icon_width)
.aligned() .aligned()
.contained() .contained()
.with_margin_right(style.icon_spacing) .with_margin_right(style.icon_spacing),
.named("error-icon"), );
summary_row.add_child(
Label::new(self.summary.error_count.to_string(), style.text.clone()) Label::new(self.summary.error_count.to_string(), style.text.clone())
.aligned() .aligned(),
.boxed(), );
]);
} }
if self.summary.warning_count > 0 { if self.summary.warning_count > 0 {
summary_row.add_children([ summary_row.add_child(
Svg::new("icons/triangle_exclamation_16.svg") Svg::new("icons/triangle_exclamation_16.svg")
.with_color(style.icon_color_warning) .with_color(style.icon_color_warning)
.constrained() .constrained()
@ -131,12 +131,12 @@ impl View for DiagnosticIndicator {
style.summary_spacing style.summary_spacing
} else { } else {
0. 0.
}) }),
.named("warning-icon"), );
summary_row.add_child(
Label::new(self.summary.warning_count.to_string(), style.text.clone()) Label::new(self.summary.warning_count.to_string(), style.text.clone())
.aligned() .aligned(),
.boxed(), );
]);
} }
if self.summary.error_count == 0 && self.summary.warning_count == 0 { if self.summary.error_count == 0 && self.summary.warning_count == 0 {
@ -146,7 +146,7 @@ impl View for DiagnosticIndicator {
.constrained() .constrained()
.with_width(style.icon_width) .with_width(style.icon_width)
.aligned() .aligned()
.named("ok-icon"), .into_named_element("ok-icon"),
); );
} }
@ -161,7 +161,6 @@ impl View for DiagnosticIndicator {
} else { } else {
style.container_ok style.container_ok
}) })
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
@ -175,7 +174,7 @@ impl View for DiagnosticIndicator {
cx, cx,
) )
.aligned() .aligned()
.boxed(), .into_element(),
); );
let style = &cx.global::<Settings>().theme.workspace.status_bar; let style = &cx.global::<Settings>().theme.workspace.status_bar;
@ -186,8 +185,7 @@ impl View for DiagnosticIndicator {
Label::new("Checking…", style.diagnostic_message.default.text.clone()) Label::new("Checking…", style.diagnostic_message.default.text.clone())
.aligned() .aligned()
.contained() .contained()
.with_margin_left(item_spacing) .with_margin_left(item_spacing),
.boxed(),
); );
} else if let Some(diagnostic) = &self.current_diagnostic { } else if let Some(diagnostic) = &self.current_diagnostic {
let message_style = style.diagnostic_message.clone(); let message_style = style.diagnostic_message.clone();
@ -200,17 +198,15 @@ impl View for DiagnosticIndicator {
.aligned() .aligned()
.contained() .contained()
.with_margin_left(item_spacing) .with_margin_left(item_spacing)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(GoToDiagnostic) cx.dispatch_action(GoToDiagnostic)
}) }),
.boxed(),
); );
} }
element.named("diagnostic indicator") element.into_named_element("diagnostic indicator")
} }
fn debug_json(&self, _: &gpui::AppContext) -> serde_json::Value { fn debug_json(&self, _: &gpui::AppContext) -> serde_json::Value {

View file

@ -227,21 +227,16 @@ impl<V: View> DragAndDrop<V> {
.with_hoverable(false) .with_hoverable(false)
.constrained() .constrained()
.with_width(region.width()) .with_width(region.width())
.with_height(region.height()) .with_height(region.height()),
.boxed(),
) )
.with_anchor_position(position) .with_anchor_position(position)
.boxed(), .into_element(),
) )
} }
State::Canceled => Some( State::Canceled => Some(
MouseEventHandler::<DraggedElementHandler, V>::new(0, cx, |_, _| { MouseEventHandler::<DraggedElementHandler, V>::new(0, cx, |_, _| {
Empty::new() Empty::new().constrained().with_width(0.).with_height(0.)
.constrained()
.with_width(0.)
.with_height(0.)
.boxed()
}) })
.on_up(MouseButton::Left, |_, _, cx| { .on_up(MouseButton::Left, |_, _, cx| {
cx.window_context().defer(|cx| { cx.window_context().defer(|cx| {
@ -257,7 +252,7 @@ impl<V: View> DragAndDrop<V> {
}); });
}); });
}) })
.boxed(), .into_element(),
), ),
} }
}) })

View file

@ -973,7 +973,7 @@ pub mod tests {
position, position,
height, height,
disposition, disposition,
render: Arc::new(|_| Empty::new().boxed()), render: Arc::new(|_| Empty::new().into_element()),
} }
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View file

@ -1045,21 +1045,21 @@ mod tests {
position: buffer_snapshot.anchor_after(Point::new(1, 0)), position: buffer_snapshot.anchor_after(Point::new(1, 0)),
height: 1, height: 1,
disposition: BlockDisposition::Above, disposition: BlockDisposition::Above,
render: Arc::new(|_| Empty::new().named("block 1")), render: Arc::new(|_| Empty::new().into_named_element("block 1")),
}, },
BlockProperties { BlockProperties {
style: BlockStyle::Fixed, style: BlockStyle::Fixed,
position: buffer_snapshot.anchor_after(Point::new(1, 2)), position: buffer_snapshot.anchor_after(Point::new(1, 2)),
height: 2, height: 2,
disposition: BlockDisposition::Above, disposition: BlockDisposition::Above,
render: Arc::new(|_| Empty::new().named("block 2")), render: Arc::new(|_| Empty::new().into_named_element("block 2")),
}, },
BlockProperties { BlockProperties {
style: BlockStyle::Fixed, style: BlockStyle::Fixed,
position: buffer_snapshot.anchor_after(Point::new(3, 3)), position: buffer_snapshot.anchor_after(Point::new(3, 3)),
height: 3, height: 3,
disposition: BlockDisposition::Below, disposition: BlockDisposition::Below,
render: Arc::new(|_| Empty::new().named("block 3")), render: Arc::new(|_| Empty::new().into_named_element("block 3")),
}, },
]); ]);
@ -1219,14 +1219,14 @@ mod tests {
style: BlockStyle::Fixed, style: BlockStyle::Fixed,
position: buffer_snapshot.anchor_after(Point::new(1, 12)), position: buffer_snapshot.anchor_after(Point::new(1, 12)),
disposition: BlockDisposition::Above, disposition: BlockDisposition::Above,
render: Arc::new(|_| Empty::new().named("block 1")), render: Arc::new(|_| Empty::new().into_named_element("block 1")),
height: 1, height: 1,
}, },
BlockProperties { BlockProperties {
style: BlockStyle::Fixed, style: BlockStyle::Fixed,
position: buffer_snapshot.anchor_after(Point::new(1, 1)), position: buffer_snapshot.anchor_after(Point::new(1, 1)),
disposition: BlockDisposition::Below, disposition: BlockDisposition::Below,
render: Arc::new(|_| Empty::new().named("block 2")), render: Arc::new(|_| Empty::new().into_named_element("block 2")),
height: 1, height: 1,
}, },
]); ]);
@ -1329,7 +1329,7 @@ mod tests {
position, position,
height, height,
disposition, disposition,
render: Arc::new(|_| Empty::new().boxed()), render: Arc::new(|_| Empty::new().into_element()),
} }
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View file

@ -819,7 +819,6 @@ impl CompletionsMenu {
)) ))
.contained() .contained()
.with_style(item_style) .with_style(item_style)
.boxed()
}, },
) )
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -828,7 +827,7 @@ impl CompletionsMenu {
item_ix: Some(item_ix), item_ix: Some(item_ix),
}); });
}) })
.boxed(), .into_element(),
); );
} }
}, },
@ -848,7 +847,7 @@ impl CompletionsMenu {
) )
.contained() .contained()
.with_style(container_style) .with_style(container_style)
.boxed() .into_element()
} }
pub async fn filter(&mut self, query: Option<&str>, executor: Arc<executor::Background>) { pub async fn filter(&mut self, query: Option<&str>, executor: Arc<executor::Background>) {
@ -982,7 +981,6 @@ impl CodeActionsMenu {
.with_soft_wrap(false) .with_soft_wrap(false)
.contained() .contained()
.with_style(item_style) .with_style(item_style)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_down(MouseButton::Left, move |_, _, cx| { .on_down(MouseButton::Left, move |_, _, cx| {
@ -990,7 +988,7 @@ impl CodeActionsMenu {
item_ix: Some(item_ix), item_ix: Some(item_ix),
}); });
}) })
.boxed(), .into_element(),
); );
} }
}, },
@ -1004,7 +1002,7 @@ impl CodeActionsMenu {
) )
.contained() .contained()
.with_style(container_style) .with_style(container_style)
.boxed(); .into_element();
if self.deployed_from_indicator { if self.deployed_from_indicator {
*cursor_position.column_mut() = 0; *cursor_position.column_mut() = 0;
@ -3138,7 +3136,6 @@ impl Editor {
MouseEventHandler::<CodeActions, _>::new(0, cx, |state, _| { MouseEventHandler::<CodeActions, _>::new(0, cx, |state, _| {
Svg::new("icons/bolt_8.svg") Svg::new("icons/bolt_8.svg")
.with_color(style.code_actions.indicator.style_for(state, active).color) .with_color(style.code_actions.indicator.style_for(state, active).color)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.with_padding(Padding::uniform(3.)) .with_padding(Padding::uniform(3.))
@ -3147,7 +3144,7 @@ impl Editor {
deployed_from_indicator: true, deployed_from_indicator: true,
}); });
}) })
.boxed(), .into_element(),
) )
} else { } else {
None None
@ -3177,7 +3174,7 @@ impl Editor {
MouseEventHandler::<FoldIndicators, _>::new( MouseEventHandler::<FoldIndicators, _>::new(
ix as usize, ix as usize,
cx, cx,
|mouse_state, _| -> Element<Editor> { |mouse_state, _| {
Svg::new(match fold_status { Svg::new(match fold_status {
FoldStatus::Folded => style.folded_icon.clone(), FoldStatus::Folded => style.folded_icon.clone(),
FoldStatus::Foldable => style.foldable_icon.clone(), FoldStatus::Foldable => style.foldable_icon.clone(),
@ -3198,7 +3195,6 @@ impl Editor {
.with_height(line_height) .with_height(line_height)
.with_width(gutter_margin) .with_width(gutter_margin)
.aligned() .aligned()
.boxed()
}, },
) )
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -3211,7 +3207,7 @@ impl Editor {
}); });
} }
}) })
.boxed() .into_element()
}) })
}) })
.flatten() .flatten()
@ -5893,7 +5889,7 @@ impl Editor {
ChildView::new(&editor, cx) ChildView::new(&editor, cx)
.contained() .contained()
.with_padding_left(cx.anchor_x) .with_padding_left(cx.anchor_x)
.boxed() .into_element()
} }
}), }),
disposition: BlockDisposition::Below, disposition: BlockDisposition::Below,
@ -7022,9 +7018,9 @@ impl View for Editor {
} }
Stack::new() Stack::new()
.with_child(EditorElement::new(style.clone()).boxed()) .with_child(EditorElement::new(style.clone()))
.with_child(ChildView::new(&self.mouse_context_menu, cx).boxed()) .with_child(ChildView::new(&self.mouse_context_menu, cx))
.boxed() .into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -7497,11 +7493,10 @@ pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> Rend
.with_highlights(highlights.clone()) .with_highlights(highlights.clone())
.contained() .contained()
.with_margin_left(cx.anchor_x) .with_margin_left(cx.anchor_x)
.boxed()
})) }))
.aligned() .aligned()
.left() .left()
.boxed() .into_element()
}) })
} }

View file

@ -2299,7 +2299,7 @@ fn test_move_line_up_down_with_blocks(cx: &mut TestAppContext) {
position: snapshot.anchor_after(Point::new(2, 0)), position: snapshot.anchor_after(Point::new(2, 0)),
disposition: BlockDisposition::Below, disposition: BlockDisposition::Below,
height: 1, height: 1,
render: Arc::new(|_| Empty::new().boxed()), render: Arc::new(|_| Empty::new().into_element()),
}], }],
cx, cx,
); );

View file

@ -1447,7 +1447,6 @@ impl EditorElement {
.constrained() .constrained()
.with_width(style.button_width) .with_width(style.button_width)
.with_height(style.button_width) .with_height(style.button_width)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -1462,7 +1461,6 @@ impl EditorElement {
) )
.aligned() .aligned()
.flex_float() .flex_float()
.boxed()
}); });
if *starts_new_buffer { if *starts_new_buffer {
@ -1488,15 +1486,13 @@ impl EditorElement {
) )
.contained() .contained()
.with_style(style.filename.container) .with_style(style.filename.container)
.aligned() .aligned(),
.boxed(),
) )
.with_children(parent_path.map(|path| { .with_children(parent_path.map(|path| {
Label::new(path, style.path.text.clone().with_font_size(font_size)) Label::new(path, style.path.text.clone().with_font_size(font_size))
.contained() .contained()
.with_style(style.path.container) .with_style(style.path.container)
.aligned() .aligned()
.boxed()
})) }))
.with_children(jump_icon) .with_children(jump_icon)
.contained() .contained()
@ -1504,17 +1500,17 @@ impl EditorElement {
.with_padding_left(gutter_padding) .with_padding_left(gutter_padding)
.with_padding_right(gutter_padding) .with_padding_right(gutter_padding)
.expanded() .expanded()
.named("path header block") .into_named_element("path header block")
} else { } else {
let text_style = self.style.text.clone(); let text_style = self.style.text.clone();
Flex::row() Flex::row()
.with_child(Label::new("", text_style).boxed()) .with_child(Label::new("", text_style))
.with_children(jump_icon) .with_children(jump_icon)
.contained() .contained()
.with_padding_left(gutter_padding) .with_padding_left(gutter_padding)
.with_padding_right(gutter_padding) .with_padding_right(gutter_padding)
.expanded() .expanded()
.named("collapsed context") .into_named_element("collapsed context")
} }
} }
}; };
@ -2535,7 +2531,7 @@ mod tests {
disposition: BlockDisposition::Above, disposition: BlockDisposition::Above,
height: 3, height: 3,
position: Anchor::min(), position: Anchor::min(),
render: Arc::new(|_| Empty::new().boxed()), render: Arc::new(|_| Empty::new().into_element()),
}], }],
cx, cx,
); );

View file

@ -344,7 +344,7 @@ impl InfoPopover {
}) })
.collect(), .collect(),
) )
.boxed() .into_element()
} else { } else {
let mut text_style = style.hover_popover.prose.clone(); let mut text_style = style.hover_popover.prose.clone();
text_style.font_size = style.text.font_size; text_style.font_size = style.text.font_size;
@ -353,12 +353,10 @@ impl InfoPopover {
.with_soft_wrap(true) .with_soft_wrap(true)
.contained() .contained()
.with_style(style.hover_popover.block_style) .with_style(style.hover_popover.block_style)
.boxed() .into_element()
} }
})); }));
flex.contained() flex.contained().with_style(style.hover_popover.container)
.with_style(style.hover_popover.container)
.boxed()
}) })
.on_move(|_, _, _| {}) // Consume move events so they don't reach regions underneath. .on_move(|_, _, _| {}) // Consume move events so they don't reach regions underneath.
.with_cursor_style(CursorStyle::Arrow) .with_cursor_style(CursorStyle::Arrow)
@ -367,7 +365,7 @@ impl InfoPopover {
top: HOVER_POPOVER_GAP, top: HOVER_POPOVER_GAP,
..Default::default() ..Default::default()
}) })
.boxed() .into_element()
} }
} }
@ -399,7 +397,6 @@ impl DiagnosticPopover {
.with_soft_wrap(true) .with_soft_wrap(true)
.contained() .contained()
.with_style(container_style) .with_style(container_style)
.boxed()
}) })
.with_padding(Padding { .with_padding(Padding {
top: HOVER_POPOVER_GAP, top: HOVER_POPOVER_GAP,
@ -418,7 +415,7 @@ impl DiagnosticPopover {
tooltip_style, tooltip_style,
cx, cx,
) )
.boxed() .into_element()
} }
pub fn activation_info(&self) -> (usize, Anchor) { pub fn activation_info(&self) -> (usize, Anchor) {

View file

@ -565,11 +565,7 @@ impl Item for Editor {
cx: &AppContext, cx: &AppContext,
) -> Element<T> { ) -> Element<T> {
Flex::row() Flex::row()
.with_child( .with_child(Label::new(self.title(cx).to_string(), style.label.clone()).aligned())
Label::new(self.title(cx).to_string(), style.label.clone())
.aligned()
.boxed(),
)
.with_children(detail.and_then(|detail| { .with_children(detail.and_then(|detail| {
let path = path_for_buffer(&self.buffer, detail, false, cx)?; let path = path_for_buffer(&self.buffer, detail, false, cx)?;
let description = path.to_string_lossy(); let description = path.to_string_lossy();
@ -580,11 +576,10 @@ impl Item for Editor {
) )
.contained() .contained()
.with_style(style.description.container) .with_style(style.description.container)
.aligned() .aligned(),
.boxed(),
) )
})) }))
.boxed() .into_element()
} }
fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) { fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) {
@ -1120,9 +1115,9 @@ impl View for CursorPosition {
if self.selected_count > 0 { if self.selected_count > 0 {
write!(text, " ({} selected)", self.selected_count).unwrap(); write!(text, " ({} selected)", self.selected_count).unwrap();
} }
Label::new(text, theme.cursor_position.clone()).boxed() Label::new(text, theme.cursor_position.clone()).into_element()
} else { } else {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }

View file

@ -50,7 +50,6 @@ impl View for DeployFeedbackButton {
.with_height(style.icon_size) .with_height(style.icon_size)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -64,10 +63,9 @@ impl View for DeployFeedbackButton {
Some(Box::new(GiveFeedback)), Some(Box::new(GiveFeedback)),
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
),
) )
.boxed(), .into_element()
)
.boxed()
} }
} }

View file

@ -231,7 +231,7 @@ impl View for FeedbackEditor {
} }
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
ChildView::new(&self.editor, cx).boxed() ChildView::new(&self.editor, cx).into_element()
} }
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
@ -264,16 +264,14 @@ impl Item for FeedbackEditor {
.with_width(style.type_icon_width) .with_width(style.type_icon_width)
.aligned() .aligned()
.contained() .contained()
.with_margin_right(style.spacing) .with_margin_right(style.spacing),
.boxed(),
) )
.with_child( .with_child(
Label::new("Send Feedback", style.label.clone()) Label::new("Send Feedback", style.label.clone())
.aligned() .aligned()
.contained() .contained(),
.boxed(),
) )
.boxed() .into_element()
} }
fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) { fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) {

View file

@ -39,8 +39,7 @@ impl View for FeedbackInfoText {
theme.feedback.info_text_default.text.clone(), theme.feedback.info_text_default.text.clone(),
) )
.with_soft_wrap(false) .with_soft_wrap(false)
.aligned() .aligned(),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<OpenZedCommunityRepo, Self>::new(0, cx, |state, _| { MouseEventHandler::<OpenZedCommunityRepo, Self>::new(0, cx, |state, _| {
@ -55,24 +54,21 @@ impl View for FeedbackInfoText {
.aligned() .aligned()
.left() .left()
.clipped() .clipped()
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(OpenZedCommunityRepo) cx.dispatch_action(OpenZedCommunityRepo)
}) }),
.boxed(),
) )
.with_child( .with_child(
Text::new(" on GitHub.", theme.feedback.info_text_default.text.clone()) Text::new(" on GitHub.", theme.feedback.info_text_default.text.clone())
.with_soft_wrap(false) .with_soft_wrap(false)
.aligned() .aligned(),
.boxed(),
) )
.aligned() .aligned()
.left() .left()
.clipped() .clipped()
.boxed() .into_element()
} }
} }

View file

@ -37,7 +37,6 @@ impl View for SubmitFeedbackButton {
Label::new("Submit as Markdown", style.text.clone()) Label::new("Submit as Markdown", style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
@ -53,7 +52,7 @@ impl View for SubmitFeedbackButton {
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
) )
.boxed() .into_element()
} }
} }

View file

@ -254,19 +254,15 @@ impl PickerDelegate for FileFinderDelegate {
self.labels_for_match(path_match); self.labels_for_match(path_match);
Flex::column() Flex::column()
.with_child( .with_child(
Label::new(file_name, style.label.clone()) Label::new(file_name, style.label.clone()).with_highlights(file_name_positions),
.with_highlights(file_name_positions)
.boxed(),
) )
.with_child( .with_child(
Label::new(full_path, style.label.clone()) Label::new(full_path, style.label.clone()).with_highlights(full_path_positions),
.with_highlights(full_path_positions)
.boxed(),
) )
.flex(1., false) .flex(1., false)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.named("match") .into_named_element("match")
} }
} }

View file

@ -153,26 +153,22 @@ impl View for GoToLine {
self.max_point.row + 1 self.max_point.row + 1
); );
ConstrainedBox::new(
Container::new(
Flex::new(Axis::Vertical) Flex::new(Axis::Vertical)
.with_child( .with_child(
Container::new(ChildView::new(&self.line_editor, cx).boxed()) ChildView::new(&self.line_editor, cx)
.with_style(theme.input_editor.container) .contained()
.boxed(), .with_style(theme.input_editor.container),
) )
.with_child( .with_child(
Container::new(Label::new(label, theme.no_matches.label.clone()).boxed()) Label::new(label, theme.no_matches.label.clone())
.with_style(theme.no_matches.container) .contained()
.boxed(), .with_style(theme.no_matches.container),
)
.boxed(),
) )
.contained()
.with_style(theme.container) .with_style(theme.container)
.boxed(), .constrained()
)
.with_max_width(500.0) .with_max_width(500.0)
.named("go to line") .into_named_element("go to line")
} }
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {

View file

@ -31,7 +31,7 @@ impl gpui::View for TextView {
} }
fn render(&mut self, _: &mut gpui::ViewContext<Self>) -> Element<TextView> { fn render(&mut self, _: &mut gpui::ViewContext<Self>) -> Element<TextView> {
TextElement.boxed() TextElement.into_element()
} }
} }

View file

@ -4685,7 +4685,7 @@ mod tests {
impl super::View for View { impl super::View for View {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
post_inc(&mut self.render_count); post_inc(&mut self.render_count);
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -4737,7 +4737,7 @@ mod tests {
impl super::View for View { impl super::View for View {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -4809,11 +4809,11 @@ mod tests {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
enum Handler {} enum Handler {}
let mouse_down_count = self.mouse_down_count.clone(); let mouse_down_count = self.mouse_down_count.clone();
MouseEventHandler::<Handler, _>::new(0, cx, |_, _| Empty::new().boxed()) MouseEventHandler::<Handler, _>::new(0, cx, |_, _| Empty::new())
.on_down(MouseButton::Left, move |_, _, _| { .on_down(MouseButton::Left, move |_, _, _| {
mouse_down_count.fetch_add(1, SeqCst); mouse_down_count.fetch_add(1, SeqCst);
}) })
.boxed() .into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -4873,7 +4873,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }
@ -5391,7 +5391,7 @@ mod tests {
impl super::View for View { impl super::View for View {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -5458,7 +5458,7 @@ mod tests {
impl super::View for View { impl super::View for View {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -5639,7 +5639,7 @@ mod tests {
impl View for ViewA { impl View for ViewA {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -5657,7 +5657,7 @@ mod tests {
impl View for ViewB { impl View for ViewB {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -5805,7 +5805,7 @@ mod tests {
impl super::View for View { impl super::View for View {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
@ -5932,7 +5932,7 @@ mod tests {
impl super::View for View1 { impl super::View for View1 {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
"View1" "View1"
@ -5940,7 +5940,7 @@ mod tests {
} }
impl super::View for View2 { impl super::View for View2 {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
"View2" "View2"
@ -6110,7 +6110,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }
@ -6172,7 +6172,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().named(format!("render count: {}", post_inc(&mut self.0))) Empty::new().into_named_element(format!("render count: {}", post_inc(&mut self.0)))
} }
} }
@ -6261,7 +6261,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }
@ -6342,7 +6342,7 @@ mod tests {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
self.rendered.set(true); self.rendered.set(true);
Empty::new().boxed() Empty::new().into_element()
} }
} }
@ -6367,9 +6367,9 @@ mod tests {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
if let Some(child) = self.child.as_ref() { if let Some(child) = self.child.as_ref() {
ChildView::new(child, cx).boxed() ChildView::new(child, cx).into_element()
} else { } else {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }
@ -6408,7 +6408,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }

View file

@ -47,7 +47,7 @@ use std::{
}; };
use util::ResultExt; use util::ResultExt;
pub trait Drawable<V: View> { pub trait Drawable<V: View>: 'static {
type LayoutState; type LayoutState;
type PaintState; type PaintState;
@ -92,7 +92,7 @@ pub trait Drawable<V: View> {
cx: &ViewContext<V>, cx: &ViewContext<V>,
) -> serde_json::Value; ) -> serde_json::Value;
fn boxed(self) -> Element<V> fn into_element(self) -> Element<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
@ -103,17 +103,7 @@ pub trait Drawable<V: View> {
} }
} }
fn into_root(self, cx: &ViewContext<V>) -> RootElement<V> fn into_named_element(self, name: impl Into<Cow<'static, str>>) -> Element<V>
where
Self: 'static + Sized,
{
RootElement {
element: self.boxed(),
view: cx.handle().downgrade(),
}
}
fn named(self, name: impl Into<Cow<'static, str>>) -> Element<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
@ -124,53 +114,63 @@ pub trait Drawable<V: View> {
} }
} }
fn into_root_element(self, cx: &ViewContext<V>) -> RootElement<V>
where
Self: 'static + Sized,
{
RootElement {
element: self.into_element(),
view: cx.handle().downgrade(),
}
}
fn constrained(self) -> ConstrainedBox<V> fn constrained(self) -> ConstrainedBox<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
ConstrainedBox::new(self.boxed()) ConstrainedBox::new(self.into_element())
} }
fn aligned(self) -> Align<V> fn aligned(self) -> Align<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
Align::new(self.boxed()) Align::new(self.into_element())
} }
fn clipped(self) -> Clipped<V> fn clipped(self) -> Clipped<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
Clipped::new(self.boxed()) Clipped::new(self.into_element())
} }
fn contained(self) -> Container<V> fn contained(self) -> Container<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
Container::new(self.boxed()) Container::new(self.into_element())
} }
fn expanded(self) -> Expanded<V> fn expanded(self) -> Expanded<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
Expanded::new(self.boxed()) Expanded::new(self.into_element())
} }
fn flex(self, flex: f32, expanded: bool) -> FlexItem<V> fn flex(self, flex: f32, expanded: bool) -> FlexItem<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
FlexItem::new(self.boxed()).flex(flex, expanded) FlexItem::new(self.into_element()).flex(flex, expanded)
} }
fn flex_float(self) -> FlexItem<V> fn flex_float(self) -> FlexItem<V>
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
FlexItem::new(self.boxed()).float() FlexItem::new(self.into_element()).float()
} }
fn with_tooltip<Tag: 'static>( fn with_tooltip<Tag: 'static>(
@ -184,7 +184,7 @@ pub trait Drawable<V: View> {
where where
Self: 'static + Sized, Self: 'static + Sized,
{ {
Tooltip::new::<Tag, V>(id, text, action, style, self.boxed(), cx) Tooltip::new::<Tag, V>(id, text, action, style, self.into_element(), cx)
} }
fn with_resize_handle<Tag: 'static>( fn with_resize_handle<Tag: 'static>(
@ -199,7 +199,7 @@ pub trait Drawable<V: View> {
Self: 'static + Sized, Self: 'static + Sized,
{ {
Resizable::new::<Tag, V>( Resizable::new::<Tag, V>(
self.boxed(), self.into_element(),
element_id, element_id,
side, side,
handle_size, handle_size,
@ -499,6 +499,64 @@ impl<V: View> Element<V> {
} }
} }
impl<V: View> Drawable<V> for Element<V> {
type LayoutState = ();
type PaintState = ();
fn layout(
&mut self,
constraint: SizeConstraint,
view: &mut V,
cx: &mut ViewContext<V>,
) -> (Vector2F, Self::LayoutState) {
let size = self.layout(constraint, view, cx);
(size, ())
}
fn paint(
&mut self,
scene: &mut SceneBuilder,
bounds: RectF,
visible_bounds: RectF,
_: &mut Self::LayoutState,
view: &mut V,
cx: &mut ViewContext<V>,
) -> Self::PaintState {
self.paint(scene, bounds.origin(), visible_bounds, view, cx);
}
fn rect_for_text_range(
&self,
range_utf16: Range<usize>,
_: RectF,
_: RectF,
_: &Self::LayoutState,
_: &Self::PaintState,
view: &V,
cx: &ViewContext<V>,
) -> Option<RectF> {
self.rect_for_text_range(range_utf16, view, cx)
}
fn debug(
&self,
_: RectF,
_: &Self::LayoutState,
_: &Self::PaintState,
view: &V,
cx: &ViewContext<V>,
) -> serde_json::Value {
self.debug(view, cx)
}
fn into_element(self) -> Element<V>
where
Self: Sized,
{
self
}
}
pub struct RootElement<V: View> { pub struct RootElement<V: View> {
element: Element<V>, element: Element<V>,
view: WeakViewHandle<V>, view: WeakViewHandle<V>,
@ -510,7 +568,7 @@ impl<V: View> RootElement<V> {
} }
} }
pub trait Component<V: View> { pub trait Component<V: View>: 'static {
fn render(&self, view: &mut V, cx: &mut ViewContext<V>) -> Element<V>; fn render(&self, view: &mut V, cx: &mut ViewContext<V>) -> Element<V>;
} }
@ -718,21 +776,22 @@ impl<V: View, R: View> Drawable<V> for RootElement<R> {
} }
pub trait ParentElement<'a, V: View>: Extend<Element<V>> + Sized { pub trait ParentElement<'a, V: View>: Extend<Element<V>> + Sized {
fn add_children(&mut self, children: impl IntoIterator<Item = Element<V>>) { fn add_children<D: Drawable<V>>(&mut self, children: impl IntoIterator<Item = D>) {
self.extend(children); self.extend(children.into_iter().map(|child| child.into_element()));
} }
fn add_child(&mut self, child: Element<V>) { fn add_child<D: Drawable<V>>(&mut self, child: D) {
self.add_children(Some(child)); self.extend(Some(child.into_element()));
} }
fn with_children(mut self, children: impl IntoIterator<Item = Element<V>>) -> Self { fn with_children<D: Drawable<V>>(mut self, children: impl IntoIterator<Item = D>) -> Self {
self.add_children(children); self.extend(children.into_iter().map(|child| child.into_element()));
self self
} }
fn with_child(self, child: Element<V>) -> Self { fn with_child<D: Drawable<V>>(mut self, child: D) -> Self {
self.with_children(Some(child)) self.extend(Some(child.into_element()));
self
} }
} }

View file

@ -25,7 +25,7 @@ where
impl<V: View, F> Drawable<V> for Canvas<V, F> impl<V: View, F> Drawable<V> for Canvas<V, F>
where where
F: FnMut(&mut SceneBuilder, RectF, RectF, &mut V, &mut ViewContext<V>), F: 'static + FnMut(&mut SceneBuilder, RectF, RectF, &mut V, &mut ViewContext<V>),
{ {
type LayoutState = (); type LayoutState = ();
type PaintState = (); type PaintState = ();

View file

@ -28,9 +28,9 @@ impl<V: View> ToJson for Constraint<V> {
} }
impl<V: View> ConstrainedBox<V> { impl<V: View> ConstrainedBox<V> {
pub fn new(child: Element<V>) -> Self { pub fn new(child: impl Drawable<V>) -> Self {
Self { Self {
child, child: child.into_element(),
constraint: Constraint::Static(Default::default()), constraint: Constraint::Static(Default::default()),
} }
} }

View file

@ -13,9 +13,9 @@ pub struct Expanded<V: View> {
} }
impl<V: View> Expanded<V> { impl<V: View> Expanded<V> {
pub fn new(child: Element<V>) -> Self { pub fn new(child: impl Drawable<V>) -> Self {
Self { Self {
child, child: child.into_element(),
full_width: true, full_width: true,
full_height: true, full_height: true,
} }

View file

@ -403,13 +403,13 @@ pub struct FlexItem<V: View> {
} }
impl<V: View> FlexItem<V> { impl<V: View> FlexItem<V> {
pub fn new(child: Element<V>) -> Self { pub fn new(child: impl Drawable<V>) -> Self {
FlexItem { FlexItem {
metadata: FlexParentData { metadata: FlexParentData {
flex: None, flex: None,
float: false, float: false,
}, },
child, child: child.into_element(),
} }
} }

View file

@ -12,9 +12,9 @@ pub struct Hook<V: View> {
} }
impl<V: View> Hook<V> { impl<V: View> Hook<V> {
pub fn new(child: Element<V>) -> Self { pub fn new(child: impl Drawable<V>) -> Self {
Self { Self {
child, child: child.into_element(),
after_layout: None, after_layout: None,
} }
} }

View file

@ -49,11 +49,10 @@ impl<V: View> Drawable<V> for KeystrokeLabel {
Label::new(keystroke.to_string(), self.text_style.clone()) Label::new(keystroke.to_string(), self.text_style.clone())
.contained() .contained()
.with_style(self.container_style) .with_style(self.container_style)
.boxed()
})) }))
.boxed() .into_element()
} else { } else {
Empty::new().collapsed().boxed() Empty::new().collapsed().into_element()
}; };
let size = element.layout(constraint, view, cx); let size = element.layout(constraint, view, cx);

View file

@ -347,21 +347,21 @@ impl<V: View> Drawable<V> for List<V> {
} }
impl<V: View> ListState<V> { impl<V: View> ListState<V> {
pub fn new<F>( pub fn new<D, F>(
element_count: usize, element_count: usize,
orientation: Orientation, orientation: Orientation,
overdraw: f32, overdraw: f32,
render_item: F, mut render_item: F,
) -> Self ) -> Self
where where
V: View, D: Drawable<V>,
F: 'static + FnMut(&mut V, usize, &mut ViewContext<V>) -> Element<V>, F: 'static + FnMut(&mut V, usize, &mut ViewContext<V>) -> D,
{ {
let mut items = SumTree::new(); let mut items = SumTree::new();
items.extend((0..element_count).map(|_| ListItem::Unrendered), &()); items.extend((0..element_count).map(|_| ListItem::Unrendered), &());
Self(Rc::new(RefCell::new(StateInner { Self(Rc::new(RefCell::new(StateInner {
last_layout_width: None, last_layout_width: None,
render_item: Box::new(render_item), render_item: Box::new(move |view, ix, cx| render_item(view, ix, cx).into_element()),
rendered_range: 0..0, rendered_range: 0..0,
items, items,
logical_scroll_top: None, logical_scroll_top: None,
@ -660,7 +660,7 @@ mod tests {
let elements = elements.clone(); let elements = elements.clone();
move |_, ix, _| { move |_, ix, _| {
let (id, height) = elements.borrow()[ix]; let (id, height) = elements.borrow()[ix];
TestElement::new(id, height).boxed() TestElement::new(id, height).into_element()
} }
}); });
@ -765,7 +765,7 @@ mod tests {
let elements = elements.clone(); let elements = elements.clone();
move |_, ix, _| { move |_, ix, _| {
let (id, height) = elements.borrow()[ix]; let (id, height) = elements.borrow()[ix];
TestElement::new(id, height).boxed() TestElement::new(id, height).into_element()
} }
}); });
@ -921,7 +921,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }

View file

@ -32,13 +32,13 @@ pub struct MouseEventHandler<Tag: 'static, V: View> {
/// Element which provides a render_child callback with a MouseState and paints a mouse /// Element which provides a render_child callback with a MouseState and paints a mouse
/// region under (or above) it for easy mouse event handling. /// region under (or above) it for easy mouse event handling.
impl<Tag, V: View> MouseEventHandler<Tag, V> { impl<Tag, V: View> MouseEventHandler<Tag, V> {
pub fn new<F>(region_id: usize, cx: &mut ViewContext<V>, render_child: F) -> Self pub fn new<D, F>(region_id: usize, cx: &mut ViewContext<V>, render_child: F) -> Self
where where
V: View, D: Drawable<V>,
F: FnOnce(&mut MouseState, &mut ViewContext<V>) -> Element<V>, F: FnOnce(&mut MouseState, &mut ViewContext<V>) -> D,
{ {
let mut mouse_state = cx.mouse_state::<Tag>(region_id); let mut mouse_state = cx.mouse_state::<Tag>(region_id);
let child = render_child(&mut mouse_state, cx); let child = render_child(&mut mouse_state, cx).into_element();
let notify_on_hover = mouse_state.accessed_hovered(); let notify_on_hover = mouse_state.accessed_hovered();
let notify_on_click = mouse_state.accessed_clicked(); let notify_on_click = mouse_state.accessed_clicked();
Self { Self {
@ -58,10 +58,10 @@ impl<Tag, V: View> MouseEventHandler<Tag, V> {
/// Modifies the MouseEventHandler to render the MouseRegion above the child element. Useful /// Modifies the MouseEventHandler to render the MouseRegion above the child element. Useful
/// for drag and drop handling and similar events which should be captured before the child /// for drag and drop handling and similar events which should be captured before the child
/// gets the opportunity /// gets the opportunity
pub fn above<F>(region_id: usize, cx: &mut ViewContext<V>, render_child: F) -> Self pub fn above<D, F>(region_id: usize, cx: &mut ViewContext<V>, render_child: F) -> Self
where where
V: View, D: Drawable<V>,
F: FnOnce(&mut MouseState, &mut ViewContext<V>) -> Element<V>, F: FnOnce(&mut MouseState, &mut ViewContext<V>) -> D,
{ {
let mut handler = Self::new(region_id, cx, render_child); let mut handler = Self::new(region_id, cx, render_child);
handler.above = true; handler.above = true;

View file

@ -73,9 +73,9 @@ impl AnchorCorner {
} }
impl<V: View> Overlay<V> { impl<V: View> Overlay<V> {
pub fn new(child: Element<V>) -> Self { pub fn new(child: impl Drawable<V>) -> Self {
Self { Self {
child, child: child.into_element(),
anchor_position: None, anchor_position: None,
anchor_corner: AnchorCorner::TopLeft, anchor_corner: AnchorCorner::TopLeft,
fit_mode: OverlayFitMode::None, fit_mode: OverlayFitMode::None,

View file

@ -108,7 +108,6 @@ impl<V: View> Resizable<V> {
Axis::Horizontal => constrained.with_max_width(state.custom_dimension.get()), Axis::Horizontal => constrained.with_max_width(state.custom_dimension.get()),
Axis::Vertical => constrained.with_max_height(state.custom_dimension.get()), Axis::Vertical => constrained.with_max_height(state.custom_dimension.get()),
} }
.boxed()
}) })
.on_after_layout({ .on_after_layout({
let state = state.clone(); let state = state.clone();
@ -116,7 +115,7 @@ impl<V: View> Resizable<V> {
state.actual_dimension.set(side.relevant_component(size)); state.actual_dimension.set(side.relevant_component(size));
} }
}) })
.boxed(); .into_element();
Self { Self {
side, side,

View file

@ -308,7 +308,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }

View file

@ -71,8 +71,7 @@ impl<V: View> Tooltip<V> {
style.clone(), style.clone(),
action.as_ref().map(|a| a.boxed_clone()), action.as_ref().map(|a| a.boxed_clone()),
true, true,
) );
.boxed();
Some( Some(
Overlay::new( Overlay::new(
Self::render_tooltip(focused_view_id, text, style, action, false) Self::render_tooltip(focused_view_id, text, style, action, false)
@ -80,14 +79,13 @@ impl<V: View> Tooltip<V> {
.dynamically(move |constraint, view, cx| { .dynamically(move |constraint, view, cx| {
SizeConstraint::strict_along( SizeConstraint::strict_along(
Axis::Vertical, Axis::Vertical,
collapsed_tooltip.layout(constraint, view, cx).y(), collapsed_tooltip.layout(constraint, view, cx).0.y(),
) )
}) }),
.boxed(),
) )
.with_fit_mode(OverlayFitMode::SwitchAnchor) .with_fit_mode(OverlayFitMode::SwitchAnchor)
.with_anchor_position(state.position.get()) .with_anchor_position(state.position.get())
.boxed(), .into_element(),
) )
} else { } else {
None None
@ -119,7 +117,7 @@ impl<V: View> Tooltip<V> {
cx.notify(); cx.notify();
} }
}) })
.boxed(); .into_element();
Self { Self {
child, child,
tooltip, tooltip,
@ -145,9 +143,9 @@ impl<V: View> Tooltip<V> {
}; };
if measure { if measure {
text.flex(1., false).boxed() text.flex(1., false).into_element()
} else { } else {
text.flex(1., false).aligned().boxed() text.flex(1., false).aligned().into_element()
} }
}) })
.with_children(action.and_then(|action| { .with_children(action.and_then(|action| {
@ -158,9 +156,9 @@ impl<V: View> Tooltip<V> {
style.keystroke.text, style.keystroke.text,
); );
if measure { if measure {
Some(keystroke_label.boxed()) Some(keystroke_label.into_element())
} else { } else {
Some(keystroke_label.aligned().boxed()) Some(keystroke_label.aligned().into_element())
} }
})) }))
.contained() .contained()

View file

@ -243,6 +243,6 @@ impl View for EmptyView {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Drawable::boxed(Empty::new()) Empty::new().into_element()
} }
} }

View file

@ -94,7 +94,7 @@ impl View for Select {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
if self.item_count == 0 { if self.item_count == 0 {
return Empty::new().boxed(); return Empty::new().into_element();
} }
enum Header {} enum Header {}
@ -107,26 +107,22 @@ impl View for Select {
}; };
let mut result = Flex::column().with_child( let mut result = Flex::column().with_child(
MouseEventHandler::<Header, _>::new(self.handle.id(), cx, |mouse_state, cx| { MouseEventHandler::<Header, _>::new(self.handle.id(), cx, |mouse_state, cx| {
Container::new((self.render_item)( (self.render_item)(
self.selected_item_ix, self.selected_item_ix,
ItemType::Header, ItemType::Header,
mouse_state.hovered(), mouse_state.hovered(),
cx, cx,
)) )
.contained()
.with_style(style.header) .with_style(style.header)
.boxed()
}) })
.on_click( .on_click(
MouseButton::Left, MouseButton::Left,
move |_, _, cx: &mut EventContext<Self>| cx.dispatch_action(ToggleSelect), move |_, _, cx: &mut EventContext<Self>| cx.dispatch_action(ToggleSelect),
) ),
.boxed(),
); );
if self.is_open { if self.is_open {
result.add_child( result.add_child(Overlay::new(
Overlay::new(
Container::new(
ConstrainedBox::new(
UniformList::new( UniformList::new(
self.list_state.clone(), self.list_state.clone(),
self.item_count, self.item_count,
@ -135,10 +131,7 @@ impl View for Select {
let selected_item_ix = this.selected_item_ix; let selected_item_ix = this.selected_item_ix;
range.end = range.end.min(this.item_count); range.end = range.end.min(this.item_count);
items.extend(range.map(|ix| { items.extend(range.map(|ix| {
MouseEventHandler::<Item, _>::new( MouseEventHandler::<Item, _>::new(ix, cx, |mouse_state, cx| {
ix,
cx,
|mouse_state, cx| {
(this.render_item)( (this.render_item)(
ix, ix,
if ix == selected_item_ix { if ix == selected_item_ix {
@ -149,29 +142,23 @@ impl View for Select {
mouse_state.hovered(), mouse_state.hovered(),
cx, cx,
) )
}, })
)
.on_click( .on_click(
MouseButton::Left, MouseButton::Left,
move |_, _, cx: &mut EventContext<Self>| { move |_, _, cx: &mut EventContext<Self>| {
cx.dispatch_action(SelectItem(ix)) cx.dispatch_action(SelectItem(ix))
}, },
) )
.boxed() .into_element()
})) }))
}, },
) )
.boxed(), .constrained()
)
.with_max_height(200.) .with_max_height(200.)
.boxed(), .contained()
) .with_style(style.menu),
.with_style(style.menu) ));
.boxed(),
)
.boxed(),
)
} }
result.boxed() result.into_element()
} }
} }

View file

@ -64,15 +64,14 @@ impl View for ActiveBufferLanguage {
Label::new(active_language_text, style.text.clone()) Label::new(active_language_text, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| { .on_click(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(crate::Toggle) cx.dispatch_action(crate::Toggle)
}) })
.boxed() .into_element()
} else { } else {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }

View file

@ -197,6 +197,6 @@ impl PickerDelegate for LanguageSelectorDelegate {
.with_highlights(mat.positions.clone()) .with_highlights(mat.positions.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .into_element()
} }
} }

View file

@ -220,6 +220,6 @@ impl PickerDelegate for OutlineViewDelegate {
.with_padding_left(20. * outline_item.depth as f32) .with_padding_left(20. * outline_item.depth as f32)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .into_element()
} }
} }

View file

@ -75,8 +75,7 @@ impl<D: PickerDelegate> View for Picker<D> {
.with_child( .with_child(
ChildView::new(&self.query_editor, cx) ChildView::new(&self.query_editor, cx)
.contained() .contained()
.with_style(editor_style) .with_style(editor_style),
.boxed(),
) )
.with_children(if match_count == 0 { .with_children(if match_count == 0 {
if query.is_empty() { if query.is_empty() {
@ -86,7 +85,7 @@ impl<D: PickerDelegate> View for Picker<D> {
Label::new("No matches", theme.no_matches.label.clone()) Label::new("No matches", theme.no_matches.label.clone())
.contained() .contained()
.with_style(theme.no_matches.container) .with_style(theme.no_matches.container)
.boxed(), .into_element(),
) )
} }
} else { } else {
@ -109,14 +108,14 @@ impl<D: PickerDelegate> View for Picker<D> {
cx.dispatch_action(SelectIndex(ix)) cx.dispatch_action(SelectIndex(ix))
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.boxed() .into_element()
})); }));
}, },
) )
.contained() .contained()
.with_margin_top(6.0) .with_margin_top(6.0)
.flex(1., false) .flex(1., false)
.boxed(), .into_element(),
) )
}) })
.contained() .contained()
@ -124,7 +123,7 @@ impl<D: PickerDelegate> View for Picker<D> {
.constrained() .constrained()
.with_max_width(self.max_size.x()) .with_max_width(self.max_size.x())
.with_max_height(self.max_size.y()) .with_max_height(self.max_size.y())
.named("picker") .into_named_element("picker")
} }
fn keymap_context(&self, _: &AppContext) -> KeymapContext { fn keymap_context(&self, _: &AppContext) -> KeymapContext {

View file

@ -6,8 +6,8 @@ use gpui::{
actions, actions,
anyhow::{anyhow, Result}, anyhow::{anyhow, Result},
elements::{ elements::{
AnchorCorner, ChildView, ConstrainedBox, ContainerStyle, Empty, Flex, Label, AnchorCorner, ChildView, ContainerStyle, Empty, Flex, Label, MouseEventHandler,
MouseEventHandler, ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState, ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState,
}, },
geometry::vector::Vector2F, geometry::vector::Vector2F,
impl_internal_actions, impl_internal_actions,
@ -1104,25 +1104,21 @@ impl ProjectPanel {
Flex::row() Flex::row()
.with_child( .with_child(
ConstrainedBox::new(if kind == EntryKind::Dir { if kind == EntryKind::Dir {
if details.is_expanded { if details.is_expanded {
Svg::new("icons/chevron_down_8.svg") Svg::new("icons/chevron_down_8.svg").with_color(style.icon_color)
.with_color(style.icon_color)
.boxed()
} else { } else {
Svg::new("icons/chevron_right_8.svg") Svg::new("icons/chevron_right_8.svg").with_color(style.icon_color)
.with_color(style.icon_color)
.boxed()
} }
.constrained()
} else { } else {
Empty::new().boxed() Empty::new().constrained()
}) }
.with_max_width(style.icon_size) .with_max_width(style.icon_size)
.with_max_height(style.icon_size) .with_max_height(style.icon_size)
.aligned() .aligned()
.constrained() .constrained()
.with_width(style.icon_size) .with_width(style.icon_size),
.boxed(),
) )
.with_child(if show_editor && editor.is_some() { .with_child(if show_editor && editor.is_some() {
ChildView::new(editor.as_ref().unwrap(), cx) ChildView::new(editor.as_ref().unwrap(), cx)
@ -1131,21 +1127,21 @@ impl ProjectPanel {
.aligned() .aligned()
.left() .left()
.flex(1.0, true) .flex(1.0, true)
.boxed() .into_element()
} else { } else {
Label::new(details.filename.clone(), style.text.clone()) Label::new(details.filename.clone(), style.text.clone())
.contained() .contained()
.with_margin_left(style.icon_spacing) .with_margin_left(style.icon_spacing)
.aligned() .aligned()
.left() .left()
.boxed() .into_element()
}) })
.constrained() .constrained()
.with_height(style.height) .with_height(style.height)
.contained() .contained()
.with_style(row_container_style) .with_style(row_container_style)
.with_padding_left(padding) .with_padding_left(padding)
.boxed() .into_named_element("project panel entry visual element")
} }
fn render_entry( fn render_entry(
@ -1259,7 +1255,7 @@ impl ProjectPanel {
} }
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.boxed() .into_named_element("project panel entry")
} }
} }
@ -1310,7 +1306,6 @@ impl View for ProjectPanel {
.contained() .contained()
.with_style(container_style) .with_style(container_style)
.expanded() .expanded()
.boxed()
}) })
.on_down(MouseButton::Right, move |e, _, cx| { .on_down(MouseButton::Right, move |e, _, cx| {
// When deploying the context menu anywhere below the last project entry, // When deploying the context menu anywhere below the last project entry,
@ -1321,11 +1316,10 @@ impl View for ProjectPanel {
position: e.position, position: e.position,
}) })
} }
}) }),
.boxed(),
) )
.with_child(ChildView::new(&self.context_menu, cx).boxed()) .with_child(ChildView::new(&self.context_menu, cx))
.boxed() .into_named_element("project panel")
} else { } else {
Flex::column() Flex::column()
.with_child( .with_child(
@ -1345,18 +1339,16 @@ impl View for ProjectPanel {
Box::new(workspace::Open), Box::new(workspace::Open),
cx, cx,
) )
.boxed()
} }
}) })
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(workspace::Open) cx.dispatch_action(workspace::Open)
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand),
.boxed(),
) )
.contained() .contained()
.with_style(container_style) .with_style(container_style)
.boxed() .into_named_element("empty project panel")
} }
} }

View file

@ -231,17 +231,16 @@ impl PickerDelegate for ProjectSymbolsDelegate {
current_style.label.text.clone().into(), current_style.label.text.clone().into(),
syntax_runs, syntax_runs,
&string_match.positions, &string_match.positions,
)) )),
.boxed(),
) )
.with_child( .with_child(
// Avoid styling the path differently when it is selected, since // Avoid styling the path differently when it is selected, since
// the symbol's syntax highlighting doesn't change when selected. // the symbol's syntax highlighting doesn't change when selected.
Label::new(path.to_string(), style.default.label.clone()).boxed(), Label::new(path.to_string(), style.default.label.clone()),
) )
.contained() .contained()
.with_style(current_style.container) .with_style(current_style.container)
.boxed() .into_element()
} }
} }

View file

@ -45,7 +45,7 @@ impl HighlightedText {
pub fn render<V: View>(self, style: impl Into<LabelStyle>) -> Element<V> { pub fn render<V: View>(self, style: impl Into<LabelStyle>) -> Element<V> {
Label::new(self.text, style) Label::new(self.text, style)
.with_highlights(self.highlight_positions) .with_highlights(self.highlight_positions)
.boxed() .into_element()
} }
} }

View file

@ -177,6 +177,6 @@ impl PickerDelegate for RecentProjectsDelegate {
.flex(1., false) .flex(1., false)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.named("match") .into_named_element("match")
} }
} }

View file

@ -114,8 +114,7 @@ impl View for BufferSearchBar {
ChildView::new(&self.query_editor, cx) ChildView::new(&self.query_editor, cx)
.aligned() .aligned()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_children(self.active_searchable_item.as_ref().and_then( .with_children(self.active_searchable_item.as_ref().and_then(
|searchable_item| { |searchable_item| {
@ -132,8 +131,7 @@ impl View for BufferSearchBar {
Label::new(message, theme.search.match_index.text.clone()) Label::new(message, theme.search.match_index.text.clone())
.contained() .contained()
.with_style(theme.search.match_index.container) .with_style(theme.search.match_index.container)
.aligned() .aligned(),
.boxed(),
) )
}, },
)) ))
@ -143,15 +141,13 @@ impl View for BufferSearchBar {
.constrained() .constrained()
.with_min_width(theme.search.editor.min_width) .with_min_width(theme.search.editor.min_width)
.with_max_width(theme.search.editor.max_width) .with_max_width(theme.search.editor.max_width)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.with_child( .with_child(
Flex::row() Flex::row()
.with_child(self.render_nav_button("<", Direction::Prev, cx)) .with_child(self.render_nav_button("<", Direction::Prev, cx))
.with_child(self.render_nav_button(">", Direction::Next, cx)) .with_child(self.render_nav_button(">", Direction::Next, cx))
.aligned() .aligned(),
.boxed(),
) )
.with_child( .with_child(
Flex::row() Flex::row()
@ -175,16 +171,14 @@ impl View for BufferSearchBar {
)) ))
.contained() .contained()
.with_style(theme.search.option_button_group) .with_style(theme.search.option_button_group)
.aligned() .aligned(),
.boxed(),
) )
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child(self.render_close_button(&theme.search, cx)) .with_child(self.render_close_button(&theme.search, cx))
.contained() .contained()
.with_style(theme.search.container) .with_style(theme.search.container)
.named("search bar") .into_named_element("search bar")
} }
} }
@ -343,7 +337,6 @@ impl BufferSearchBar {
Label::new(icon, style.text.clone()) Label::new(icon, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_any_action(option.to_toggle_action()) cx.dispatch_any_action(option.to_toggle_action())
@ -356,7 +349,7 @@ impl BufferSearchBar {
tooltip_style, tooltip_style,
cx, cx,
) )
.boxed(), .into_element(),
) )
} }
@ -391,7 +384,6 @@ impl BufferSearchBar {
Label::new(icon, style.text.clone()) Label::new(icon, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_click(MouseButton::Left, { .on_click(MouseButton::Left, {
let action = action.boxed_clone(); let action = action.boxed_clone();
@ -405,7 +397,7 @@ impl BufferSearchBar {
tooltip_style, tooltip_style,
cx, cx,
) )
.boxed() .into_element()
} }
fn render_close_button( fn render_close_button(
@ -429,7 +421,6 @@ impl BufferSearchBar {
.with_width(style.button_width) .with_width(style.button_width)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_click(MouseButton::Left, { .on_click(MouseButton::Left, {
let action = action.boxed_clone(); let action = action.boxed_clone();
@ -437,7 +428,7 @@ impl BufferSearchBar {
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.with_tooltip::<CloseButton>(0, tooltip.to_string(), Some(action), tooltip_style, cx) .with_tooltip::<CloseButton>(0, tooltip.to_string(), Some(action), tooltip_style, cx)
.boxed() .into_element()
} }
fn deploy(pane: &mut Pane, action: &Deploy, cx: &mut ViewContext<Pane>) { fn deploy(pane: &mut Pane, action: &Deploy, cx: &mut ViewContext<Pane>) {

View file

@ -197,16 +197,15 @@ impl View for ProjectSearchView {
.contained() .contained()
.with_background_color(theme.editor.background) .with_background_color(theme.editor.background)
.flex(1., true) .flex(1., true)
.boxed()
}) })
.on_down(MouseButton::Left, |_, _, cx| { .on_down(MouseButton::Left, |_, _, cx| {
cx.focus_parent_view(); cx.focus_parent_view();
}) })
.boxed() .into_named_element("project search view")
} else { } else {
ChildView::new(&self.results_editor, cx) ChildView::new(&self.results_editor, cx)
.flex(1., true) .flex(1., true)
.boxed() .into_named_element("project search view")
} }
} }
@ -263,17 +262,14 @@ impl Item for ProjectSearchView {
.with_width(tab_theme.type_icon_width) .with_width(tab_theme.type_icon_width)
.aligned() .aligned()
.contained() .contained()
.with_margin_right(tab_theme.spacing) .with_margin_right(tab_theme.spacing),
.boxed(),
) )
.with_children(self.model.read(cx).active_query.as_ref().map(|query| { .with_children(self.model.read(cx).active_query.as_ref().map(|query| {
let query_text = util::truncate_and_trailoff(query.as_str(), MAX_TAB_TITLE_LEN); let query_text = util::truncate_and_trailoff(query.as_str(), MAX_TAB_TITLE_LEN);
Label::new(query_text, tab_theme.label.clone()) Label::new(query_text, tab_theme.label.clone()).aligned()
.aligned()
.boxed()
})) }))
.boxed() .into_element()
} }
fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) { fn for_each_project_item(&self, cx: &AppContext, f: &mut dyn FnMut(usize, &dyn project::Item)) {
@ -778,7 +774,6 @@ impl ProjectSearchBar {
Label::new(icon, style.text.clone()) Label::new(icon, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_click(MouseButton::Left, { .on_click(MouseButton::Left, {
let action = action.boxed_clone(); let action = action.boxed_clone();
@ -792,7 +787,7 @@ impl ProjectSearchBar {
tooltip_style, tooltip_style,
cx, cx,
) )
.boxed() .into_element()
} }
fn render_option_button( fn render_option_button(
@ -813,7 +808,6 @@ impl ProjectSearchBar {
Label::new(icon, style.text.clone()) Label::new(icon, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_any_action(option.to_toggle_action()) cx.dispatch_any_action(option.to_toggle_action())
@ -826,7 +820,7 @@ impl ProjectSearchBar {
tooltip_style, tooltip_style,
cx, cx,
) )
.boxed() .into_element()
} }
fn is_option_enabled(&self, option: SearchOption, cx: &AppContext) -> bool { fn is_option_enabled(&self, option: SearchOption, cx: &AppContext) -> bool {
@ -868,8 +862,7 @@ impl View for ProjectSearchBar {
ChildView::new(&search.query_editor, cx) ChildView::new(&search.query_editor, cx)
.aligned() .aligned()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_children(search.active_match_index.map(|match_ix| { .with_children(search.active_match_index.map(|match_ix| {
Label::new( Label::new(
@ -883,7 +876,6 @@ impl View for ProjectSearchBar {
.contained() .contained()
.with_style(theme.search.match_index.container) .with_style(theme.search.match_index.container)
.aligned() .aligned()
.boxed()
})) }))
.contained() .contained()
.with_style(editor_container) .with_style(editor_container)
@ -891,15 +883,13 @@ impl View for ProjectSearchBar {
.constrained() .constrained()
.with_min_width(theme.search.editor.min_width) .with_min_width(theme.search.editor.min_width)
.with_max_width(theme.search.editor.max_width) .with_max_width(theme.search.editor.max_width)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.with_child( .with_child(
Flex::row() Flex::row()
.with_child(self.render_nav_button("<", Direction::Prev, cx)) .with_child(self.render_nav_button("<", Direction::Prev, cx))
.with_child(self.render_nav_button(">", Direction::Next, cx)) .with_child(self.render_nav_button(">", Direction::Next, cx))
.aligned() .aligned(),
.boxed(),
) )
.with_child( .with_child(
Flex::row() Flex::row()
@ -912,16 +902,15 @@ impl View for ProjectSearchBar {
.with_child(self.render_option_button("Regex", SearchOption::Regex, cx)) .with_child(self.render_option_button("Regex", SearchOption::Regex, cx))
.contained() .contained()
.with_style(theme.search.option_button_group) .with_style(theme.search.option_button_group)
.aligned() .aligned(),
.boxed(),
) )
.contained() .contained()
.with_style(theme.search.container) .with_style(theme.search.container)
.aligned() .aligned()
.left() .left()
.named("project search") .into_named_element("project search")
} else { } else {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }

View file

@ -95,7 +95,7 @@ mod tests {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }

View file

@ -46,7 +46,7 @@ impl View for TerminalButton {
let workspace = self.workspace.upgrade(cx); let workspace = self.workspace.upgrade(cx);
let project = match workspace { let project = match workspace {
Some(workspace) => workspace.read(cx).project().read(cx), Some(workspace) => workspace.read(cx).project().read(cx),
None => return Empty::new().boxed(), None => return Empty::new().into_element(),
}; };
let focused_view = cx.focused_view_id(); let focused_view = cx.focused_view_id();
@ -79,20 +79,18 @@ impl View for TerminalButton {
.constrained() .constrained()
.with_width(style.icon_size) .with_width(style.icon_size)
.aligned() .aligned()
.named("terminals-icon"), .into_named_element("terminals-icon"),
) )
.with_children(has_terminals.then(|| { .with_children(has_terminals.then(|| {
Label::new(terminal_count.to_string(), style.label.text.clone()) Label::new(terminal_count.to_string(), style.label.text.clone())
.contained() .contained()
.with_style(style.label.container) .with_style(style.label.container)
.aligned() .aligned()
.boxed()
})) }))
.constrained() .constrained()
.with_height(style.icon_size) .with_height(style.icon_size)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
} }
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -111,17 +109,10 @@ impl View for TerminalButton {
Some(Box::new(FocusDock)), Some(Box::new(FocusDock)),
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
),
) )
.boxed(), .with_child(ChildView::new(&self.popup_menu, cx).aligned().top().right())
) .into_named_element("terminal button")
.with_child(
ChildView::new(&self.popup_menu, cx)
.aligned()
.top()
.right()
.boxed(),
)
.boxed()
} }
} }

View file

@ -600,11 +600,10 @@ impl Drawable<TerminalView> for TerminalElement {
.constrained() .constrained()
.with_width(dimensions.width()) .with_width(dimensions.width())
.with_height(dimensions.height()) .with_height(dimensions.height())
.with_tooltip::<TerminalElement>(id, uri, None, tooltip_style, cx) .with_tooltip::<TerminalElement>(id, uri, None, tooltip_style, cx),
.boxed(),
) )
.with_position_mode(gpui::elements::OverlayPositionMode::Local) .with_position_mode(gpui::elements::OverlayPositionMode::Local)
.boxed(); .into_element();
tooltip.layout( tooltip.layout(
SizeConstraint::new(Vector2F::zero(), cx.window_size()), SizeConstraint::new(Vector2F::zero(), cx.window_size()),

View file

@ -403,11 +403,10 @@ impl View for TerminalView {
focused, focused,
self.should_show_cursor(focused, cx), self.should_show_cursor(focused, cx),
) )
.contained() .contained(),
.boxed(),
) )
.with_child(ChildView::new(&self.context_menu, cx).boxed()) .with_child(ChildView::new(&self.context_menu, cx))
.boxed() .into_element()
} }
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
@ -561,11 +560,10 @@ impl Item for TerminalView {
.with_width(tab_theme.type_icon_width) .with_width(tab_theme.type_icon_width)
.aligned() .aligned()
.contained() .contained()
.with_margin_right(tab_theme.spacing) .with_margin_right(tab_theme.spacing),
.boxed(),
) )
.with_child(Label::new(title, tab_theme.label.clone()).aligned().boxed()) .with_child(Label::new(title, tab_theme.label.clone()).aligned())
.boxed() .into_element()
} }
fn clone_on_split( fn clone_on_split(

View file

@ -11,7 +11,7 @@ use gpui::{
platform, platform,
platform::MouseButton, platform::MouseButton,
scene::MouseClick, scene::MouseClick,
Action, Drawable, Element, EventContext, MouseState, View, ViewContext, Action, Drawable, EventContext, MouseState, View, ViewContext,
}; };
use serde::Deserialize; use serde::Deserialize;
@ -36,14 +36,13 @@ pub fn checkbox<Tag: 'static, V: View>(
) -> MouseEventHandler<Tag, V> { ) -> MouseEventHandler<Tag, V> {
let label = Label::new(label, style.label.text.clone()) let label = Label::new(label, style.label.text.clone())
.contained() .contained()
.with_style(style.label.container) .with_style(style.label.container);
.boxed();
checkbox_with_label(label, style, checked, cx, change) checkbox_with_label(label, style, checked, cx, change)
} }
pub fn checkbox_with_label<Tag: 'static, V: View>( pub fn checkbox_with_label<Tag: 'static, D: Drawable<V>, V: View>(
label: Element<V>, label: D,
style: &CheckboxStyle, style: &CheckboxStyle,
checked: bool, checked: bool,
cx: &mut ViewContext<V>, cx: &mut ViewContext<V>,
@ -60,10 +59,7 @@ pub fn checkbox_with_label<Tag: 'static, V: View>(
}; };
Flex::row() Flex::row()
.with_children([ .with_child(indicator.contained().with_style(if checked {
indicator
.contained()
.with_style(if checked {
if state.hovered() { if state.hovered() {
style.hovered_and_checked style.hovered_and_checked
} else { } else {
@ -75,12 +71,9 @@ pub fn checkbox_with_label<Tag: 'static, V: View>(
} else { } else {
style.default style.default
} }
}) }))
.boxed(), .with_child(label)
label,
])
.align_children_center() .align_children_center()
.boxed()
}) })
.on_click(platform::MouseButton::Left, move |_, _, cx| { .on_click(platform::MouseButton::Left, move |_, _, cx| {
change(!checked, cx) change(!checked, cx)
@ -151,21 +144,16 @@ pub fn keystroke_label_for<V: View>(
action: Box<dyn Action>, action: Box<dyn Action>,
) -> Container<V> { ) -> Container<V> {
Flex::row() Flex::row()
.with_child(Label::new(label_text, label_style.text.clone()).contained())
.with_child( .with_child(
Label::new(label_text, label_style.text.clone())
.contained()
.boxed(),
)
.with_child({
KeystrokeLabel::new( KeystrokeLabel::new(
view_id, view_id,
action, action,
keystroke_style.container, keystroke_style.container,
keystroke_style.text.clone(), keystroke_style.text.clone(),
) )
.flex_float() .flex_float(),
.boxed() )
})
.contained() .contained()
.with_style(label_style.container) .with_style(label_style.container)
} }
@ -178,7 +166,7 @@ pub fn cta_button<L, A, V>(
max_width: f32, max_width: f32,
style: &ButtonStyle, style: &ButtonStyle,
cx: &mut ViewContext<V>, cx: &mut ViewContext<V>,
) -> Element<V> ) -> MouseEventHandler<A, V>
where where
L: Into<Cow<'static, str>>, L: Into<Cow<'static, str>>,
A: 'static + Action + Clone, A: 'static + Action + Clone,
@ -187,7 +175,6 @@ where
cta_button_with_click::<A, _, _, _>(label, max_width, style, cx, move |_, _, cx| { cta_button_with_click::<A, _, _, _>(label, max_width, style, cx, move |_, _, cx| {
cx.dispatch_action(action.clone()) cx.dispatch_action(action.clone())
}) })
.boxed()
} }
pub fn cta_button_with_click<Tag, L, V, F>( pub fn cta_button_with_click<Tag, L, V, F>(
@ -211,7 +198,6 @@ where
.with_style(style.container) .with_style(style.container)
.constrained() .constrained()
.with_max_width(max_width) .with_max_width(max_width)
.boxed()
}) })
.on_click(MouseButton::Left, f) .on_click(MouseButton::Left, f)
.with_cursor_style(platform::CursorStyle::PointingHand) .with_cursor_style(platform::CursorStyle::PointingHand)
@ -232,17 +218,18 @@ impl ModalStyle {
} }
} }
pub fn modal<Tag, V, I, F>( pub fn modal<Tag, V, I, D, F>(
title: I, title: I,
style: &ModalStyle, style: &ModalStyle,
cx: &mut ViewContext<V>, cx: &mut ViewContext<V>,
build_modal: F, build_modal: F,
) -> Element<V> ) -> impl Drawable<V>
where where
Tag: 'static, Tag: 'static,
V: View, V: View,
I: Into<Cow<'static, str>>, I: Into<Cow<'static, str>>,
F: FnOnce(&mut gpui::ViewContext<V>) -> Element<V>, D: Drawable<V>,
F: FnOnce(&mut gpui::ViewContext<V>) -> D,
{ {
const TITLEBAR_HEIGHT: f32 = 28.; const TITLEBAR_HEIGHT: f32 = 28.;
// let active = cx.window_is_active(cx.window_id()); // let active = cx.window_is_active(cx.window_id());
@ -250,43 +237,39 @@ where
Flex::column() Flex::column()
.with_child( .with_child(
Stack::new() Stack::new()
.with_children([ .with_child(Label::new(
Label::new(
title, title,
style style
.title_text .title_text
.style_for(&mut MouseState::default(), false) .style_for(&mut MouseState::default(), false)
.clone(), .clone(),
) ))
.boxed(), .with_child(
// FIXME: Get a better tag type // FIXME: Get a better tag type
MouseEventHandler::<Tag, V>::new(999999, cx, |state, _cx| { MouseEventHandler::<Tag, V>::new(999999, cx, |state, _cx| {
let style = style.close_icon.style_for(state, false); let style = style.close_icon.style_for(state, false);
icon(style).boxed() icon(style)
}) })
.on_click(platform::MouseButton::Left, move |_, _, cx| { .on_click(platform::MouseButton::Left, move |_, _, cx| {
cx.remove_window(); cx.remove_window();
}) })
.with_cursor_style(platform::CursorStyle::PointingHand) .with_cursor_style(platform::CursorStyle::PointingHand)
.aligned() .aligned()
.right() .right(),
.boxed(), )
])
.contained() .contained()
.with_style(style.titlebar) .with_style(style.titlebar)
.constrained() .constrained()
.with_height(TITLEBAR_HEIGHT) .with_height(TITLEBAR_HEIGHT),
.boxed(),
) )
.with_child( .with_child(
Container::new(build_modal(cx)) build_modal(cx)
.contained()
.with_style(style.container) .with_style(style.container)
.constrained() .constrained()
.with_width(style.dimensions().x()) .with_width(style.dimensions().x())
.with_height(style.dimensions().y() - TITLEBAR_HEIGHT) .with_height(style.dimensions().y() - TITLEBAR_HEIGHT),
.boxed(),
) )
.constrained() .constrained()
.with_height(style.dimensions().y()) .with_height(style.dimensions().y())
.boxed()
} }

View file

@ -217,6 +217,6 @@ impl PickerDelegate for ThemeSelectorDelegate {
.with_highlights(theme_match.positions.clone()) .with_highlights(theme_match.positions.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .into_element()
} }
} }

View file

@ -46,10 +46,9 @@ impl ThemeTestbench {
}); });
}) })
.flex(1.0, false) .flex(1.0, false)
.boxed()
})) }))
.flex(1.0, false) .flex(1.0, false)
.boxed() .into_element()
} }
Flex::column() Flex::column()
@ -71,39 +70,30 @@ impl ThemeTestbench {
) -> Container<Self> { ) -> Container<Self> {
Flex::column() Flex::column()
.with_child( .with_child(
Self::render_button_set(0, layer_index, "base", &layer.base, cx) Self::render_button_set(0, layer_index, "base", &layer.base, cx).flex(1., false),
.flex(1., false)
.boxed(),
) )
.with_child( .with_child(
Self::render_button_set(1, layer_index, "variant", &layer.variant, cx) Self::render_button_set(1, layer_index, "variant", &layer.variant, cx)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.with_child( .with_child(
Self::render_button_set(2, layer_index, "on", &layer.on, cx) Self::render_button_set(2, layer_index, "on", &layer.on, cx).flex(1., false),
.flex(1., false)
.boxed(),
) )
.with_child( .with_child(
Self::render_button_set(3, layer_index, "accent", &layer.accent, cx) Self::render_button_set(3, layer_index, "accent", &layer.accent, cx)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.with_child( .with_child(
Self::render_button_set(4, layer_index, "positive", &layer.positive, cx) Self::render_button_set(4, layer_index, "positive", &layer.positive, cx)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.with_child( .with_child(
Self::render_button_set(5, layer_index, "warning", &layer.warning, cx) Self::render_button_set(5, layer_index, "warning", &layer.warning, cx)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.with_child( .with_child(
Self::render_button_set(6, layer_index, "negative", &layer.negative, cx) Self::render_button_set(6, layer_index, "negative", &layer.negative, cx)
.flex(1., false) .flex(1., false),
.boxed(),
) )
.contained() .contained()
.with_style(ContainerStyle { .with_style(ContainerStyle {
@ -224,10 +214,9 @@ impl ThemeTestbench {
corner_radius: 2., corner_radius: 2.,
..Default::default() ..Default::default()
}) })
.boxed()
}) })
.flex(1., true) .flex(1., true)
.boxed() .into_element()
} }
fn render_label(text: String, style: &Style, cx: &mut ViewContext<Self>) -> Label { fn render_label(text: String, style: &Style, cx: &mut ViewContext<Self>) -> Label {
@ -270,30 +259,16 @@ impl View for ThemeTestbench {
Self::render_ramps(color_scheme) Self::render_ramps(color_scheme)
.contained() .contained()
.with_margin_right(10.) .with_margin_right(10.)
.flex(0.1, false) .flex(0.1, false),
.boxed(),
) )
.with_child( .with_child(
Flex::column() Flex::column()
.with_child( .with_child(Self::render_layer(100, &color_scheme.lowest, cx).flex(1., true))
Self::render_layer(100, &color_scheme.lowest, cx) .with_child(Self::render_layer(200, &color_scheme.middle, cx).flex(1., true))
.flex(1., true) .with_child(Self::render_layer(300, &color_scheme.highest, cx).flex(1., true))
.boxed(), .flex(1., false),
) )
.with_child( .into_element()
Self::render_layer(200, &color_scheme.middle, cx)
.flex(1., true)
.boxed(),
)
.with_child(
Self::render_layer(300, &color_scheme.highest, cx)
.flex(1., true)
.boxed(),
)
.flex(1., false)
.boxed(),
)
.boxed()
} }
} }
@ -307,7 +282,7 @@ impl Item for ThemeTestbench {
Label::new("Theme Testbench", style.label.clone()) Label::new("Theme Testbench", style.label.clone())
.aligned() .aligned()
.contained() .contained()
.boxed() .into_element()
} }
fn serialized_item_kind() -> Option<&'static str> { fn serialized_item_kind() -> Option<&'static str> {

View file

@ -143,6 +143,6 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
.with_highlights(keymap_match.positions.clone()) .with_highlights(keymap_match.positions.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .into_element()
} }
} }

View file

@ -73,78 +73,77 @@ impl View for WelcomePage {
PaneBackdrop::new( PaneBackdrop::new(
self_handle.id(), self_handle.id(),
Flex::column() Flex::column()
.with_children([ .with_child(
Flex::column() Flex::column()
.with_children([ .with_child(
theme::ui::svg(&theme.welcome.logo) theme::ui::svg(&theme.welcome.logo)
.aligned() .aligned()
.contained() .contained()
.aligned() .aligned(),
.boxed(), )
.with_child(
Label::new( Label::new(
"Code at the speed of thought", "Code at the speed of thought",
theme.welcome.logo_subheading.text.clone(), theme.welcome.logo_subheading.text.clone(),
) )
.aligned() .aligned()
.contained() .contained()
.with_style(theme.welcome.logo_subheading.container) .with_style(theme.welcome.logo_subheading.container),
.boxed(), )
])
.contained() .contained()
.with_style(theme.welcome.heading_group) .with_style(theme.welcome.heading_group)
.constrained() .constrained()
.with_width(width) .with_width(width),
.boxed(), )
.with_child(
Flex::column() Flex::column()
.with_children([ .with_child(theme::ui::cta_button(
theme::ui::cta_button(
"Choose a theme", "Choose a theme",
theme_selector::Toggle, theme_selector::Toggle,
width, width,
&theme.welcome.button, &theme.welcome.button,
cx, cx,
), ))
theme::ui::cta_button( .with_child(theme::ui::cta_button(
"Choose a keymap", "Choose a keymap",
ToggleBaseKeymapSelector, ToggleBaseKeymapSelector,
width, width,
&theme.welcome.button, &theme.welcome.button,
cx, cx,
), ))
theme::ui::cta_button( .with_child(theme::ui::cta_button(
"Install the CLI", "Install the CLI",
install_cli::Install, install_cli::Install,
width, width,
&theme.welcome.button, &theme.welcome.button,
cx, cx,
), ))
])
.contained() .contained()
.with_style(theme.welcome.button_group) .with_style(theme.welcome.button_group)
.constrained() .constrained()
.with_width(width) .with_width(width),
.boxed(), )
.with_child(
Flex::column() Flex::column()
.with_children([ .with_child(
theme::ui::checkbox_with_label::<Metrics, Self>( theme::ui::checkbox_with_label::<Metrics, _, Self>(
Flex::column() Flex::column()
.with_children([ .with_child(
Label::new( Label::new(
"Send anonymous usage data", "Send anonymous usage data",
theme.welcome.checkbox.label.text.clone(), theme.welcome.checkbox.label.text.clone(),
) )
.contained() .contained()
.with_style(theme.welcome.checkbox.label.container) .with_style(theme.welcome.checkbox.label.container),
.boxed(), )
.with_child(
Label::new( Label::new(
"Help > View Telemetry", "Help > View Telemetry",
theme.welcome.usage_note.text.clone(), theme.welcome.usage_note.text.clone(),
) )
.contained() .contained()
.with_style(theme.welcome.usage_note.container) .with_style(theme.welcome.usage_note.container),
.boxed(), ),
])
.boxed(),
&theme.welcome.checkbox, &theme.welcome.checkbox,
metrics, metrics,
cx, cx,
@ -155,8 +154,9 @@ impl View for WelcomePage {
}, },
) )
.contained() .contained()
.with_style(theme.welcome.checkbox_container) .with_style(theme.welcome.checkbox_container),
.boxed(), )
.with_child(
theme::ui::checkbox::<Diagnostics, Self>( theme::ui::checkbox::<Diagnostics, Self>(
"Send crash reports", "Send crash reports",
&theme.welcome.checkbox, &theme.welcome.checkbox,
@ -169,23 +169,21 @@ impl View for WelcomePage {
}, },
) )
.contained() .contained()
.with_style(theme.welcome.checkbox_container) .with_style(theme.welcome.checkbox_container),
.boxed(), )
])
.contained() .contained()
.with_style(theme.welcome.checkbox_group) .with_style(theme.welcome.checkbox_group)
.constrained() .constrained()
.with_width(width) .with_width(width),
.boxed(), )
])
.constrained() .constrained()
.with_max_width(width) .with_max_width(width)
.contained() .contained()
.with_uniform_padding(10.) .with_uniform_padding(10.)
.aligned() .aligned()
.boxed(), .into_element(),
) )
.boxed() .into_named_element("welcome page")
} }
} }
@ -212,10 +210,9 @@ impl Item for WelcomePage {
.with_child( .with_child(
Label::new("Welcome to Zed!", style.label.clone()) Label::new("Welcome to Zed!", style.label.clone())
.aligned() .aligned()
.contained() .contained(),
.boxed(),
) )
.boxed() .into_element()
} }
fn show_toolbar(&self) -> bool { fn show_toolbar(&self) -> bool {

View file

@ -5,7 +5,7 @@ use serde::Deserialize;
use collections::HashMap; use collections::HashMap;
use gpui::{ use gpui::{
actions, actions,
elements::{ChildView, Container, Empty, MouseEventHandler, ParentElement, Side, Stack}, elements::{ChildView, Empty, MouseEventHandler, ParentElement, Side, Stack},
geometry::vector::Vector2F, geometry::vector::Vector2F,
impl_internal_actions, impl_internal_actions,
platform::{CursorStyle, MouseButton}, platform::{CursorStyle, MouseButton},
@ -348,7 +348,8 @@ impl Dock {
enum DockResizeHandle {} enum DockResizeHandle {}
let resizable = Container::new(ChildView::new(&self.pane, cx).boxed()) let resizable = ChildView::new(&self.pane, cx)
.contained()
.with_style(panel_style) .with_style(panel_style)
.with_resize_handle::<DockResizeHandle>( .with_resize_handle::<DockResizeHandle>(
resize_side as usize, resize_side as usize,
@ -367,26 +368,21 @@ impl Dock {
}); });
if anchor == DockAnchor::Right { if anchor == DockAnchor::Right {
resizable resizable.constrained().dynamically(|constraint, _, cx| {
.constrained()
.dynamically(|constraint, _, cx| {
SizeConstraint::new( SizeConstraint::new(
Vector2F::new(20., constraint.min.y()), Vector2F::new(20., constraint.min.y()),
Vector2F::new(cx.window_size().x() * 0.8, constraint.max.y()), Vector2F::new(cx.window_size().x() * 0.8, constraint.max.y()),
) )
}) })
.boxed()
} else { } else {
resizable resizable.constrained().dynamically(|constraint, _, cx| {
.constrained()
.dynamically(|constraint, _, cx| {
SizeConstraint::new( SizeConstraint::new(
Vector2F::new(constraint.min.x(), 50.), Vector2F::new(constraint.min.x(), 50.),
Vector2F::new(constraint.max.x(), cx.window_size().y() * 0.8), Vector2F::new(constraint.max.x(), cx.window_size().y() * 0.8),
) )
}) })
.boxed()
} }
.into_element()
} }
DockAnchor::Expanded => { DockAnchor::Expanded => {
enum ExpandedDockWash {} enum ExpandedDockWash {}
@ -398,27 +394,24 @@ impl Dock {
Empty::new() Empty::new()
.contained() .contained()
.with_background_color(style.wash_color) .with_background_color(style.wash_color)
.boxed()
}) })
.capture_all() .capture_all()
.on_down(MouseButton::Left, |_, _, cx| { .on_down(MouseButton::Left, |_, _, cx| {
cx.dispatch_action(HideDock); cx.dispatch_action(HideDock);
}) })
.with_cursor_style(CursorStyle::Arrow) .with_cursor_style(CursorStyle::Arrow),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<ExpandedDockPane, _>::new(0, cx, |_state, cx| { MouseEventHandler::<ExpandedDockPane, _>::new(0, cx, |_state, cx| {
ChildView::new(&self.pane, cx).boxed() ChildView::new(&self.pane, cx)
}) })
// Make sure all events directly under the dock pane // Make sure all events directly under the dock pane
// are captured // are captured
.capture_all() .capture_all()
.contained() .contained()
.with_style(style.maximized) .with_style(style.maximized),
.boxed(),
) )
.boxed() .into_element()
} }
}) })
} }

View file

@ -38,7 +38,7 @@ impl View for ToggleDockButton {
let workspace = self.workspace.upgrade(cx); let workspace = self.workspace.upgrade(cx);
if workspace.is_none() { if workspace.is_none() {
return Empty::new().boxed(); return Empty::new().into_element();
} }
let workspace = workspace.unwrap(); let workspace = workspace.unwrap();
@ -64,7 +64,6 @@ impl View for ToggleDockButton {
.with_height(style.icon_size) .with_height(style.icon_size)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
} }
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -98,7 +97,7 @@ impl View for ToggleDockButton {
cx, cx,
) )
} }
.boxed() .into_element()
} }
} }

View file

@ -930,7 +930,7 @@ pub(crate) mod test {
} }
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed() Empty::new().into_element()
} }
} }
@ -949,7 +949,7 @@ pub(crate) mod test {
_: &AppContext, _: &AppContext,
) -> Element<V> { ) -> Element<V> {
self.tab_detail.set(detail); self.tab_detail.set(detail);
Empty::new().boxed() Empty::new().into_element()
} }
fn for_each_project_item( fn for_each_project_item(

View file

@ -255,8 +255,7 @@ pub mod simple_message_notification {
.aligned() .aligned()
.top() .top()
.left() .left()
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_child( .with_child(
MouseEventHandler::<Cancel, _>::new(0, cx, |state, _| { MouseEventHandler::<Cancel, _>::new(0, cx, |state, _| {
@ -271,7 +270,6 @@ pub mod simple_message_notification {
.constrained() .constrained()
.with_width(style.button_width) .with_width(style.button_width)
.with_height(style.button_width) .with_height(style.button_width)
.boxed()
}) })
.with_padding(Padding::uniform(5.)) .with_padding(Padding::uniform(5.))
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -285,23 +283,18 @@ pub mod simple_message_notification {
) )
.aligned() .aligned()
.top() .top()
.flex_float() .flex_float(),
.boxed(), ),
)
.boxed(),
) )
.with_children({ .with_children({
let style = theme.action_message.style_for(state, false); let style = theme.action_message.style_for(state, false);
if let Some(click_message) = click_message { if let Some(click_message) = click_message {
Some( Some(
Flex::row() Flex::row().with_child(
.with_child(
Text::new(click_message, style.text.clone()) Text::new(click_message, style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container),
.boxed(), ),
)
.boxed(),
) )
} else { } else {
None None
@ -309,7 +302,6 @@ pub mod simple_message_notification {
.into_iter() .into_iter()
}) })
.contained() .contained()
.boxed()
}) })
// Since we're not using a proper overlay, we have to capture these extra events // Since we're not using a proper overlay, we have to capture these extra events
.on_down(MouseButton::Left, |_, _, _| {}) .on_down(MouseButton::Left, |_, _, _| {})
@ -325,7 +317,7 @@ pub mod simple_message_notification {
} else { } else {
CursorStyle::Arrow CursorStyle::Arrow
}) })
.boxed() .into_element()
} }
} }

View file

@ -1383,7 +1383,7 @@ impl Pane {
row.add_child({ row.add_child({
enum TabDragReceiver {} enum TabDragReceiver {}
let mut receiver = let mut receiver =
dragged_item_receiver::<TabDragReceiver, _>(ix, ix, true, None, cx, { dragged_item_receiver::<TabDragReceiver, _, _>(ix, ix, true, None, cx, {
let item = item.clone(); let item = item.clone();
let pane = pane.clone(); let pane = pane.clone();
let detail = detail.clone(); let detail = detail.clone();
@ -1437,7 +1437,7 @@ impl Pane {
); );
if let Some(tab_tooltip_text) = tab_tooltip_text { if let Some(tab_tooltip_text) = tab_tooltip_text {
return mouse_event_handler mouse_event_handler
.with_tooltip::<Self>( .with_tooltip::<Self>(
ix, ix,
tab_tooltip_text, tab_tooltip_text,
@ -1445,10 +1445,10 @@ impl Pane {
tooltip_theme, tooltip_theme,
cx, cx,
) )
.boxed(); .into_element()
} else {
mouse_event_handler.into_element()
} }
mouse_event_handler.boxed()
} }
}); });
@ -1456,8 +1456,7 @@ impl Pane {
receiver = receiver.with_cursor_style(CursorStyle::PointingHand); receiver = receiver.with_cursor_style(CursorStyle::PointingHand);
} }
receiver receiver.as_draggable(
.as_draggable(
DraggedItem { DraggedItem {
item, item,
pane: pane.clone(), pane: pane.clone(),
@ -1480,7 +1479,6 @@ impl Pane {
} }
}, },
) )
.boxed()
}) })
} }
@ -1490,15 +1488,14 @@ impl Pane {
let filler_style = theme.workspace.tab_bar.tab_style(pane_active, false); let filler_style = theme.workspace.tab_bar.tab_style(pane_active, false);
enum Filler {} enum Filler {}
row.add_child( row.add_child(
dragged_item_receiver::<Filler, _>(0, filler_index, true, None, cx, |_, _| { dragged_item_receiver::<Filler, _, _>(0, filler_index, true, None, cx, |_, _| {
Empty::new() Empty::new()
.contained() .contained()
.with_style(filler_style.container) .with_style(filler_style.container)
.with_border(filler_style.container.border) .with_border(filler_style.container.border)
.boxed()
}) })
.flex(1., true) .flex(1., true)
.named("filler"), .into_named_element("filler"),
); );
row row
@ -1582,8 +1579,7 @@ impl Pane {
} }
Flex::row() Flex::row()
.with_child( .with_child({
Align::new({
let diameter = 7.0; let diameter = 7.0;
let icon_color = if item.has_conflict(cx) { let icon_color = if item.has_conflict(cx) {
Some(tab_style.icon_conflict) Some(tab_style.icon_conflict)
@ -1593,7 +1589,6 @@ impl Pane {
None None
}; };
ConstrainedBox::new(
Canvas::new(move |scene, bounds, _, _, _| { Canvas::new(move |scene, bounds, _, _, _| {
if let Some(color) = icon_color { if let Some(color) = icon_color {
let square = RectF::new(bounds.origin(), vec2f(diameter, diameter)); let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
@ -1605,43 +1600,31 @@ impl Pane {
}); });
} }
}) })
.boxed(), .constrained()
)
.with_width(diameter) .with_width(diameter)
.with_height(diameter) .with_height(diameter)
.boxed() .aligned()
}) })
.boxed(), .with_child(title.aligned().contained().with_style(ContainerStyle {
)
.with_child(
Container::new(Align::new(title).boxed())
.with_style(ContainerStyle {
margin: Margin { margin: Margin {
left: tab_style.spacing, left: tab_style.spacing,
right: tab_style.spacing, right: tab_style.spacing,
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
}) }))
.boxed(),
)
.with_child( .with_child(
Align::new( if hovered {
ConstrainedBox::new(if hovered {
let item_id = item.id(); let item_id = item.id();
enum TabCloseButton {} enum TabCloseButton {}
let icon = Svg::new("icons/x_mark_8.svg"); let icon = Svg::new("icons/x_mark_8.svg");
MouseEventHandler::<TabCloseButton, _>::new( MouseEventHandler::<TabCloseButton, _>::new(item_id, cx, |mouse_state, _| {
item_id,
cx,
|mouse_state, _| {
if mouse_state.hovered() { if mouse_state.hovered() {
icon.with_color(tab_style.icon_close_active).boxed() icon.with_color(tab_style.icon_close_active)
} else { } else {
icon.with_color(tab_style.icon_close).boxed() icon.with_color(tab_style.icon_close)
} }
}, })
)
.with_padding(Padding::uniform(4.)) .with_padding(Padding::uniform(4.))
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, { .on_click(MouseButton::Left, {
@ -1653,20 +1636,19 @@ impl Pane {
}) })
} }
}) })
.named("close-tab-icon") .into_named_element("close-tab-icon")
.constrained()
} else { } else {
Empty::new().boxed() Empty::new().constrained()
}) }
.with_width(tab_style.close_icon_width) .with_width(tab_style.close_icon_width)
.boxed(), .aligned(),
)
.boxed(),
) )
.contained() .contained()
.with_style(container) .with_style(container)
.constrained() .constrained()
.with_height(tab_style.height) .with_height(tab_style.height)
.boxed() .into_element()
} }
fn render_tab_bar_buttons( fn render_tab_bar_buttons(
@ -1719,7 +1701,7 @@ impl Pane {
.contained() .contained()
.with_style(theme.workspace.tab_bar.pane_button_container) .with_style(theme.workspace.tab_bar.pane_button_container)
.flex(1., false) .flex(1., false)
.boxed() .into_element()
} }
fn render_blank_pane(&mut self, theme: &Theme, _cx: &mut ViewContext<Self>) -> Element<Self> { fn render_blank_pane(&mut self, theme: &Theme, _cx: &mut ViewContext<Self>) -> Element<Self> {
@ -1727,7 +1709,7 @@ impl Pane {
Empty::new() Empty::new()
.contained() .contained()
.with_background_color(background) .with_background_color(background)
.boxed() .into_element()
} }
} }
@ -1743,8 +1725,6 @@ impl View for Pane {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
enum MouseNavigationHandler {} enum MouseNavigationHandler {}
Stack::new()
.with_child(
MouseEventHandler::<MouseNavigationHandler, _>::new(0, cx, |_, cx| { MouseEventHandler::<MouseNavigationHandler, _>::new(0, cx, |_, cx| {
let active_item_index = self.active_item_index; let active_item_index = self.active_item_index;
@ -1757,39 +1737,39 @@ impl View for Pane {
enum TabBarEventHandler {} enum TabBarEventHandler {}
stack.add_child( stack.add_child(
MouseEventHandler::<TabBarEventHandler, _>::new( MouseEventHandler::<TabBarEventHandler, _>::new(0, cx, |_, _| {
0,
cx,
|_, _| {
Empty::new() Empty::new()
.contained() .contained()
.with_style(theme.workspace.tab_bar.container) .with_style(theme.workspace.tab_bar.container)
.boxed()
},
)
.on_down(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(ActivateItem(active_item_index));
}) })
.boxed(), .on_down(
MouseButton::Left,
move |_, _, cx| {
cx.dispatch_action(ActivateItem(active_item_index));
},
),
); );
let mut tab_row = Flex::row() let mut tab_row = Flex::row().with_child(
.with_child(self.render_tabs(cx).flex(1., true).named("tabs")); self.render_tabs(cx)
.flex(1., true)
.into_named_element("tabs"),
);
if self.is_active { if self.is_active {
tab_row.add_child(self.render_tab_bar_buttons(&theme, cx)) tab_row.add_child(self.render_tab_bar_buttons(&theme, cx))
} }
stack.add_child(tab_row.boxed()); stack.add_child(tab_row);
stack stack
.constrained() .constrained()
.with_height(theme.workspace.tab_bar.height) .with_height(theme.workspace.tab_bar.height)
.flex(1., false) .flex(1., false)
.named("tab bar") .into_named_element("tab bar")
}) })
.with_child({ .with_child({
enum PaneContentTabDropTarget {} enum PaneContentTabDropTarget {}
dragged_item_receiver::<PaneContentTabDropTarget, _>( dragged_item_receiver::<PaneContentTabDropTarget, _, _>(
0, 0,
self.active_item_index + 1, self.active_item_index + 1,
false, false,
@ -1804,34 +1784,31 @@ impl View for Pane {
let toolbar_hidden = toolbar.read(cx).hidden(); let toolbar_hidden = toolbar.read(cx).hidden();
move |_, cx| { move |_, cx| {
Flex::column() Flex::column()
.with_children((!toolbar_hidden).then(|| { .with_children(
ChildView::new(&toolbar, cx).expanded().boxed() (!toolbar_hidden)
})) .then(|| ChildView::new(&toolbar, cx).expanded()),
.with_child( )
ChildView::new(active_item.as_any(), cx) .with_child(
.flex(1., true) ChildView::new(active_item.as_any(), cx).flex(1., true),
.boxed(),
) )
.boxed()
} }
}, },
) )
.flex(1., true) .flex(1., true)
.boxed()
}) })
.with_child(ChildView::new(&self.tab_context_menu, cx).boxed()) .with_child(ChildView::new(&self.tab_context_menu, cx))
.boxed() .into_element()
} else { } else {
enum EmptyPane {} enum EmptyPane {}
let theme = cx.global::<Settings>().theme.clone(); let theme = cx.global::<Settings>().theme.clone();
dragged_item_receiver::<EmptyPane, _>(0, 0, false, None, cx, |_, cx| { dragged_item_receiver::<EmptyPane, _, _>(0, 0, false, None, cx, |_, cx| {
self.render_blank_pane(&theme, cx) self.render_blank_pane(&theme, cx)
}) })
.on_down(MouseButton::Left, |_, _, cx| { .on_down(MouseButton::Left, |_, _, cx| {
cx.focus_parent_view(); cx.focus_parent_view();
}) })
.boxed() .into_element()
} }
}) })
.on_down( .on_down(
@ -1847,9 +1824,7 @@ impl View for Pane {
cx.dispatch_action(GoForward { pane: Some(pane) }) cx.dispatch_action(GoForward { pane: Some(pane) })
} }
}) })
.boxed(), .into_named_element("pane")
)
.named("pane")
} }
fn focus_in(&mut self, focused: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, focused: AnyViewHandle, cx: &mut ViewContext<Self>) {
@ -1917,19 +1892,17 @@ fn render_tab_bar_button<A: Action + Clone>(
.constrained() .constrained()
.with_width(style.button_width) .with_width(style.button_width)
.with_height(style.button_width) .with_height(style.button_width)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
cx.dispatch_action(action.clone()); cx.dispatch_action(action.clone());
}) }),
.boxed(),
) )
.with_children( .with_children(
context_menu.map(|menu| ChildView::new(&menu, cx).aligned().bottom().right().boxed()), context_menu.map(|menu| ChildView::new(&menu, cx).aligned().bottom().right()),
) )
.flex(1., false) .flex(1., false)
.boxed() .into_named_element("tab bar button")
} }
impl ItemNavHistory { impl ItemNavHistory {

View file

@ -5,8 +5,7 @@ use gpui::{
geometry::{rect::RectF, vector::Vector2F}, geometry::{rect::RectF, vector::Vector2F},
platform::MouseButton, platform::MouseButton,
scene::MouseUp, scene::MouseUp,
AppContext, Drawable, Element, EventContext, MouseState, Quad, View, ViewContext, AppContext, Drawable, EventContext, MouseState, Quad, View, ViewContext, WeakViewHandle,
WeakViewHandle,
}; };
use project::ProjectEntryId; use project::ProjectEntryId;
use settings::Settings; use settings::Settings;
@ -18,7 +17,7 @@ use crate::{
use super::DraggedItem; use super::DraggedItem;
pub fn dragged_item_receiver<Tag, F>( pub fn dragged_item_receiver<Tag, D, F>(
region_id: usize, region_id: usize,
drop_index: usize, drop_index: usize,
allow_same_pane: bool, allow_same_pane: bool,
@ -28,7 +27,8 @@ pub fn dragged_item_receiver<Tag, F>(
) -> MouseEventHandler<Tag, Pane> ) -> MouseEventHandler<Tag, Pane>
where where
Tag: 'static, Tag: 'static,
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> Element<Pane>, D: Drawable<Pane>,
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> D,
{ {
MouseEventHandler::<Tag, _>::above(region_id, cx, |state, cx| { MouseEventHandler::<Tag, _>::above(region_id, cx, |state, cx| {
// Observing hovered will cause a render when the mouse enters regardless // Observing hovered will cause a render when the mouse enters regardless
@ -69,9 +69,7 @@ where
}); });
} }
}) })
.boxed()
})) }))
.boxed()
}) })
.on_up(MouseButton::Left, { .on_up(MouseButton::Left, {
move |event, _, cx| { move |event, _, cx| {

View file

@ -165,7 +165,7 @@ impl Member {
Border::default() Border::default()
}; };
let prompt = if let Some((_, leader)) = leader { let leader_status_box = if let Some((_, leader)) = leader {
match leader.location { match leader.location {
ParticipantLocation::SharedProject { ParticipantLocation::SharedProject {
project_id: leader_project_id, project_id: leader_project_id,
@ -195,7 +195,6 @@ impl Member {
.with_style( .with_style(
theme.workspace.external_location_message.container, theme.workspace.external_location_message.container,
) )
.boxed()
}, },
) )
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
@ -208,7 +207,7 @@ impl Member {
.aligned() .aligned()
.bottom() .bottom()
.right() .right()
.boxed(), .into_element(),
) )
} }
} }
@ -225,7 +224,7 @@ impl Member {
.aligned() .aligned()
.bottom() .bottom()
.right() .right()
.boxed(), .into_element(),
), ),
ParticipantLocation::External => Some( ParticipantLocation::External => Some(
Label::new( Label::new(
@ -240,7 +239,7 @@ impl Member {
.aligned() .aligned()
.bottom() .bottom()
.right() .right()
.boxed(), .into_element(),
), ),
} }
} else { } else {
@ -248,14 +247,9 @@ impl Member {
}; };
Stack::new() Stack::new()
.with_child( .with_child(ChildView::new(pane, cx).contained().with_border(border))
ChildView::new(pane, cx) .with_children(leader_status_box)
.contained() .into_element()
.with_border(border)
.boxed(),
)
.with_children(prompt)
.boxed()
} }
Member::Axis(axis) => axis.render( Member::Axis(axis) => axis.render(
project, project,
@ -388,12 +382,12 @@ impl PaneAxis {
Axis::Vertical => border.bottom = true, Axis::Vertical => border.bottom = true,
Axis::Horizontal => border.right = true, Axis::Horizontal => border.right = true,
} }
member = Container::new(member).with_border(border).boxed(); member = member.contained().with_border(border).into_element();
} }
FlexItem::new(member).flex(flex, true).boxed() FlexItem::new(member).flex(flex, true)
})) }))
.boxed() .into_element()
} }
} }

View file

@ -89,10 +89,9 @@ impl View for SharedScreen {
}) })
.contained() .contained()
.with_style(cx.global::<Settings>().theme.shared_screen) .with_style(cx.global::<Settings>().theme.shared_screen)
.boxed()
}) })
.on_down(MouseButton::Left, |_, _, cx| cx.focus_parent_view()) .on_down(MouseButton::Left, |_, _, cx| cx.focus_parent_view())
.boxed() .into_element()
} }
} }
@ -120,18 +119,16 @@ impl Item for SharedScreen {
.with_width(style.type_icon_width) .with_width(style.type_icon_width)
.aligned() .aligned()
.contained() .contained()
.with_margin_right(style.spacing) .with_margin_right(style.spacing),
.boxed(),
) )
.with_child( .with_child(
Label::new( Label::new(
format!("{}'s screen", self.user.github_login), format!("{}'s screen", self.user.github_login),
style.label.clone(), style.label.clone(),
) )
.aligned() .aligned(),
.boxed(),
) )
.boxed() .into_element()
} }
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) { fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {

View file

@ -202,9 +202,9 @@ impl View for Sidebar {
style.initial_size, style.initial_size,
cx, cx,
) )
.boxed() .into_element()
} else { } else {
Empty::new().boxed() Empty::new().into_element()
} }
} }
} }
@ -258,7 +258,7 @@ impl View for SidebarButtons {
let is_active = is_open && ix == active_ix; let is_active = is_open && ix == active_ix;
let style = item_style.style_for(state, is_active); let style = item_style.style_for(state, is_active);
Stack::new() Stack::new()
.with_child(Svg::new(icon_path).with_color(style.icon_color).boxed()) .with_child(Svg::new(icon_path).with_color(style.icon_color))
.with_children(if !is_active && item_view.should_show_badge(cx) { .with_children(if !is_active && item_view.should_show_badge(cx) {
Some( Some(
Empty::new() Empty::new()
@ -267,8 +267,7 @@ impl View for SidebarButtons {
.with_style(badge_style) .with_style(badge_style)
.aligned() .aligned()
.bottom() .bottom()
.right() .right(),
.boxed(),
) )
} else { } else {
None None
@ -278,7 +277,6 @@ impl View for SidebarButtons {
.with_height(style.icon_size) .with_height(style.icon_size)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, { .on_click(MouseButton::Left, {
@ -292,12 +290,11 @@ impl View for SidebarButtons {
tooltip_style.clone(), tooltip_style.clone(),
cx, cx,
) )
.boxed()
}, },
)) ))
.contained() .contained()
.with_style(group_style) .with_style(group_style)
.boxed() .into_element()
} }
} }

View file

@ -56,9 +56,8 @@ impl View for StatusBar {
.aligned() .aligned()
.contained() .contained()
.with_margin_right(theme.item_spacing) .with_margin_right(theme.item_spacing)
.boxed()
})) }))
.boxed(), .into_element(),
right: Flex::row() right: Flex::row()
.with_children(self.right_items.iter().rev().map(|i| { .with_children(self.right_items.iter().rev().map(|i| {
@ -66,15 +65,14 @@ impl View for StatusBar {
.aligned() .aligned()
.contained() .contained()
.with_margin_left(theme.item_spacing) .with_margin_left(theme.item_spacing)
.boxed()
})) }))
.boxed(), .into_element(),
} }
.contained() .contained()
.with_style(theme.container) .with_style(theme.container)
.constrained() .constrained()
.with_height(theme.height) .with_height(theme.height)
.boxed() .into_element()
} }
} }

View file

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

View file

@ -2088,29 +2088,24 @@ impl Workspace {
}; };
enum TitleBar {} enum TitleBar {}
ConstrainedBox::new(
MouseEventHandler::<TitleBar, _>::new(0, cx, |_, cx| { MouseEventHandler::<TitleBar, _>::new(0, cx, |_, cx| {
Container::new(
Stack::new() Stack::new()
.with_children( .with_children(
self.titlebar_item self.titlebar_item
.as_ref() .as_ref()
.map(|item| ChildView::new(item, cx).boxed()), .map(|item| ChildView::new(item, cx)),
)
.boxed(),
) )
.contained()
.with_style(container_theme) .with_style(container_theme)
.boxed()
}) })
.on_click(MouseButton::Left, |event, _, cx| { .on_click(MouseButton::Left, |event, _, cx| {
if event.click_count == 2 { if event.click_count == 2 {
cx.zoom_window(); cx.zoom_window();
} }
}) })
.boxed(), .constrained()
)
.with_height(theme.workspace.titlebar.height) .with_height(theme.workspace.titlebar.height)
.named("titlebar") .into_named_element("titlebar")
} }
fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) { fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) {
@ -2191,11 +2186,10 @@ impl Workspace {
.aligned() .aligned()
.contained() .contained()
.with_style(theme.workspace.disconnected_overlay.container) .with_style(theme.workspace.disconnected_overlay.container)
.boxed()
}) })
.with_cursor_style(CursorStyle::Arrow) .with_cursor_style(CursorStyle::Arrow)
.capture_all() .capture_all()
.boxed(), .into_named_element("disconnected overlay"),
) )
} else { } else {
None None
@ -2216,7 +2210,6 @@ impl Workspace {
ChildView::new(notification.as_any(), cx) ChildView::new(notification.as_any(), cx)
.contained() .contained()
.with_style(theme.notification) .with_style(theme.notification)
.boxed()
})) }))
.constrained() .constrained()
.with_width(theme.notifications.width) .with_width(theme.notifications.width)
@ -2225,7 +2218,7 @@ impl Workspace {
.aligned() .aligned()
.bottom() .bottom()
.right() .right()
.boxed(), .into_element(),
) )
} }
} }
@ -2857,8 +2850,7 @@ impl View for Workspace {
constraint.max.y(), constraint.max.y(),
), ),
) )
}) }),
.boxed(),
) )
} else { } else {
None None
@ -2876,18 +2868,15 @@ impl View for Workspace {
self.active_pane(), self.active_pane(),
cx, cx,
)) ))
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_children(self.dock.render( .with_children(self.dock.render(
&theme, &theme,
DockAnchor::Bottom, DockAnchor::Bottom,
cx, cx,
)) )),
.boxed(),
) )
.flex(1., true) .flex(1., true),
.boxed(),
) )
.with_children(self.dock.render(&theme, DockAnchor::Right, cx)) .with_children(self.dock.render(&theme, DockAnchor::Right, cx))
.with_children( .with_children(
@ -2903,17 +2892,14 @@ impl View for Workspace {
constraint.max.y(), constraint.max.y(),
), ),
) )
}) }),
.boxed(),
) )
} else { } else {
None None
}, },
) )
.boxed()
}) })
.with_child( .with_child(Overlay::new(
Overlay::new(
Stack::new() Stack::new()
.with_children(self.dock.render( .with_children(self.dock.render(
&theme, &theme,
@ -2926,26 +2912,18 @@ impl View for Workspace {
.with_style(theme.workspace.modal) .with_style(theme.workspace.modal)
.aligned() .aligned()
.top() .top()
.boxed()
})) }))
.with_children( .with_children(self.render_notifications(&theme.workspace, cx)),
self.render_notifications(&theme.workspace, cx), ))
.flex(1.0, true),
) )
.boxed(), .with_child(ChildView::new(&self.status_bar, cx))
)
.boxed(),
)
.flex(1.0, true)
.boxed(),
)
.with_child(ChildView::new(&self.status_bar, cx).boxed())
.contained() .contained()
.with_background_color(theme.workspace.background) .with_background_color(theme.workspace.background),
.boxed(),
) )
.with_children(DragAndDrop::render(cx)) .with_children(DragAndDrop::render(cx))
.with_children(self.render_disconnected_overlay(cx)) .with_children(self.render_disconnected_overlay(cx))
.named("workspace") .into_named_element("workspace")
} }
fn focus_in(&mut self, view: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, view: AnyViewHandle, cx: &mut ViewContext<Self>) {