Fix remaining z-index bugs

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Kirill Bulatov 2023-12-20 17:02:03 +02:00
parent 1474816a93
commit fe40e3920b
4 changed files with 10 additions and 3 deletions

View file

@ -68,7 +68,6 @@ impl Render for CollabTitlebarItem {
h_stack() h_stack()
.id("titlebar") .id("titlebar")
.z_index(160) // todo!("z-index")
.justify_between() .justify_between()
.w_full() .w_full()
.h(rems(1.75)) .h(rems(1.75))

View file

@ -2057,9 +2057,14 @@ pub trait BorrowWindow: BorrowMut<Window> + BorrowMut<AppContext> {
size: self.window().viewport_size, size: self.window().viewport_size,
}, },
}; };
let new_stacking_order_id =
post_inc(&mut self.window_mut().next_frame.next_stacking_order_id);
let old_stacking_order = mem::take(&mut self.window_mut().next_frame.z_index_stack);
self.window_mut().next_frame.z_index_stack.id = new_stacking_order_id;
self.window_mut().next_frame.content_mask_stack.push(mask); self.window_mut().next_frame.content_mask_stack.push(mask);
let result = f(self); let result = f(self);
self.window_mut().next_frame.content_mask_stack.pop(); self.window_mut().next_frame.content_mask_stack.pop();
self.window_mut().next_frame.z_index_stack = old_stacking_order;
result result
} }
@ -2068,9 +2073,14 @@ pub trait BorrowWindow: BorrowMut<Window> + BorrowMut<AppContext> {
fn with_z_index<R>(&mut self, z_index: u8, f: impl FnOnce(&mut Self) -> R) -> R { fn with_z_index<R>(&mut self, z_index: u8, f: impl FnOnce(&mut Self) -> R) -> R {
let new_stacking_order_id = let new_stacking_order_id =
post_inc(&mut self.window_mut().next_frame.next_stacking_order_id); post_inc(&mut self.window_mut().next_frame.next_stacking_order_id);
let old_stacking_order_id = mem::replace(
&mut self.window_mut().next_frame.z_index_stack.id,
new_stacking_order_id,
);
self.window_mut().next_frame.z_index_stack.id = new_stacking_order_id; self.window_mut().next_frame.z_index_stack.id = new_stacking_order_id;
self.window_mut().next_frame.z_index_stack.push(z_index); self.window_mut().next_frame.z_index_stack.push(z_index);
let result = f(self); let result = f(self);
self.window_mut().next_frame.z_index_stack.id = old_stacking_order_id;
self.window_mut().next_frame.z_index_stack.pop(); self.window_mut().next_frame.z_index_stack.pop();
result result
} }

View file

@ -96,7 +96,6 @@ impl RenderOnce for TabBar {
div() div()
.id(self.id) .id(self.id)
.z_index(120) // todo!("z-index")
.group("tab_bar") .group("tab_bar")
.flex() .flex()
.flex_none() .flex_none()

View file

@ -105,7 +105,6 @@ impl Render for Toolbar {
v_stack() v_stack()
.p_1() .p_1()
.gap_2() .gap_2()
.z_index(80) // todo!("z-index")
.border_b() .border_b()
.border_color(cx.theme().colors().border_variant) .border_color(cx.theme().colors().border_variant)
.bg(cx.theme().colors().toolbar_background) .bg(cx.theme().colors().toolbar_background)