Move workspace title into collaboration titlebar item render

This commit is contained in:
Julia 2023-01-26 14:01:05 -05:00
parent 24fcad3fa2
commit ed2f1ddd2d
3 changed files with 21 additions and 17 deletions

View File

@ -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::<Settings>().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()
}
}

View File

@ -363,6 +363,7 @@ impl<T: Element> AnyElement for Lifecycle<T> {
value
}
}
_ => panic!("invalid element lifecycle state"),
}
}

View File

@ -1837,15 +1837,6 @@ impl Workspace {
}
fn render_titlebar(&self, theme: &Theme, cx: &mut RenderContext<Self>) -> 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::<TitleBar>::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(),
)