From 2c3ba00d3e99238b171233939bc885262165faf9 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 23 Aug 2021 15:23:06 +0200 Subject: [PATCH] Remove vestiges of `after_layout` Co-Authored-By: Nathan Sobo --- gpui/src/elements.rs | 8 +------- gpui/src/lib.rs | 3 +-- gpui/src/presenter.rs | 29 ----------------------------- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/gpui/src/elements.rs b/gpui/src/elements.rs index e390e84653981daf0b06ce8c0edd19eda259123b..1156a434e1243c185ca92de4b12a8a6103e4162f 100644 --- a/gpui/src/elements.rs +++ b/gpui/src/elements.rs @@ -31,8 +31,7 @@ pub use uniform_list::*; use crate::{ geometry::{rect::RectF, vector::Vector2F}, - json, AfterLayoutContext, DebugContext, Event, EventContext, LayoutContext, PaintContext, - SizeConstraint, + json, DebugContext, Event, EventContext, LayoutContext, PaintContext, SizeConstraint, }; use core::panic; use json::ToJson; @@ -40,7 +39,6 @@ use std::{any::Any, borrow::Cow, mem}; trait AnyElement { fn layout(&mut self, constraint: SizeConstraint, cx: &mut LayoutContext) -> Vector2F; - fn after_layout(&mut self, _: &mut AfterLayoutContext) {} fn paint(&mut self, origin: Vector2F, cx: &mut PaintContext); fn dispatch_event(&mut self, event: &Event, cx: &mut EventContext) -> bool; fn debug(&self, cx: &DebugContext) -> serde_json::Value; @@ -249,10 +247,6 @@ impl ElementBox { self.element.layout(constraint, cx) } - pub fn after_layout(&mut self, cx: &mut AfterLayoutContext) { - self.element.after_layout(cx); - } - pub fn paint(&mut self, origin: Vector2F, cx: &mut PaintContext) { self.element.paint(origin, cx); } diff --git a/gpui/src/lib.rs b/gpui/src/lib.rs index 308674d45dd726ed70a07d79dc20824aa07521c2..e7cfa3b1776ab416be5df8fed36f98aac36080bf 100644 --- a/gpui/src/lib.rs +++ b/gpui/src/lib.rs @@ -29,6 +29,5 @@ pub use gpui_macros::test; pub use platform::FontSystem; pub use platform::{Event, PathPromptOptions, Platform, PromptLevel}; pub use presenter::{ - AfterLayoutContext, Axis, DebugContext, EventContext, LayoutContext, PaintContext, - SizeConstraint, Vector2FExt, + Axis, DebugContext, EventContext, LayoutContext, PaintContext, SizeConstraint, Vector2FExt, }; diff --git a/gpui/src/presenter.rs b/gpui/src/presenter.rs index ebffa9653a76fbb28210aabc4c768a8900f1548f..f282e4405ea2e5ca2606a96dea9ca0cef3f9d8fc 100644 --- a/gpui/src/presenter.rs +++ b/gpui/src/presenter.rs @@ -82,7 +82,6 @@ impl Presenter { if let Some(root_view_id) = cx.root_view_id(self.window_id) { self.layout(window_size, cx); - self.after_layout(cx); let mut paint_cx = PaintContext { scene: &mut scene, font_cache: &self.font_cache, @@ -122,18 +121,6 @@ impl Presenter { } } - fn after_layout(&mut self, cx: &mut MutableAppContext) { - if let Some(root_view_id) = cx.root_view_id(self.window_id) { - let mut layout_cx = AfterLayoutContext { - rendered_views: &mut self.rendered_views, - font_cache: &self.font_cache, - text_layout_cache: &self.text_layout_cache, - app: cx, - }; - layout_cx.after_layout(root_view_id); - } - } - pub fn dispatch_event(&mut self, event: Event, cx: &mut MutableAppContext) { if let Some(root_view_id) = cx.root_view_id(self.window_id) { if matches!(event, Event::MouseMoved { .. }) { @@ -205,22 +192,6 @@ impl<'a> LayoutContext<'a> { } } -pub struct AfterLayoutContext<'a> { - rendered_views: &'a mut HashMap, - pub font_cache: &'a FontCache, - pub text_layout_cache: &'a TextLayoutCache, - pub app: &'a mut MutableAppContext, -} - -impl<'a> AfterLayoutContext<'a> { - fn after_layout(&mut self, view_id: usize) { - if let Some(mut view) = self.rendered_views.remove(&view_id) { - view.after_layout(self); - self.rendered_views.insert(view_id, view); - } - } -} - pub struct PaintContext<'a> { rendered_views: &'a mut HashMap, pub scene: &'a mut Scene,