WIP: Fix compilation of gpui2
This commit is contained in:
@@ -41,7 +41,7 @@ pub trait Element<V: 'static>: IntoAnyElement<V> {
|
||||
#[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
|
||||
|
||||
pub trait ParentElement<V>: Element<V> {
|
||||
pub trait ParentElement<V: 'static>: Element<V> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]>;
|
||||
|
||||
fn child(mut self, child: impl IntoAnyElement<V>) -> Self
|
||||
@@ -68,7 +68,7 @@ trait ElementObject<V> {
|
||||
fn paint(&mut self, view_state: &mut V, cx: &mut ViewContext<V>);
|
||||
}
|
||||
|
||||
struct RenderedElement<V, E: Element<V>> {
|
||||
struct RenderedElement<V: 'static, E: Element<V>> {
|
||||
element: E,
|
||||
phase: ElementRenderPhase<E::ElementState>,
|
||||
}
|
||||
@@ -181,6 +181,7 @@ pub struct AnyElement<V>(Box<dyn ElementObject<V> + Send + Sync>);
|
||||
impl<V> AnyElement<V> {
|
||||
pub fn new<E>(element: E) -> Self
|
||||
where
|
||||
V: 'static,
|
||||
E: 'static + Send + Sync,
|
||||
E: Element<V>,
|
||||
E::ElementState: Any + Send + Sync,
|
||||
|
||||
@@ -160,7 +160,7 @@ impl<V: 'static> Div<V, StatelessInteraction<V>, FocusDisabled> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, I> Focusable for Div<V, I, FocusEnabled<V>>
|
||||
impl<V, I> Focusable<V> for Div<V, I, FocusEnabled<V>>
|
||||
where
|
||||
V: 'static,
|
||||
I: ElementInteraction<V>,
|
||||
|
||||
@@ -161,7 +161,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, I> Focusable for Img<V, I, FocusEnabled<V>>
|
||||
impl<V, I> Focusable<V> for Img<V, I, FocusEnabled<V>>
|
||||
where
|
||||
V: 'static,
|
||||
I: ElementInteraction<V>,
|
||||
|
||||
@@ -135,7 +135,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: 'static, I> Focusable for Svg<V, I, FocusEnabled<V>>
|
||||
impl<V: 'static, I> Focusable<V> for Svg<V, I, FocusEnabled<V>>
|
||||
where
|
||||
I: ElementInteraction<V>,
|
||||
{
|
||||
|
||||
@@ -53,8 +53,7 @@ impl<V: 'static> IntoAnyElement<V> for Text<V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: 'static> Element for Text<V> {
|
||||
type ViewState = V;
|
||||
impl<V: 'static> Element<V> for Text<V> {
|
||||
type ElementState = Arc<Mutex<Option<TextElementState>>>;
|
||||
|
||||
fn id(&self) -> Option<crate::ElementId> {
|
||||
|
||||
@@ -11,7 +11,7 @@ pub type FocusListeners<V> = SmallVec<[FocusListener<V>; 2]>;
|
||||
pub type FocusListener<V> =
|
||||
Arc<dyn Fn(&mut V, &FocusHandle, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static>;
|
||||
|
||||
pub trait Focusable<V>: Element<V> {
|
||||
pub trait Focusable<V: 'static>: Element<V> {
|
||||
fn focus_listeners(&mut self) -> &mut FocusListeners<V>;
|
||||
fn set_focus_style(&mut self, style: StyleRefinement);
|
||||
fn set_focus_in_style(&mut self, style: StyleRefinement);
|
||||
@@ -43,10 +43,7 @@ pub trait Focusable<V>: Element<V> {
|
||||
|
||||
fn on_focus(
|
||||
mut self,
|
||||
listener: impl Fn(&mut Self::ViewState, &FocusEvent, &mut ViewContext<Self::ViewState>)
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,
|
||||
) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::{
|
||||
|
||||
const DRAG_THRESHOLD: f64 = 2.;
|
||||
|
||||
pub trait StatelessInteractive<V>: Element<V> {
|
||||
pub trait StatelessInteractive<V: 'static>: Element<V> {
|
||||
fn stateless_interaction(&mut self) -> &mut StatelessInteraction<V>;
|
||||
|
||||
fn hover(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self
|
||||
@@ -279,7 +279,7 @@ pub trait StatelessInteractive<V>: Element<V> {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait StatefulInteractive<V>: StatelessInteractive<V> {
|
||||
pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
|
||||
fn stateful_interaction(&mut self) -> &mut StatefulInteraction<V>;
|
||||
|
||||
fn active(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self
|
||||
@@ -870,6 +870,7 @@ pub struct ClickEvent {
|
||||
pub struct Drag<S, R, V, E>
|
||||
where
|
||||
R: Fn(&mut V, &mut ViewContext<V>) -> E,
|
||||
V: 'static,
|
||||
E: Element<V>,
|
||||
{
|
||||
pub state: S,
|
||||
@@ -880,6 +881,7 @@ where
|
||||
impl<S, R, V, E> Drag<S, R, V, E>
|
||||
where
|
||||
R: Fn(&mut V, &mut ViewContext<V>) -> E,
|
||||
V: 'static,
|
||||
E: Element<V>,
|
||||
{
|
||||
pub fn new(state: S, render_drag_handle: R) -> Self {
|
||||
|
||||
@@ -194,8 +194,7 @@ impl<ParentV: 'static> IntoAnyElement<ParentV> for AnyView {
|
||||
}
|
||||
}
|
||||
|
||||
impl Element for AnyView {
|
||||
type ViewState = ();
|
||||
impl Element<()> for AnyView {
|
||||
type ElementState = AnyBox;
|
||||
|
||||
fn id(&self) -> Option<crate::ElementId> {
|
||||
@@ -204,18 +203,18 @@ impl Element for AnyView {
|
||||
|
||||
fn initialize(
|
||||
&mut self,
|
||||
_: &mut Self::ViewState,
|
||||
_: &mut (),
|
||||
_: Option<Self::ElementState>,
|
||||
cx: &mut ViewContext<Self::ViewState>,
|
||||
cx: &mut ViewContext<()>,
|
||||
) -> Self::ElementState {
|
||||
self.view.lock().initialize(cx)
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
_: &mut Self::ViewState,
|
||||
_: &mut (),
|
||||
element: &mut Self::ElementState,
|
||||
cx: &mut ViewContext<Self::ViewState>,
|
||||
cx: &mut ViewContext<()>,
|
||||
) -> LayoutId {
|
||||
self.view.lock().layout(element, cx)
|
||||
}
|
||||
@@ -225,7 +224,7 @@ impl Element for AnyView {
|
||||
bounds: Bounds<Pixels>,
|
||||
_: &mut (),
|
||||
element: &mut AnyBox,
|
||||
cx: &mut ViewContext<Self::ViewState>,
|
||||
cx: &mut ViewContext<()>,
|
||||
) {
|
||||
self.view.lock().paint(bounds, element, cx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user