From 859c0f53cb5449c0c358af1af04f6233ed3bd6d7 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 22 Mar 2021 18:55:53 +0100 Subject: [PATCH] WIP: Introduce layers in renderer Co-Authored-By: Nathan Sobo --- gpui/src/elements/stack.rs | 2 ++ gpui/src/scene.rs | 16 +++++++++------- zed/src/file_finder.rs | 6 +----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gpui/src/elements/stack.rs b/gpui/src/elements/stack.rs index 0d6858118d..f0d33e3afc 100644 --- a/gpui/src/elements/stack.rs +++ b/gpui/src/elements/stack.rs @@ -49,7 +49,9 @@ impl Element for Stack { ctx: &mut PaintContext, ) -> Self::PaintState { for child in &mut self.children { + ctx.scene.push_layer(); child.paint(bounds.origin(), ctx); + ctx.scene.pop_layer(); } } diff --git a/gpui/src/scene.rs b/gpui/src/scene.rs index 1ac8654cdb..ce73837c69 100644 --- a/gpui/src/scene.rs +++ b/gpui/src/scene.rs @@ -56,14 +56,16 @@ impl Scene { self.layers.as_slice() } - // pub fn push_layer(&mut self, clip_bounds: Option) { + pub fn push_layer(&mut self) { + let ix = self.layers.len(); + self.layers.push(Layer::default()); + self.active_layer_stack.push(ix); + } - // } - - // pub fn pop_layer(&mut self) { - // assert!(self.active_layer_stack.len() > 1); - // self.active_layer_stack.pop(); - // } + pub fn pop_layer(&mut self) { + assert!(self.active_layer_stack.len() > 1); + self.active_layer_stack.pop(); + } pub fn push_quad(&mut self, quad: Quad) { self.active_layer().push_quad(quad) diff --git a/zed/src/file_finder.rs b/zed/src/file_finder.rs index c57b33c631..45b4cff164 100644 --- a/zed/src/file_finder.rs +++ b/zed/src/file_finder.rs @@ -70,11 +70,7 @@ impl View for FileFinder { .with_uniform_padding(6.0) .with_corner_radius(6.0) .with_background_color(ColorU::new(0xf2, 0xf2, 0xf2, 0xff)) - .with_shadow( - vec2f(0.0, 4.0), - 12.0, - ColorF::new(0.0, 0.0, 0.0, 0.25).to_u8(), - ) + .with_shadow(vec2f(0., 4.), 12., ColorF::new(0.0, 0.0, 0.0, 0.25).to_u8()) .boxed(), ) .with_max_width(600.0)