Remove vestiges of after_layout

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-08-23 15:23:06 +02:00
parent 6dddb72e82
commit 2c3ba00d3e
3 changed files with 2 additions and 38 deletions

View file

@ -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);
}

View file

@ -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,
};

View file

@ -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<usize, ElementBox>,
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<usize, ElementBox>,
pub scene: &'a mut Scene,