From ed2f1ddd2d6d099c09e5a1889666554876414893 Mon Sep 17 00:00:00 2001 From: Julia Date: Thu, 26 Jan 2023 14:01:05 -0500 Subject: [PATCH] Move workspace title into collaboration titlebar item render --- crates/collab_ui/src/collab_titlebar_item.rs | 20 +++++++++++++++++++- crates/gpui/src/elements.rs | 1 + crates/workspace/src/workspace.rs | 17 +---------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index a767e50565..d4f56c54f4 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -47,6 +47,15 @@ impl View for CollabTitlebarItem { return Empty::new().boxed(); }; + let project = workspace.read(cx).project().read(cx); + let mut worktree_root_names = String::new(); + for (i, name) in project.worktree_root_names(cx).enumerate() { + if i > 0 { + worktree_root_names.push_str(", "); + } + worktree_root_names.push_str(name); + } + let theme = cx.global::().theme.clone(); let mut container = Flex::row(); @@ -67,7 +76,16 @@ impl View for CollabTitlebarItem { container.add_children(self.render_collaborators(&workspace, &theme, cx)); container.add_children(self.render_current_user(&workspace, &theme, cx)); container.add_children(self.render_connection_status(&workspace, cx)); - container.boxed() + + Stack::new() + .with_child( + Label::new(worktree_root_names, theme.workspace.titlebar.title.clone()) + .aligned() + .left() + .boxed(), + ) + .with_child(container.aligned().right().boxed()) + .boxed() } } diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rs index 41a802feb3..b77d46536d 100644 --- a/crates/gpui/src/elements.rs +++ b/crates/gpui/src/elements.rs @@ -363,6 +363,7 @@ impl AnyElement for Lifecycle { value } } + _ => panic!("invalid element lifecycle state"), } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d61fc3774c..e6a89045d2 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1837,15 +1837,6 @@ impl Workspace { } fn render_titlebar(&self, theme: &Theme, cx: &mut RenderContext) -> ElementBox { - let project = &self.project.read(cx); - let mut worktree_root_names = String::new(); - for (i, name) in project.worktree_root_names(cx).enumerate() { - if i > 0 { - worktree_root_names.push_str(", "); - } - worktree_root_names.push_str(name); - } - // TODO: There should be a better system in place for this // (https://github.com/zed-industries/zed/issues/1290) let is_fullscreen = cx.window_is_fullscreen(cx.window_id()); @@ -1862,16 +1853,10 @@ impl Workspace { MouseEventHandler::::new(0, cx, |_, cx| { Container::new( Stack::new() - .with_child( - Label::new(worktree_root_names, theme.workspace.titlebar.title.clone()) - .aligned() - .left() - .boxed(), - ) .with_children( self.titlebar_item .as_ref() - .map(|item| ChildView::new(item, cx).aligned().right().boxed()), + .map(|item| ChildView::new(item, cx).boxed()), ) .boxed(), )