diff --git a/gpui/src/elements.rs b/gpui/src/elements.rs index 08f8732e0e594679d6693c34263b27d4e38d679e..c8048ef3fa2f002656fb2a6943292e613f655aa0 100644 --- a/gpui/src/elements.rs +++ b/gpui/src/elements.rs @@ -108,6 +108,34 @@ pub trait Element { element: Rc::new(RefCell::new(Lifecycle::Init { element: self })), }) } + + fn constrained(self) -> ConstrainedBox + where + Self: 'static + Sized, + { + ConstrainedBox::new(self.boxed()) + } + + fn aligned(self) -> Align + where + Self: 'static + Sized, + { + Align::new(self.boxed()) + } + + fn contained(self) -> Container + where + Self: 'static + Sized, + { + Container::new(self.boxed()) + } + + fn expanded(self, flex: f32) -> Expanded + where + Self: 'static + Sized, + { + Expanded::new(flex, self.boxed()) + } } pub enum Lifecycle { diff --git a/zed/src/people_panel.rs b/zed/src/people_panel.rs index acdae8331f91c05f37ea29ce6fb2abd7a37aecb3..6c770b703ac92093451bc9e4226f7f186e2f2cda 100644 --- a/zed/src/people_panel.rs +++ b/zed/src/people_panel.rs @@ -96,21 +96,15 @@ impl PeoplePanel { .map(|avatar| Image::new(avatar).with_style(theme.host_avatar).boxed()), ) .with_child( - ConstrainedBox::new( - Align::new( - Container::new( - Label::new( - collaborator.user.github_login.clone(), - theme.host_username.text.clone(), - ) - .boxed(), - ) - .with_style(theme.host_username.container) - .boxed() - ) - .left() - .boxed() + Label::new( + collaborator.user.github_login.clone(), + theme.host_username.text.clone(), ) + .contained() + .with_style(theme.host_username.container) + .aligned() + .left() + .constrained() .with_height(host_avatar_height) .boxed() ) @@ -192,32 +186,26 @@ impl PeoplePanel { Container::new( Flex::row() .with_child( - ConstrainedBox::new( - Align::new( - Label::new( - worktree.root_name.clone(), - style.text.clone(), - ) - .boxed(), - ) - .left() - .boxed() + Label::new( + worktree.root_name.clone(), + style.text.clone(), ) + .aligned() + .left() + .constrained() .with_height(guest_avatar_height) .boxed() ) .with_children(worktree.guests.iter().filter_map( |participant| { participant.avatar.clone().map(|avatar| { - Container::new( - Image::new(avatar) - .with_style(theme.guest_avatar) - .boxed(), - ) - .with_margin_left( - theme.guest_avatar_spacing, - ) - .boxed() + Image::new(avatar) + .with_style(theme.guest_avatar) + .contained() + .with_margin_left( + theme.guest_avatar_spacing, + ) + .boxed() }) }, )) @@ -236,7 +224,7 @@ impl PeoplePanel { }); } - Expanded::new(1.0, worktree_row.boxed()).boxed() + worktree_row.expanded(1.0).boxed() }) .boxed() }),