From 61490fbaa8ac4472155d8ce2e9d493cc4919608e Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 17 Oct 2023 21:40:24 +0200 Subject: [PATCH] Checkpoint --- crates/gpui3/src/element.rs | 3 +-- crates/gpui3/src/elements/div.rs | 37 +++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/crates/gpui3/src/element.rs b/crates/gpui3/src/element.rs index 06cc7ff6caeaf94d5db09a4a226bc681dc9180f1..b9c42721d17c7c24e3842ab5e48bc54edd5424f8 100644 --- a/crates/gpui3/src/element.rs +++ b/crates/gpui3/src/element.rs @@ -1,4 +1,4 @@ -use crate::{BorrowWindow, Bounds, ElementId, LayoutId, Pixels, Point, SharedString, ViewContext}; +use crate::{BorrowWindow, Bounds, ElementId, LayoutId, Pixels, Point, ViewContext}; use derive_more::{Deref, DerefMut}; pub(crate) use smallvec::SmallVec; @@ -48,7 +48,6 @@ impl ElementIdentity for AnonymousElement { pub trait ParentElement: Element { fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]>; - fn group_mut(&mut self) -> &mut Option; fn child(mut self, child: impl IntoAnyElement) -> Self where diff --git a/crates/gpui3/src/elements/div.rs b/crates/gpui3/src/elements/div.rs index 43034787ff7cc48d4d361142633d3b71279cb253..0838183976d5e7ca712f3941677a6951afd88496 100644 --- a/crates/gpui3/src/elements/div.rs +++ b/crates/gpui3/src/elements/div.rs @@ -2,7 +2,8 @@ use crate::{ AnonymousElement, AnyElement, AppContext, BorrowWindow, Bounds, Clickable, DispatchPhase, Element, ElementId, ElementIdentity, IdentifiedElement, Interactive, IntoAnyElement, LayoutId, MouseClickEvent, MouseDownEvent, MouseEventListeners, MouseMoveEvent, MouseUpEvent, Overflow, - Pixels, Point, ScrollWheelEvent, SharedString, Style, StyleRefinement, Styled, ViewContext, + ParentElement, Pixels, Point, ScrollWheelEvent, SharedString, Style, StyleRefinement, Styled, + ViewContext, }; use collections::HashMap; use parking_lot::Mutex; @@ -112,18 +113,6 @@ where } } -impl Interactive for Div -where - V: 'static + Send + Sync, - K: ElementIdentity, -{ - fn listeners(&mut self) -> &mut MouseEventListeners { - &mut self.listeners - } -} - -impl Clickable for Div where V: 'static + Send + Sync {} - impl Div where V: 'static + Send + Sync, @@ -430,6 +419,16 @@ where } } +impl ParentElement for Div +where + V: 'static + Send + Sync, + K: ElementIdentity, +{ + fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { + &mut self.children + } +} + impl Styled for Div where V: 'static + Send + Sync, @@ -440,6 +439,18 @@ where } } +impl Interactive for Div +where + V: 'static + Send + Sync, + K: ElementIdentity, +{ + fn listeners(&mut self) -> &mut MouseEventListeners { + &mut self.listeners + } +} + +impl Clickable for Div where V: 'static + Send + Sync {} + fn paint_hover_listener(bounds: Bounds, cx: &mut ViewContext) where V: 'static + Send + Sync,