Add more debugging

This commit is contained in:
Mikayla 2023-12-05 17:31:33 -08:00
parent 2ee0ecb677
commit 735f2029e9
No known key found for this signature in database
3 changed files with 87 additions and 63 deletions

View file

@ -1,10 +1,10 @@
use crate::{
green, point, px, red, Action, AnyDrag, AnyDragState, AnyElement, AnyTooltip, AnyView,
AppContext, BorrowAppContext, BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element,
ElementId, FocusEvent, FocusHandle, IntoElement, KeyContext, KeyDownEvent, KeyUpEvent,
LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels,
Point, Render, ScrollWheelEvent, SharedString, Size, StackingOrder, Style, StyleRefinement,
Styled, Task, View, Visibility, WindowContext,
point, px, Action, AnyDrag, AnyDragState, AnyElement, AnyTooltip, AnyView, AppContext,
BorrowAppContext, BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element, ElementId,
FocusEvent, FocusHandle, IntoElement, KeyContext, KeyDownEvent, KeyUpEvent, LayoutId,
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point,
Render, ScrollWheelEvent, SharedString, Size, StackingOrder, Style, StyleRefinement, Styled,
Task, View, Visibility, WindowContext,
};
use collections::HashMap;
use refineable::Refineable;
@ -95,6 +95,32 @@ pub trait InteractiveElement: Sized + Element {
self
}
fn on_mouse_down_weird(
mut self,
button: MouseButton,
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
) -> Self {
self.interactivity().mouse_down_listeners.push(Box::new(
move |event, bounds, phase, cx| {
dbg!("HEREEEE");
let contains = dbg!(dbg!(&bounds.bounds).contains_point(dbg!(&event.position)))
&& dbg!(cx.was_top_layer(&event.position, &bounds.stacking_order));
dbg!(contains);
if phase == DispatchPhase::Bubble
&& event.button == button
&& bounds.visibly_contains(&event.position, cx)
{
dbg!("HEREEEE2");
(listener)(event, cx)
}
},
));
self
}
fn on_any_mouse_down(
mut self,
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
@ -767,7 +793,7 @@ pub struct Interactivity {
pub tooltip_builder: Option<TooltipBuilder>,
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct InteractiveBounds {
pub bounds: Bounds<Pixels>,
pub stacking_order: StackingOrder,