mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
Remove after_layout from Element trait
Now that layout takes a MutableAppContext we don't need an after_layout phase.
This commit is contained in:
parent
d0a5bc694c
commit
d68e0b0b97
18 changed files with 22 additions and 191 deletions
|
@ -46,14 +46,6 @@ impl gpui::Element for TextElement {
|
|||
(constraint.max, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: pathfinder_geometry::vector::Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
_: &mut gpui::AfterLayoutContext,
|
||||
) {
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -59,13 +59,6 @@ pub trait Element {
|
|||
cx: &mut LayoutContext,
|
||||
) -> (Vector2F, Self::LayoutState);
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
size: Vector2F,
|
||||
layout: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
);
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
@ -163,20 +156,6 @@ impl<T: Element> AnyElement for Lifecycle<T> {
|
|||
result
|
||||
}
|
||||
|
||||
fn after_layout(&mut self, cx: &mut AfterLayoutContext) {
|
||||
if let Lifecycle::PostLayout {
|
||||
element,
|
||||
size,
|
||||
layout,
|
||||
..
|
||||
} = self
|
||||
{
|
||||
element.after_layout(*size, layout, cx);
|
||||
} else {
|
||||
panic!("invalid element lifecycle state");
|
||||
}
|
||||
}
|
||||
|
||||
fn paint(&mut self, origin: Vector2F, cx: &mut PaintContext) {
|
||||
*self = if let Lifecycle::PostLayout {
|
||||
mut element,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
json, AfterLayoutContext, DebugContext, Element, ElementBox, Event, EventContext,
|
||||
LayoutContext, PaintContext, SizeConstraint,
|
||||
json, DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
};
|
||||
use json::ToJson;
|
||||
use pathfinder_geometry::vector::Vector2F;
|
||||
|
@ -51,15 +51,6 @@ impl Element for Align {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: pathfinder_geometry::rect::RectF,
|
||||
|
|
|
@ -56,14 +56,6 @@ where
|
|||
self.0(bounds, cx)
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
_: &mut crate::AfterLayoutContext,
|
||||
) {
|
||||
}
|
||||
|
||||
fn dispatch_event(
|
||||
&mut self,
|
||||
_: &crate::Event,
|
||||
|
|
|
@ -3,8 +3,8 @@ use serde_json::json;
|
|||
|
||||
use crate::{
|
||||
geometry::{rect::RectF, vector::Vector2F},
|
||||
json, AfterLayoutContext, DebugContext, Element, ElementBox, Event, EventContext,
|
||||
LayoutContext, PaintContext, SizeConstraint,
|
||||
json, DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
};
|
||||
|
||||
pub struct ConstrainedBox {
|
||||
|
@ -67,15 +67,6 @@ impl Element for ConstrainedBox {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -10,8 +10,7 @@ use crate::{
|
|||
},
|
||||
json::ToJson,
|
||||
scene::{self, Border, Quad},
|
||||
AfterLayoutContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
Element, ElementBox, Event, EventContext, LayoutContext, PaintContext, SizeConstraint,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
|
@ -167,15 +166,6 @@ impl Element for Container {
|
|||
(child_size + size_buffer, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -6,9 +6,7 @@ use crate::{
|
|||
json::{json, ToJson},
|
||||
DebugContext,
|
||||
};
|
||||
use crate::{
|
||||
AfterLayoutContext, Element, Event, EventContext, LayoutContext, PaintContext, SizeConstraint,
|
||||
};
|
||||
use crate::{Element, Event, EventContext, LayoutContext, PaintContext, SizeConstraint};
|
||||
|
||||
pub struct Empty;
|
||||
|
||||
|
@ -41,9 +39,6 @@ impl Element for Empty {
|
|||
(vec2f(x, y), ())
|
||||
}
|
||||
|
||||
fn after_layout(&mut self, _: Vector2F, _: &mut Self::LayoutState, _: &mut AfterLayoutContext) {
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
_: RectF,
|
||||
|
|
|
@ -2,8 +2,8 @@ use pathfinder_geometry::rect::RectF;
|
|||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
geometry::vector::Vector2F, AfterLayoutContext, DebugContext, Element, ElementBox, Event,
|
||||
EventContext, LayoutContext, PaintContext, SizeConstraint,
|
||||
geometry::vector::Vector2F, DebugContext, Element, ElementBox, Event, EventContext,
|
||||
LayoutContext, PaintContext, SizeConstraint,
|
||||
};
|
||||
|
||||
pub struct EventHandler {
|
||||
|
@ -41,15 +41,6 @@ impl Element for EventHandler {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -2,8 +2,8 @@ use std::{any::Any, f32::INFINITY};
|
|||
|
||||
use crate::{
|
||||
json::{self, ToJson, Value},
|
||||
AfterLayoutContext, Axis, DebugContext, Element, ElementBox, Event, EventContext,
|
||||
LayoutContext, PaintContext, SizeConstraint, Vector2FExt,
|
||||
Axis, DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint, Vector2FExt,
|
||||
};
|
||||
use pathfinder_geometry::{
|
||||
rect::RectF,
|
||||
|
@ -134,17 +134,6 @@ impl Element for Flex {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
for child in &mut self.children {
|
||||
child.after_layout(cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
@ -223,15 +212,6 @@ impl Element for Expanded {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -8,8 +8,8 @@ use crate::{
|
|||
},
|
||||
json::{ToJson, Value},
|
||||
text_layout::Line,
|
||||
AfterLayoutContext, DebugContext, Element, Event, EventContext, FontCache, LayoutContext,
|
||||
PaintContext, SizeConstraint,
|
||||
DebugContext, Element, Event, EventContext, FontCache, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
|
@ -140,9 +140,6 @@ impl Element for Label {
|
|||
(size, line)
|
||||
}
|
||||
|
||||
fn after_layout(&mut self, _: Vector2F, _: &mut Self::LayoutState, _: &mut AfterLayoutContext) {
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -6,8 +6,8 @@ use crate::{
|
|||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
json::{json, ToJson},
|
||||
AfterLayoutContext, DebugContext, Element, ElementBox, Event, EventContext, LayoutContext,
|
||||
PaintContext, SizeConstraint,
|
||||
DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
};
|
||||
|
||||
pub struct LineBox {
|
||||
|
@ -60,15 +60,6 @@ impl Element for LineBox {
|
|||
}
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: pathfinder_geometry::rect::RectF,
|
||||
|
|
|
@ -44,15 +44,6 @@ impl Element for List {
|
|||
todo!()
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
size: Vector2F,
|
||||
layout: &mut Self::LayoutState,
|
||||
cx: &mut crate::AfterLayoutContext,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
geometry::{rect::RectF, vector::Vector2F},
|
||||
AfterLayoutContext, AppContext, DebugContext, Element, ElementBox, Event, EventContext,
|
||||
LayoutContext, PaintContext, SizeConstraint, ValueHandle,
|
||||
AppContext, DebugContext, Element, ElementBox, Event, EventContext, LayoutContext,
|
||||
PaintContext, SizeConstraint, ValueHandle,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
|
@ -51,15 +51,6 @@ impl Element for MouseEventHandler {
|
|||
(self.child.layout(constraint, cx), ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
self.child.after_layout(cx);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
geometry::{rect::RectF, vector::Vector2F},
|
||||
json::{self, json, ToJson},
|
||||
AfterLayoutContext, DebugContext, Element, ElementBox, Event, EventContext, LayoutContext,
|
||||
PaintContext, SizeConstraint,
|
||||
DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
};
|
||||
|
||||
pub struct Stack {
|
||||
|
@ -33,17 +33,6 @@ impl Element for Stack {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
for child in &mut self.children {
|
||||
child.after_layout(cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -8,8 +8,7 @@ use crate::{
|
|||
rect::RectF,
|
||||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
scene, AfterLayoutContext, DebugContext, Element, Event, EventContext, LayoutContext,
|
||||
PaintContext, SizeConstraint,
|
||||
scene, DebugContext, Element, Event, EventContext, LayoutContext, PaintContext, SizeConstraint,
|
||||
};
|
||||
|
||||
pub struct Svg {
|
||||
|
@ -66,9 +65,6 @@ impl Element for Svg {
|
|||
}
|
||||
}
|
||||
|
||||
fn after_layout(&mut self, _: Vector2F, _: &mut Self::LayoutState, _: &mut AfterLayoutContext) {
|
||||
}
|
||||
|
||||
fn paint(&mut self, bounds: RectF, svg: &mut Self::LayoutState, cx: &mut PaintContext) {
|
||||
if let Some(svg) = svg.clone() {
|
||||
cx.scene.push_icon(scene::Icon {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
use super::{
|
||||
AfterLayoutContext, Element, Event, EventContext, LayoutContext, PaintContext, SizeConstraint,
|
||||
};
|
||||
use super::{Element, Event, EventContext, LayoutContext, PaintContext, SizeConstraint};
|
||||
use crate::{
|
||||
geometry::{
|
||||
rect::RectF,
|
||||
|
@ -164,17 +162,6 @@ where
|
|||
)
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
layout: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
for item in &mut layout.items {
|
||||
item.after_layout(cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
|
@ -398,15 +398,6 @@ impl Element for ChildView {
|
|||
(size, ())
|
||||
}
|
||||
|
||||
fn after_layout(
|
||||
&mut self,
|
||||
_: Vector2F,
|
||||
_: &mut Self::LayoutState,
|
||||
cx: &mut AfterLayoutContext,
|
||||
) {
|
||||
cx.after_layout(self.view_id);
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: pathfinder_geometry::rect::RectF,
|
||||
|
|
|
@ -9,8 +9,8 @@ use gpui::{
|
|||
},
|
||||
json::{self, ToJson},
|
||||
text_layout::{self, TextLayoutCache},
|
||||
AfterLayoutContext, AppContext, Border, Element, Event, EventContext, FontCache, LayoutContext,
|
||||
MutableAppContext, PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle,
|
||||
AppContext, Border, Element, Event, EventContext, FontCache, LayoutContext, MutableAppContext,
|
||||
PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle,
|
||||
};
|
||||
use json::json;
|
||||
use smallvec::SmallVec;
|
||||
|
@ -552,9 +552,6 @@ impl Element for EditorElement {
|
|||
(size, Some(layout))
|
||||
}
|
||||
|
||||
fn after_layout(&mut self, _: Vector2F, _: &mut Self::LayoutState, _: &mut AfterLayoutContext) {
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: RectF,
|
||||
|
|
Loading…
Reference in a new issue