Pass visible bounds to Element::dispatch_event

This commit is contained in:
Antonio Scandurra 2022-04-07 15:10:09 +02:00
parent ae415ee49b
commit 73f2fd6b09
23 changed files with 37 additions and 4 deletions

View File

@ -1147,6 +1147,7 @@ impl Element for EditorElement {
&mut self,
event: &Event,
_: RectF,
_: RectF,
layout: &mut LayoutState,
paint: &mut PaintState,
cx: &mut EventContext,

View File

@ -104,6 +104,7 @@ impl gpui::Element for TextElement {
&mut self,
_: &gpui::Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut gpui::EventContext,

View File

@ -74,6 +74,7 @@ pub trait Element {
&mut self,
event: &Event,
bounds: RectF,
visible_bounds: RectF,
layout: &mut Self::LayoutState,
paint: &mut Self::PaintState,
cx: &mut EventContext,
@ -169,6 +170,7 @@ pub enum Lifecycle<T: Element> {
element: T,
constraint: SizeConstraint,
bounds: RectF,
visible_bounds: RectF,
layout: T::LayoutState,
paint: T::PaintState,
},
@ -222,6 +224,7 @@ impl<T: Element> AnyElement for Lifecycle<T> {
element,
constraint,
bounds,
visible_bounds,
layout,
paint,
}
@ -242,6 +245,7 @@ impl<T: Element> AnyElement for Lifecycle<T> {
element,
constraint,
bounds,
visible_bounds,
layout,
paint,
}
@ -254,12 +258,13 @@ impl<T: Element> AnyElement for Lifecycle<T> {
if let Lifecycle::PostPaint {
element,
bounds,
visible_bounds,
layout,
paint,
..
} = self
{
element.dispatch_event(event, *bounds, layout, paint, cx)
element.dispatch_event(event, *bounds, *visible_bounds, layout, paint, cx)
} else {
panic!("invalid element lifecycle state");
}
@ -288,6 +293,7 @@ impl<T: Element> AnyElement for Lifecycle<T> {
element,
constraint,
bounds,
visible_bounds,
layout,
paint,
} => {
@ -299,6 +305,8 @@ impl<T: Element> AnyElement for Lifecycle<T> {
new_map.insert("type".into(), typ);
}
new_map.insert("constraint".into(), constraint.to_json());
new_map.insert("bounds".into(), bounds.to_json());
new_map.insert("visible_bounds".into(), visible_bounds.to_json());
new_map.append(map);
json::Value::Object(new_map)
} else {

View File

@ -85,7 +85,8 @@ impl Element for Align {
fn dispatch_event(
&mut self,
event: &Event,
_: pathfinder_geometry::rect::RectF,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -59,6 +59,7 @@ where
&mut self,
_: &crate::Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut crate::EventContext,

View File

@ -81,6 +81,7 @@ impl Element for ConstrainedBox {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -247,6 +247,7 @@ impl Element for Container {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -52,6 +52,7 @@ impl Element for Empty {
&mut self,
_: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut EventContext,

View File

@ -85,6 +85,8 @@ impl Element for EventHandler {
&mut self,
event: &Event,
bounds: RectF,
_: RectF,
visible_bounds: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -66,6 +66,7 @@ impl Element for Expanded {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -266,6 +266,7 @@ impl Element for Flex {
&mut self,
event: &Event,
bounds: RectF,
_: RectF,
remaining_space: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,
@ -391,6 +392,7 @@ impl Element for FlexItem {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -57,6 +57,7 @@ impl Element for Hook {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -81,6 +81,7 @@ impl Element for Image {
&mut self,
_: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut EventContext,

View File

@ -166,6 +166,7 @@ impl Element for Label {
&mut self,
_: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut EventContext,

View File

@ -253,6 +253,7 @@ impl Element for List {
&mut self,
event: &Event,
bounds: RectF,
_: RectF,
scroll_top: &mut ListOffset,
_: &mut (),
cx: &mut EventContext,
@ -872,6 +873,7 @@ mod tests {
&mut self,
_: &Event,
_: RectF,
_: RectF,
_: &mut (),
_: &mut (),
_: &mut EventContext,

View File

@ -100,6 +100,7 @@ impl Element for MouseEventHandler {
&mut self,
event: &Event,
bounds: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -44,6 +44,7 @@ impl Element for Overlay {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -51,6 +51,7 @@ impl Element for Stack {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -76,6 +76,7 @@ impl Element for Svg {
&mut self,
_: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut EventContext,

View File

@ -172,6 +172,7 @@ impl Element for Text {
&mut self,
_: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut EventContext,

View File

@ -281,6 +281,7 @@ where
&mut self,
event: &Event,
bounds: RectF,
_: RectF,
layout: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -535,6 +535,7 @@ impl Element for ChildView {
&mut self,
event: &Event,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
cx: &mut EventContext,

View File

@ -16,7 +16,7 @@ use gpui::{
action,
color::Color,
elements::*,
geometry::{vector::vec2f, PathBuilder},
geometry::{rect::RectF, vector::vec2f, PathBuilder},
json::{self, to_string_pretty, ToJson},
keymap::Binding,
platform::{CursorStyle, WindowOptions},
@ -2068,7 +2068,8 @@ impl Element for AvatarRibbon {
fn dispatch_event(
&mut self,
_: &gpui::Event,
_: gpui::geometry::rect::RectF,
_: RectF,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut gpui::EventContext,