From 6a4f3aaa5639e30af9e99cc997415053c70b22dd Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Oct 2022 12:16:09 +0200 Subject: [PATCH 1/6] Create a `SceneBuilder` and sort stacking contexts when calling `build` --- crates/editor/src/element.rs | 8 ++--- crates/gpui/src/gpui.rs | 2 +- crates/gpui/src/presenter.rs | 21 +++++++------ crates/gpui/src/scene.rs | 61 +++++++++++++++++++++++------------- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 9bb1c2735fceebf1a296530d7969ef25c73a2f47..424351ebfc1fc40ff75636879fb14699800b0e3a 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -31,7 +31,7 @@ use gpui::{ text_layout::{self, Line, RunStyle, TextLayoutCache}, AppContext, Axis, Border, CursorRegion, Element, ElementBox, EventContext, LayoutContext, Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent, MouseRegion, MutableAppContext, - PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle, + PaintContext, Quad, SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle, }; use json::json; use language::{Bias, CursorShape, DiagnosticSeverity, OffsetUtf16, Point, Selection}; @@ -2189,7 +2189,7 @@ pub struct HighlightedRangeLine { } impl HighlightedRange { - pub fn paint(&self, bounds: RectF, scene: &mut Scene) { + pub fn paint(&self, bounds: RectF, scene: &mut SceneBuilder) { if self.lines.len() >= 2 && self.lines[0].start_x > self.lines[1].end_x { self.paint_lines(self.start_y, &self.lines[0..1], bounds, scene); self.paint_lines( @@ -2208,7 +2208,7 @@ impl HighlightedRange { start_y: f32, lines: &[HighlightedRangeLine], bounds: RectF, - scene: &mut Scene, + scene: &mut SceneBuilder, ) { if lines.is_empty() { return; @@ -2375,7 +2375,7 @@ mod tests { let mut element = EditorElement::new(editor.downgrade(), editor.read(cx).style(cx)); - let mut scene = Scene::new(1.0); + let mut scene = SceneBuilder::new(1.0); let mut presenter = cx.build_presenter(window_id, 30., Default::default()); let mut layout_cx = presenter.build_layout_context(Vector2F::zero(), false, cx); let (size, mut state) = element.layout( diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index 4cca93edc8a5dabfac011e137ea4ccd48698a3b0..d8b446ac177597ec8f6f04d51fd71e6939bd10da 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -16,7 +16,7 @@ pub mod fonts; pub mod geometry; mod presenter; pub mod scene; -pub use scene::{Border, CursorRegion, MouseRegion, MouseRegionId, Quad, Scene}; +pub use scene::{Border, CursorRegion, MouseRegion, MouseRegionId, Quad, Scene, SceneBuilder}; pub mod text_layout; pub use text_layout::TextLayoutCache; mod util; diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rs index 71803a4cf0862ac9101a64bdb0d2fd29cfeb6d6b..b0a8d37301a25a6354c3f173a16eb95603fec48c 100644 --- a/crates/gpui/src/presenter.rs +++ b/crates/gpui/src/presenter.rs @@ -8,13 +8,14 @@ use crate::{ platform::{CursorStyle, Event}, scene::{ CursorRegion, MouseClick, MouseDown, MouseDownOut, MouseDrag, MouseEvent, MouseHover, - MouseMove, MouseScrollWheel, MouseUp, MouseUpOut, + MouseMove, MouseScrollWheel, MouseUp, MouseUpOut, Scene, }, text_layout::TextLayoutCache, Action, AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, Appearance, AssetCache, ElementBox, Entity, FontSystem, ModelHandle, MouseButton, MouseMovedEvent, - MouseRegion, MouseRegionId, ParentId, ReadModel, ReadView, RenderContext, RenderParams, Scene, - UpgradeModelHandle, UpgradeViewHandle, View, ViewHandle, WeakModelHandle, WeakViewHandle, + MouseRegion, MouseRegionId, ParentId, ReadModel, ReadView, RenderContext, RenderParams, + SceneBuilder, UpgradeModelHandle, UpgradeViewHandle, View, ViewHandle, WeakModelHandle, + WeakViewHandle, }; use collections::{HashMap, HashSet}; use pathfinder_geometry::vector::{vec2f, Vector2F}; @@ -135,17 +136,18 @@ impl Presenter { refreshing: bool, cx: &mut MutableAppContext, ) -> Scene { - let mut scene = Scene::new(scale_factor); + let mut scene_builder = SceneBuilder::new(scale_factor); if let Some(root_view_id) = cx.root_view_id(self.window_id) { self.layout(window_size, refreshing, cx); - let mut paint_cx = self.build_paint_context(&mut scene, window_size, cx); + let mut paint_cx = self.build_paint_context(&mut scene_builder, window_size, cx); paint_cx.paint( root_view_id, Vector2F::zero(), RectF::new(Vector2F::zero(), window_size), ); self.text_layout_cache.finish_frame(); + let scene = scene_builder.build(); self.cursor_regions = scene.cursor_regions(); self.mouse_regions = scene.mouse_regions(); @@ -154,11 +156,12 @@ impl Presenter { self.dispatch_event(event, true, cx); } } + + scene } else { log::error!("could not find root_view_id for window {}", self.window_id); + scene_builder.build() } - - scene } fn layout(&mut self, window_size: Vector2F, refreshing: bool, cx: &mut MutableAppContext) { @@ -196,7 +199,7 @@ impl Presenter { pub fn build_paint_context<'a>( &'a mut self, - scene: &'a mut Scene, + scene: &'a mut SceneBuilder, window_size: Vector2F, cx: &'a mut MutableAppContext, ) -> PaintContext { @@ -689,7 +692,7 @@ pub struct PaintContext<'a> { rendered_views: &'a mut HashMap, view_stack: Vec, pub window_size: Vector2F, - pub scene: &'a mut Scene, + pub scene: &'a mut SceneBuilder, pub font_cache: &'a FontCache, pub text_layout_cache: &'a TextLayoutCache, pub app: &'a AppContext, diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 99b38a185277731a389771d531ef5b3ca9fc0187..9dd9e6bf218588670ab1146a7d39c1e640087904 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -18,7 +18,7 @@ use crate::{ pub use mouse_event::*; pub use mouse_region::*; -pub struct Scene { +pub struct SceneBuilder { scale_factor: f32, stacking_contexts: Vec, active_stacking_context_stack: Vec, @@ -176,18 +176,12 @@ pub struct Image { pub data: Arc, } -impl Scene { - pub fn new(scale_factor: f32) -> Self { - let stacking_context = StackingContext::new(0, None); - Scene { - scale_factor, - stacking_contexts: vec![stacking_context], - active_stacking_context_stack: vec![0], - #[cfg(debug_assertions)] - mouse_region_ids: Default::default(), - } - } +pub struct Scene { + scale_factor: f32, + stacking_contexts: Vec, +} +impl Scene { pub fn scale_factor(&self) -> f32 { self.scale_factor } @@ -204,16 +198,41 @@ impl Scene { } pub fn mouse_regions(&self) -> Vec<(MouseRegion, usize)> { - let mut regions = Vec::new(); - for stacking_context in self.stacking_contexts.iter() { - for layer in &stacking_context.layers { - for mouse_region in &layer.mouse_regions { - regions.push((mouse_region.clone(), stacking_context.depth)); - } - } + self.stacking_contexts + .iter() + .flat_map(|context| { + context + .layers + .iter() + .flat_map(|layer| &layer.mouse_regions) + .map(|region| (region.clone(), context.depth)) + }) + .collect() + } +} + +impl SceneBuilder { + pub fn new(scale_factor: f32) -> Self { + let stacking_context = StackingContext::new(0, None); + SceneBuilder { + scale_factor, + stacking_contexts: vec![stacking_context], + active_stacking_context_stack: vec![0], + #[cfg(debug_assertions)] + mouse_region_ids: Default::default(), + } + } + + pub fn build(mut self) -> Scene { + self.stacking_contexts.sort_by_key(|context| context.depth); + Scene { + scale_factor: self.scale_factor, + stacking_contexts: self.stacking_contexts, } - regions.sort_by_key(|(_, depth)| *depth); - regions + } + + pub fn scale_factor(&self) -> f32 { + self.scale_factor } pub fn push_stacking_context(&mut self, clip_bounds: Option) { From 33ebfc3f101b182443636d54baf1f0bf16466c42 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Oct 2022 12:18:23 +0200 Subject: [PATCH 2/6] Rename `depth` to `height` when referring to stacking contexts --- crates/gpui/src/presenter.rs | 16 ++++++++-------- crates/gpui/src/scene.rs | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rs index b0a8d37301a25a6354c3f173a16eb95603fec48c..7628edee0354d2d1a7878d2b03c3649cdfc45d9d 100644 --- a/crates/gpui/src/presenter.rs +++ b/crates/gpui/src/presenter.rs @@ -360,14 +360,14 @@ impl Presenter { for mut mouse_event in mouse_events { let mut valid_regions = Vec::new(); - // GPUI elements are arranged by depth but sibling elements can register overlapping + // GPUI elements are arranged by height but sibling elements can register overlapping // mouse regions. As such, hover events are only fired on overlapping elements which - // are at the same depth as the topmost element which overlaps with the mouse. + // are at the same height as the topmost element which overlaps with the mouse. match &mouse_event { MouseEvent::Hover(_) => { - let mut top_most_depth = None; + let mut top_most_height = None; let mouse_position = self.mouse_position.clone(); - for (region, depth) in self.mouse_regions.iter().rev() { + for (region, height) in self.mouse_regions.iter().rev() { // Allow mouse regions to appear transparent to hovers if !region.hoverable { continue; @@ -375,15 +375,15 @@ impl Presenter { let contains_mouse = region.bounds.contains_point(mouse_position); - if contains_mouse && top_most_depth.is_none() { - top_most_depth = Some(depth); + if contains_mouse && top_most_height.is_none() { + top_most_height = Some(height); } // This unwrap relies on short circuiting boolean expressions // The right side of the && is only executed when contains_mouse // is true, and we know above that when contains_mouse is true - // top_most_depth is set - if contains_mouse && depth == top_most_depth.unwrap() { + // top_most_height is set + if contains_mouse && height == top_most_height.unwrap() { //Ensure that hover entrance events aren't sent twice if self.hovered_region_ids.insert(region.id()) { valid_regions.push(region.clone()); diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 9dd9e6bf218588670ab1146a7d39c1e640087904..6c4b8a28f547f0c752e11ee1d4baee721818f42c 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -29,7 +29,7 @@ pub struct SceneBuilder { struct StackingContext { layers: Vec, active_layer_stack: Vec, - depth: usize, + height: usize, } #[derive(Default)] @@ -205,7 +205,7 @@ impl Scene { .layers .iter() .flat_map(|layer| &layer.mouse_regions) - .map(|region| (region.clone(), context.depth)) + .map(|region| (region.clone(), context.height)) }) .collect() } @@ -224,7 +224,7 @@ impl SceneBuilder { } pub fn build(mut self) -> Scene { - self.stacking_contexts.sort_by_key(|context| context.depth); + self.stacking_contexts.sort_by_key(|context| context.height); Scene { scale_factor: self.scale_factor, stacking_contexts: self.stacking_contexts, @@ -236,11 +236,11 @@ impl SceneBuilder { } pub fn push_stacking_context(&mut self, clip_bounds: Option) { - let depth = self.active_stacking_context().depth + 1; + let height = self.active_stacking_context().height + 1; self.active_stacking_context_stack .push(self.stacking_contexts.len()); self.stacking_contexts - .push(StackingContext::new(depth, clip_bounds)) + .push(StackingContext::new(height, clip_bounds)) } pub fn pop_stacking_context(&mut self) { @@ -332,11 +332,11 @@ impl SceneBuilder { } impl StackingContext { - fn new(depth: usize, clip_bounds: Option) -> Self { + fn new(height: usize, clip_bounds: Option) -> Self { Self { layers: vec![Layer::new(clip_bounds)], active_layer_stack: vec![0], - depth, + height, } } From 2055f05b09f2e6ae12564c76f9bc3efe9deee5f9 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Oct 2022 12:19:25 +0200 Subject: [PATCH 3/6] :lipstick: --- crates/gpui/src/scene.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 6c4b8a28f547f0c752e11ee1d4baee721818f42c..fbed606ff86d0a5248f14538bfc1ef48c66b5277 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -26,6 +26,11 @@ pub struct SceneBuilder { mouse_region_ids: HashSet, } +pub struct Scene { + scale_factor: f32, + stacking_contexts: Vec, +} + struct StackingContext { layers: Vec, active_layer_stack: Vec, @@ -176,11 +181,6 @@ pub struct Image { pub data: Arc, } -pub struct Scene { - scale_factor: f32, - stacking_contexts: Vec, -} - impl Scene { pub fn scale_factor(&self) -> f32 { self.scale_factor From dfe2fd03861a19430176e2ee589e24fd9fba5b52 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Oct 2022 13:41:47 +0200 Subject: [PATCH 4/6] Allow specifying a custom height for stacking contexts --- crates/editor/src/element.rs | 4 ++-- crates/gpui/src/elements/overlay.rs | 9 ++++++++- crates/gpui/src/elements/resizable.rs | 2 +- crates/gpui/src/presenter.rs | 10 +++++++--- crates/gpui/src/scene.rs | 4 ++-- crates/workspace/src/pane/dragged_item_receiver.rs | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 424351ebfc1fc40ff75636879fb14699800b0e3a..d80b4ea844433b9fd75e0b13f3395899304ed85b 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -791,7 +791,7 @@ impl EditorElement { cx.scene.pop_layer(); if let Some((position, context_menu)) = layout.context_menu.as_mut() { - cx.scene.push_stacking_context(None); + cx.scene.push_stacking_context(None, None); let cursor_row_layout = &layout.position_map.line_layouts[(position.row() - start_row) as usize]; let x = cursor_row_layout.x_for_index(position.column() as usize) - scroll_left; @@ -820,7 +820,7 @@ impl EditorElement { } if let Some((position, hover_popovers)) = layout.hover_popovers.as_mut() { - cx.scene.push_stacking_context(None); + cx.scene.push_stacking_context(None, None); // This is safe because we check on layout whether the required row is available let hovered_row_layout = diff --git a/crates/gpui/src/elements/overlay.rs b/crates/gpui/src/elements/overlay.rs index 15d3d764f2a626d9a2b4e2530e284e44f85ec9f4..b63b488b19977312d619ec540ca9ae48c549acf1 100644 --- a/crates/gpui/src/elements/overlay.rs +++ b/crates/gpui/src/elements/overlay.rs @@ -16,6 +16,7 @@ pub struct Overlay { fit_mode: OverlayFitMode, position_mode: OverlayPositionMode, hoverable: bool, + height: Option, } #[derive(Copy, Clone)] @@ -82,6 +83,7 @@ impl Overlay { fit_mode: OverlayFitMode::None, position_mode: OverlayPositionMode::Window, hoverable: false, + height: None, } } @@ -109,6 +111,11 @@ impl Overlay { self.hoverable = hoverable; self } + + pub fn with_height(mut self, height: usize) -> Self { + self.height = Some(height); + self + } } impl Element for Overlay { @@ -204,7 +211,7 @@ impl Element for Overlay { OverlayFitMode::None => {} } - cx.paint_stacking_context(None, |cx| { + cx.paint_stacking_context(None, self.height, |cx| { if self.hoverable { enum OverlayHoverCapture {} // Block hovers in lower stacking contexts diff --git a/crates/gpui/src/elements/resizable.rs b/crates/gpui/src/elements/resizable.rs index fb5bfa4a11643dbb351a9f7138b7fdb683f43ddb..b84ea57f54bdd62d65080220a7180f3b94bb329d 100644 --- a/crates/gpui/src/elements/resizable.rs +++ b/crates/gpui/src/elements/resizable.rs @@ -149,7 +149,7 @@ impl Element for Resizable { _child_size: &mut Self::LayoutState, cx: &mut crate::PaintContext, ) -> Self::PaintState { - cx.scene.push_stacking_context(None); + cx.scene.push_stacking_context(None, None); let handle_region = self.side.of_rect(bounds, self.handle_size); diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rs index 7628edee0354d2d1a7878d2b03c3649cdfc45d9d..4b2f7676697d83eed717f28e1ac426cc02085ee5 100644 --- a/crates/gpui/src/presenter.rs +++ b/crates/gpui/src/presenter.rs @@ -709,11 +709,15 @@ impl<'a> PaintContext<'a> { } #[inline] - pub fn paint_stacking_context(&mut self, clip_bounds: Option, f: F) - where + pub fn paint_stacking_context( + &mut self, + clip_bounds: Option, + height: Option, + f: F, + ) where F: FnOnce(&mut Self), { - self.scene.push_stacking_context(clip_bounds); + self.scene.push_stacking_context(clip_bounds, height); f(self); self.scene.pop_stacking_context(); } diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index fbed606ff86d0a5248f14538bfc1ef48c66b5277..079073fbd950535953a2f82bcec054bcbc09e9e4 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -235,8 +235,8 @@ impl SceneBuilder { self.scale_factor } - pub fn push_stacking_context(&mut self, clip_bounds: Option) { - let height = self.active_stacking_context().height + 1; + pub fn push_stacking_context(&mut self, clip_bounds: Option, height: Option) { + let height = height.unwrap_or_else(|| self.active_stacking_context().height + 1); self.active_stacking_context_stack .push(self.stacking_contexts.len()); self.stacking_contexts diff --git a/crates/workspace/src/pane/dragged_item_receiver.rs b/crates/workspace/src/pane/dragged_item_receiver.rs index a3f1285e51303feb4961e522a4deb3a051ee6ae7..6b69b94094da508d09fb87db89a05076e7703639 100644 --- a/crates/workspace/src/pane/dragged_item_receiver.rs +++ b/crates/workspace/src/pane/dragged_item_receiver.rs @@ -48,7 +48,7 @@ where .map(|(dir, margin)| dir.along_edge(bounds, margin)) .unwrap_or(bounds); - cx.paint_stacking_context(None, |cx| { + cx.paint_stacking_context(None, None, |cx| { cx.scene.push_quad(Quad { bounds: overlay_region, background: Some(overlay_color(cx)), From 2b4fd532023cdd0a457f718788cbe19ddc6a2b56 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Oct 2022 13:47:12 +0200 Subject: [PATCH 5/6] Rename height to z-index --- crates/gpui/src/elements/overlay.rs | 10 +++++----- crates/gpui/src/presenter.rs | 20 ++++++++++---------- crates/gpui/src/scene.rs | 19 ++++++++++--------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/crates/gpui/src/elements/overlay.rs b/crates/gpui/src/elements/overlay.rs index b63b488b19977312d619ec540ca9ae48c549acf1..3dd816ca2a10c593d1ff088f6b540a9f1376df04 100644 --- a/crates/gpui/src/elements/overlay.rs +++ b/crates/gpui/src/elements/overlay.rs @@ -16,7 +16,7 @@ pub struct Overlay { fit_mode: OverlayFitMode, position_mode: OverlayPositionMode, hoverable: bool, - height: Option, + z_index: Option, } #[derive(Copy, Clone)] @@ -83,7 +83,7 @@ impl Overlay { fit_mode: OverlayFitMode::None, position_mode: OverlayPositionMode::Window, hoverable: false, - height: None, + z_index: None, } } @@ -112,8 +112,8 @@ impl Overlay { self } - pub fn with_height(mut self, height: usize) -> Self { - self.height = Some(height); + pub fn with_z_index(mut self, z_index: usize) -> Self { + self.z_index = Some(z_index); self } } @@ -211,7 +211,7 @@ impl Element for Overlay { OverlayFitMode::None => {} } - cx.paint_stacking_context(None, self.height, |cx| { + cx.paint_stacking_context(None, self.z_index, |cx| { if self.hoverable { enum OverlayHoverCapture {} // Block hovers in lower stacking contexts diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rs index 4b2f7676697d83eed717f28e1ac426cc02085ee5..e43e428fe62fbfd782daa82b7da87b30219ebc9a 100644 --- a/crates/gpui/src/presenter.rs +++ b/crates/gpui/src/presenter.rs @@ -360,14 +360,14 @@ impl Presenter { for mut mouse_event in mouse_events { let mut valid_regions = Vec::new(); - // GPUI elements are arranged by height but sibling elements can register overlapping + // GPUI elements are arranged by z_index but sibling elements can register overlapping // mouse regions. As such, hover events are only fired on overlapping elements which - // are at the same height as the topmost element which overlaps with the mouse. + // are at the same z-index as the topmost element which overlaps with the mouse. match &mouse_event { MouseEvent::Hover(_) => { - let mut top_most_height = None; + let mut highest_z_index = None; let mouse_position = self.mouse_position.clone(); - for (region, height) in self.mouse_regions.iter().rev() { + for (region, z_index) in self.mouse_regions.iter().rev() { // Allow mouse regions to appear transparent to hovers if !region.hoverable { continue; @@ -375,15 +375,15 @@ impl Presenter { let contains_mouse = region.bounds.contains_point(mouse_position); - if contains_mouse && top_most_height.is_none() { - top_most_height = Some(height); + if contains_mouse && highest_z_index.is_none() { + highest_z_index = Some(z_index); } // This unwrap relies on short circuiting boolean expressions // The right side of the && is only executed when contains_mouse // is true, and we know above that when contains_mouse is true - // top_most_height is set - if contains_mouse && height == top_most_height.unwrap() { + // highest_z_index is set. + if contains_mouse && z_index == highest_z_index.unwrap() { //Ensure that hover entrance events aren't sent twice if self.hovered_region_ids.insert(region.id()) { valid_regions.push(region.clone()); @@ -712,12 +712,12 @@ impl<'a> PaintContext<'a> { pub fn paint_stacking_context( &mut self, clip_bounds: Option, - height: Option, + z_index: Option, f: F, ) where F: FnOnce(&mut Self), { - self.scene.push_stacking_context(clip_bounds, height); + self.scene.push_stacking_context(clip_bounds, z_index); f(self); self.scene.pop_stacking_context(); } diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 079073fbd950535953a2f82bcec054bcbc09e9e4..032087c95af6b80a6e6a3dbf449bae5bebbaa1a8 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -34,7 +34,7 @@ pub struct Scene { struct StackingContext { layers: Vec, active_layer_stack: Vec, - height: usize, + z_index: usize, } #[derive(Default)] @@ -205,7 +205,7 @@ impl Scene { .layers .iter() .flat_map(|layer| &layer.mouse_regions) - .map(|region| (region.clone(), context.height)) + .map(|region| (region.clone(), context.z_index)) }) .collect() } @@ -213,7 +213,7 @@ impl Scene { impl SceneBuilder { pub fn new(scale_factor: f32) -> Self { - let stacking_context = StackingContext::new(0, None); + let stacking_context = StackingContext::new(None, 0); SceneBuilder { scale_factor, stacking_contexts: vec![stacking_context], @@ -224,7 +224,8 @@ impl SceneBuilder { } pub fn build(mut self) -> Scene { - self.stacking_contexts.sort_by_key(|context| context.height); + self.stacking_contexts + .sort_by_key(|context| context.z_index); Scene { scale_factor: self.scale_factor, stacking_contexts: self.stacking_contexts, @@ -235,12 +236,12 @@ impl SceneBuilder { self.scale_factor } - pub fn push_stacking_context(&mut self, clip_bounds: Option, height: Option) { - let height = height.unwrap_or_else(|| self.active_stacking_context().height + 1); + pub fn push_stacking_context(&mut self, clip_bounds: Option, z_index: Option) { + let z_index = z_index.unwrap_or_else(|| self.active_stacking_context().z_index + 1); self.active_stacking_context_stack .push(self.stacking_contexts.len()); self.stacking_contexts - .push(StackingContext::new(height, clip_bounds)) + .push(StackingContext::new(clip_bounds, z_index)) } pub fn pop_stacking_context(&mut self) { @@ -332,11 +333,11 @@ impl SceneBuilder { } impl StackingContext { - fn new(height: usize, clip_bounds: Option) -> Self { + fn new(clip_bounds: Option, z_index: usize) -> Self { Self { layers: vec![Layer::new(clip_bounds)], active_layer_stack: vec![0], - height, + z_index, } } From f364a15d896076d284207edeca5657d7c3e4f868 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Oct 2022 13:47:37 +0200 Subject: [PATCH 6/6] Prevent expanded dock from hiding contacts popover --- crates/collab_ui/src/collab_titlebar_item.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 2a8870fe66dd7d64d509e1fa8105c88c76ce5612..658ca264256a1c0e0954c6f1fec51dea6c046584 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -247,6 +247,7 @@ impl CollabTitlebarItem { ) .with_fit_mode(OverlayFitMode::SwitchAnchor) .with_anchor_corner(AnchorCorner::BottomLeft) + .with_z_index(999) .boxed() })) .boxed()