WIP
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
AnyElement, Bounds, DispatchPhase, Element, IdentifiedElement, Interactive, MouseDownEvent,
|
||||
MouseEventListeners, MouseUpEvent, ParentElement, Pixels, Styled, ViewContext,
|
||||
AnyElement, Bounds, DispatchPhase, Element, IdentifiedElement, Interactive, IntoAnyElement,
|
||||
MouseDownEvent, MouseEventListeners, MouseUpEvent, ParentElement, Pixels, Styled, ViewContext,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use refineable::Cascade;
|
||||
@@ -51,6 +51,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: IdentifiedElement> IntoAnyElement<E::ViewState> for Clickable<E> {
|
||||
fn into_any(self) -> AnyElement<E::ViewState> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> Element for Clickable<E>
|
||||
where
|
||||
E: IdentifiedElement,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
AnyElement, BorrowWindow, Bounds, Cascade, Element, ElementId, IdentifiedElement, Interactive,
|
||||
LayoutId, MouseEventListeners, Overflow, ParentElement, Pixels, Point, Refineable, Style,
|
||||
Styled, ViewContext,
|
||||
IntoAnyElement, LayoutId, MouseEventListeners, Overflow, ParentElement, Pixels, Point,
|
||||
Refineable, Style, Styled, ViewContext,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use smallvec::SmallVec;
|
||||
@@ -29,7 +29,21 @@ pub fn div<S>() -> Div<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync, Marker: 'static + Send + Sync> Element for Div<S, Marker> {
|
||||
impl<S, Marker> IntoAnyElement<S> for Div<S, Marker>
|
||||
where
|
||||
S: 'static + Send + Sync,
|
||||
Marker: 'static + Send + Sync,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<S> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Marker> Element for Div<S, Marker>
|
||||
where
|
||||
S: 'static + Send + Sync,
|
||||
Marker: 'static + Send + Sync,
|
||||
{
|
||||
type ViewState = S;
|
||||
type ElementState = ();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
AnyElement, AppContext, Bounds, Element, ElementId, IdentifiedElement, Interactive,
|
||||
MouseEventListeners, ParentElement, Pixels, SharedString, Styled, ViewContext,
|
||||
IntoAnyElement, MouseEventListeners, ParentElement, Pixels, SharedString, Styled, ViewContext,
|
||||
};
|
||||
use collections::HashMap;
|
||||
use refineable::Cascade;
|
||||
@@ -27,6 +27,12 @@ impl<E> Group<E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Element> IntoAnyElement<E::ViewState> for Group<E> {
|
||||
fn into_any(self) -> AnyElement<E::ViewState> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Element> Element for Group<E> {
|
||||
type ViewState = E::ViewState;
|
||||
type ElementState = E::ElementState;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
group_bounds, AnyElement, Bounds, DispatchPhase, Element, ElementId, IdentifiedElement,
|
||||
Interactive, MouseEventListeners, MouseMoveEvent, ParentElement, Pixels, SharedString, Styled,
|
||||
ViewContext,
|
||||
Interactive, IntoAnyElement, MouseEventListeners, MouseMoveEvent, ParentElement, Pixels,
|
||||
SharedString, Styled, ViewContext,
|
||||
};
|
||||
use refineable::{Cascade, CascadeSlot, Refineable};
|
||||
use smallvec::SmallVec;
|
||||
@@ -51,6 +51,17 @@ impl<S: 'static + Send + Sync, E: Interactive<S> + Styled> Interactive<S> for Ho
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> IntoAnyElement<E::ViewState> for Hoverable<E>
|
||||
where
|
||||
E: Element + Styled,
|
||||
<E as Styled>::Style: 'static + Refineable + Send + Sync + Default,
|
||||
<<E as Styled>::Style as Refineable>::Refinement: 'static + Refineable + Send + Sync + Default,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<E::ViewState> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> Element for Hoverable<E>
|
||||
where
|
||||
E: Element + Styled,
|
||||
|
||||
@@ -2,8 +2,8 @@ use refineable::{Cascade, Refineable};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{
|
||||
AnyElement, BorrowWindow, Bounds, Element, ElementId, IdentifiedElement, LayoutId,
|
||||
ParentElement, Styled, ViewContext,
|
||||
AnyElement, BorrowWindow, Bounds, Element, ElementId, IdentifiedElement, IntoAnyElement,
|
||||
LayoutId, ParentElement, Styled, ViewContext,
|
||||
};
|
||||
|
||||
pub struct Identified<E> {
|
||||
@@ -11,6 +11,12 @@ pub struct Identified<E> {
|
||||
pub(crate) id: ElementId,
|
||||
}
|
||||
|
||||
impl<E: Element> IntoAnyElement<E::ViewState> for Identified<E> {
|
||||
fn into_any(self) -> AnyElement<E::ViewState> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Element> Element for Identified<E> {
|
||||
type ViewState = E::ViewState;
|
||||
type ElementState = E::ElementState;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
BorrowWindow, Bounds, Element, LayoutId, Pixels, SharedString, Style, Styled, ViewContext,
|
||||
AnyElement, BorrowWindow, Bounds, Element, IntoAnyElement, LayoutId, Pixels, SharedString,
|
||||
Style, Styled, ViewContext,
|
||||
};
|
||||
use futures::FutureExt;
|
||||
use refineable::Cascade;
|
||||
@@ -34,6 +35,15 @@ impl<S> Img<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> IntoAnyElement<S> for Img<S>
|
||||
where
|
||||
S: 'static + Send + Sync,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<S> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Send + Sync + 'static> Element for Img<S> {
|
||||
type ViewState = S;
|
||||
type ElementState = ();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
group_bounds, AnyElement, Bounds, DispatchPhase, Element, IdentifiedElement, Interactive,
|
||||
MouseDownEvent, MouseEventListeners, MouseUpEvent, ParentElement, Pixels, SharedString, Styled,
|
||||
ViewContext,
|
||||
IntoAnyElement, MouseDownEvent, MouseEventListeners, MouseUpEvent, ParentElement, Pixels,
|
||||
SharedString, Styled, ViewContext,
|
||||
};
|
||||
use refineable::{Cascade, CascadeSlot, Refineable};
|
||||
use smallvec::SmallVec;
|
||||
@@ -54,6 +54,17 @@ impl<S: 'static + Send + Sync, E: Interactive<S> + Styled> Interactive<S> for Pr
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> IntoAnyElement<E::ViewState> for Pressable<E>
|
||||
where
|
||||
E: Styled + IdentifiedElement,
|
||||
<E as Styled>::Style: 'static + Refineable + Send + Sync + Default,
|
||||
<<E as Styled>::Style as Refineable>::Refinement: 'static + Refineable + Send + Sync + Default,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<E::ViewState> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> Element for Pressable<E>
|
||||
where
|
||||
E: Styled + IdentifiedElement,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use crate::{Bounds, Element, LayoutId, Pixels, SharedString, Style, Styled};
|
||||
use crate::{
|
||||
AnyElement, Bounds, Element, IntoAnyElement, LayoutId, Pixels, SharedString, Style, Styled,
|
||||
};
|
||||
use refineable::Cascade;
|
||||
use std::marker::PhantomData;
|
||||
use util::ResultExt;
|
||||
@@ -24,6 +26,15 @@ impl<S> Svg<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> IntoAnyElement<S> for Svg<S>
|
||||
where
|
||||
S: 'static + Send + Sync,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<S> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Element for Svg<S> {
|
||||
type ViewState = S;
|
||||
type ElementState = ();
|
||||
|
||||
@@ -42,6 +42,12 @@ pub struct Text<S> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> IntoAnyElement<S> for Text<S> {
|
||||
fn into_any(self) -> AnyElement<S> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Element for Text<S> {
|
||||
type ViewState = S;
|
||||
type ElementState = Arc<Mutex<Option<TextElementState>>>;
|
||||
|
||||
Reference in New Issue
Block a user