Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix more z-index and rendering issues
Kirill Bulatov8f1c5375efa1
diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rsindex 023b77ab8f3..914e5c7bb64 100644--- a/crates/collab_ui2/src/collab_titlebar_item.rs+++ b/crates/collab_ui2/src/collab_titlebar_item.rs@@ -68,6 +68,7 @@ impl Render for CollabTitlebarItem {h_stack().id("titlebar")+ .z_index(160).justify_between().w_full().h(rems(1.75))diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rsindex 8fce15d1c69..84c66f3534e 100644--- a/crates/ui2/src/components/context_menu.rs+++ b/crates/ui2/src/components/context_menu.rs@@ -3,8 +3,8 @@ use crate::{ListSeparator, ListSubHeader,};use gpui::{- px, Action, AppContext, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView,- IntoElement, Render, Subscription, View, VisualContext,+ px, Action, AnyElement, AppContext, DismissEvent, Div, EventEmitter, FocusHandle,+ FocusableView, IntoElement, Render, Subscription, View, VisualContext,};use menu::{SelectFirst, SelectLast, SelectNext, SelectPrev};use std::{rc::Rc, time::Duration};@@ -18,6 +18,9 @@ pub enum ContextMenuItem {handler: Rc<dyn Fn(&mut WindowContext)>,action: Option<Box<dyn Action>>,},+ CustomEntry {+ entry_render: Box<dyn Fn(&mut WindowContext) -> AnyElement>,+ },}pub struct ContextMenu {@@ -83,6 +86,16 @@ impl ContextMenu {self}+ pub fn custom_entry(+ mut self,+ entry_render: impl Fn(&mut WindowContext) -> AnyElement + 'static,+ ) -> Self {+ self.items.push(ContextMenuItem::CustomEntry {+ entry_render: Box::new(entry_render),+ });+ self+ }+pub fn action(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> Self {self.items.push(ContextMenuItem::Entry {label: label.into(),@@ -230,9 +243,9 @@ impl Render for ContextMenu {el}).flex_none()- .child(- List::new().children(self.items.iter().enumerate().map(- |(ix, item)| match item {+ .child(List::new().children(self.items.iter_mut().enumerate().map(+ |(ix, item)| {+ match item {ContextMenuItem::Separator => ListSeparator.into_any_element(),ContextMenuItem::Header(header) => {ListSubHeader::new(header.clone()).into_any_element()@@ -255,7 +268,7 @@ impl Render for ContextMenu {Label::new(label.clone()).into_any_element()};- ListItem::new(label.clone())+ ListItem::new(ix).inset(true).selected(Some(ix) == self.selected_index).on_click(move |_, cx| handler(cx))@@ -271,9 +284,14 @@ impl Render for ContextMenu {).into_any_element()}- },- )),- ),+ ContextMenuItem::CustomEntry { entry_render } => ListItem::new(ix)+ .inset(true)+ .selected(Some(ix) == self.selected_index)+ .child(entry_render(cx))+ .into_any_element(),+ }+ },+ ))),)}}diff --git a/crates/ui2/src/components/list/list_item.rs b/crates/ui2/src/components/list/list_item.rsindex a6f99350534..e8689030c36 100644--- a/crates/ui2/src/components/list/list_item.rs+++ b/crates/ui2/src/components/list/list_item.rs@@ -129,7 +129,6 @@ impl RenderOnce for ListItem {fn render(self, cx: &mut WindowContext) -> Self::Rendered {h_stack().id(self.id)- .bg(gpui::green()).w_full().relative()// When an item is inset draw the indent spacing outside of the item@@ -172,8 +171,8 @@ impl RenderOnce for ListItem {})}).when_some(self.on_click, |this, on_click| {- this.cursor_copy()- .on_click(move |event, cx| on_click(dbg!(event), cx))+ this.cursor_pointer()+ .on_click(move |event, cx| on_click(event, cx))}).when_some(self.on_secondary_mouse_down, |this, on_mouse_down| {this.on_mouse_down(MouseButton::Right, move |event, cx| {diff --git a/crates/ui2/src/components/tab_bar.rs b/crates/ui2/src/components/tab_bar.rsindex 7cff2f51bd8..b10ffd1c630 100644--- a/crates/ui2/src/components/tab_bar.rs+++ b/crates/ui2/src/components/tab_bar.rs@@ -96,6 +96,7 @@ impl RenderOnce for TabBar {div().id(self.id)+ .z_index(120).group("tab_bar").flex().flex_none()