Checkpoint
This commit is contained in:
+56
-12
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use refineable::Refineable;
|
use refineable::Refineable;
|
||||||
pub(crate) use smallvec::SmallVec;
|
pub(crate) use smallvec::SmallVec;
|
||||||
use std::mem;
|
use std::{marker::PhantomData, mem};
|
||||||
|
|
||||||
pub trait Element: 'static + Send + Sync + IntoAnyElement<Self::ViewState> {
|
pub trait Element: 'static + Send + Sync + IntoAnyElement<Self::ViewState> {
|
||||||
type ViewState: 'static + Send + Sync;
|
type ViewState: 'static + Send + Sync;
|
||||||
@@ -39,22 +39,66 @@ pub trait Element: 'static + Send + Sync + IntoAnyElement<Self::ViewState> {
|
|||||||
#[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]
|
#[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]
|
||||||
pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
|
pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
|
||||||
|
|
||||||
pub trait ElementIdentity: 'static + Send + Sync {
|
pub trait ElementInteractivity<V: 'static + Send + Sync>: 'static + Send + Sync {
|
||||||
fn id(&self) -> Option<ElementId>;
|
fn as_stateful(&self) -> Option<&StatefulInteractivity<V>>;
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Identified(pub(crate) ElementId);
|
fn initialize<R>(
|
||||||
|
&self,
|
||||||
impl ElementIdentity for Identified {
|
cx: &mut ViewContext<V>,
|
||||||
fn id(&self) -> Option<ElementId> {
|
f: impl FnOnce(Option<GlobalElementId>, &mut ViewContext<V>) -> R,
|
||||||
Some(self.0.clone())
|
) -> R {
|
||||||
|
if let Some(identified) = self.as_stateful() {
|
||||||
|
cx.with_element_id(identified.id.clone(), |global_id, cx| {
|
||||||
|
f(Some(global_id), cx)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
f(None, cx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Anonymous;
|
#[derive(Deref, DerefMut)]
|
||||||
|
pub struct StatefulInteractivity<V: 'static + Send + Sync> {
|
||||||
|
pub id: ElementId,
|
||||||
|
#[deref]
|
||||||
|
#[deref_mut]
|
||||||
|
common: StatelessInteractivity<V>,
|
||||||
|
}
|
||||||
|
|
||||||
impl ElementIdentity for Anonymous {
|
impl<V> ElementInteractivity<V> for StatefulInteractivity<V>
|
||||||
fn id(&self) -> Option<ElementId> {
|
where
|
||||||
|
V: 'static + Send + Sync,
|
||||||
|
{
|
||||||
|
fn as_stateful(&self) -> Option<&StatefulInteractivity<V>> {
|
||||||
|
Some(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<V> From<ElementId> for StatefulInteractivity<V>
|
||||||
|
where
|
||||||
|
V: 'static + Send + Sync,
|
||||||
|
{
|
||||||
|
fn from(id: ElementId) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
common: StatelessInteractivity::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct StatelessInteractivity<V>(PhantomData<V>);
|
||||||
|
|
||||||
|
impl<V> Default for StatelessInteractivity<V> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(PhantomData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<V> ElementInteractivity<V> for StatelessInteractivity<V>
|
||||||
|
where
|
||||||
|
V: 'static + Send + Sync,
|
||||||
|
{
|
||||||
|
fn as_stateful(&self) -> Option<&StatefulInteractivity<V>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
Active, Anonymous, AnyElement, AppContext, BorrowWindow, Bounds, Click, DispatchPhase, Element,
|
Active, AnyElement, AppContext, BorrowWindow, Bounds, Click, DispatchPhase, Element,
|
||||||
ElementFocusability, ElementId, ElementIdentity, Focus, FocusHandle, FocusListeners, Focusable,
|
ElementFocusability, ElementId, ElementInteractivity, Focus, FocusHandle, FocusListeners,
|
||||||
GlobalElementId, Hover, Identified, Interactive, Interactivity, IntoAnyElement, KeyDownEvent,
|
Focusable, GlobalElementId, Hover, Interactive, Interactivity, IntoAnyElement, KeyDownEvent,
|
||||||
KeyMatch, LayoutId, MouseDownEvent, MouseMoveEvent, MouseUpEvent, NonFocusable, Overflow,
|
KeyMatch, LayoutId, MouseDownEvent, MouseMoveEvent, MouseUpEvent, NonFocusable, Overflow,
|
||||||
ParentElement, Pixels, Point, SharedString, Style, StyleRefinement, Styled, ViewContext,
|
ParentElement, Pixels, Point, SharedString, StatefulInteractivity, StatelessInteractivity,
|
||||||
|
Style, StyleRefinement, Styled, ViewContext,
|
||||||
};
|
};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@@ -62,7 +63,7 @@ impl ScrollState {
|
|||||||
|
|
||||||
pub struct Div<
|
pub struct Div<
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity = Anonymous,
|
I: ElementInteractivity<V> = StatelessInteractivity<V>,
|
||||||
F: ElementFocusability<V> = NonFocusable,
|
F: ElementFocusability<V> = NonFocusable,
|
||||||
> {
|
> {
|
||||||
identity: I,
|
identity: I,
|
||||||
@@ -77,12 +78,12 @@ pub struct Div<
|
|||||||
group_active: Option<GroupStyle>,
|
group_active: Option<GroupStyle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn div<V>() -> Div<V, Anonymous, NonFocusable>
|
pub fn div<V>() -> Div<V, StatelessInteractivity<V>, NonFocusable>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
Div {
|
Div {
|
||||||
identity: Anonymous,
|
identity: StatelessInteractivity::default(),
|
||||||
focusability: NonFocusable,
|
focusability: NonFocusable,
|
||||||
interactivity: Interactivity::default(),
|
interactivity: Interactivity::default(),
|
||||||
children: SmallVec::new(),
|
children: SmallVec::new(),
|
||||||
@@ -100,14 +101,14 @@ struct GroupStyle {
|
|||||||
style: StyleRefinement,
|
style: StyleRefinement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Div<V, Anonymous, F>
|
impl<V, F> Div<V, StatelessInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
pub fn id(self, id: impl Into<ElementId>) -> Div<V, Identified, F> {
|
pub fn id(self, id: impl Into<ElementId>) -> Div<V, StatefulInteractivity<V>, F> {
|
||||||
Div {
|
Div {
|
||||||
identity: Identified(id.into()),
|
identity: id.into().into(),
|
||||||
focusability: self.focusability,
|
focusability: self.focusability,
|
||||||
interactivity: self.interactivity,
|
interactivity: self.interactivity,
|
||||||
children: self.children,
|
children: self.children,
|
||||||
@@ -123,7 +124,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> Div<V, I, F>
|
impl<V, I, F> Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -271,7 +272,7 @@ where
|
|||||||
|
|
||||||
impl<V, I> Div<V, I, NonFocusable>
|
impl<V, I> Div<V, I, NonFocusable>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
pub fn focusable(self, handle: &FocusHandle) -> Div<V, I, Focusable<V>> {
|
pub fn focusable(self, handle: &FocusHandle) -> Div<V, I, Focusable<V>> {
|
||||||
@@ -292,7 +293,7 @@ where
|
|||||||
|
|
||||||
impl<V, I> Focus for Div<V, I, Focusable<V>>
|
impl<V, I> Focus for Div<V, I, Focusable<V>>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
fn focus_listeners(&mut self) -> &mut FocusListeners<V> {
|
fn focus_listeners(&mut self) -> &mut FocusListeners<V> {
|
||||||
@@ -318,7 +319,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> Element for Div<V, I, F>
|
impl<V, I, F> Element for Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -326,7 +327,9 @@ where
|
|||||||
type ElementState = DivState;
|
type ElementState = DivState;
|
||||||
|
|
||||||
fn id(&self) -> Option<ElementId> {
|
fn id(&self) -> Option<ElementId> {
|
||||||
self.identity.id()
|
self.identity
|
||||||
|
.as_stateful()
|
||||||
|
.map(|identified| identified.id.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(
|
fn initialize(
|
||||||
@@ -456,7 +459,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> IntoAnyElement<V> for Div<V, I, F>
|
impl<V, I, F> IntoAnyElement<V> for Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -467,7 +470,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> ParentElement for Div<V, I, F>
|
impl<V, I, F> ParentElement for Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -478,7 +481,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> Styled for Div<V, I, F>
|
impl<V, I, F> Styled for Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -489,7 +492,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> Interactive for Div<V, I, F>
|
impl<V, I, F> Interactive for Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -500,7 +503,7 @@ where
|
|||||||
|
|
||||||
impl<V, I, F> Hover for Div<V, I, F>
|
impl<V, I, F> Hover for Div<V, I, F>
|
||||||
where
|
where
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -513,14 +516,14 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Click for Div<V, Identified, F>
|
impl<V, F> Click for Div<V, StatefulInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Active for Div<V, Identified, F>
|
impl<V, F> Active for Div<V, StatefulInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
div, Active, Anonymous, AnyElement, BorrowWindow, Bounds, Click, Div, DivState, Element,
|
div, Active, AnyElement, BorrowWindow, Bounds, Click, Div, DivState, Element,
|
||||||
ElementFocusability, ElementId, ElementIdentity, Focus, FocusListeners, Focusable, Hover,
|
ElementFocusability, ElementId, ElementInteractivity, Focus, FocusListeners, Focusable, Hover,
|
||||||
Identified, Interactive, Interactivity, IntoAnyElement, LayoutId, NonFocusable, Pixels,
|
Interactive, Interactivity, IntoAnyElement, LayoutId, NonFocusable, Pixels, SharedString,
|
||||||
SharedString, StyleRefinement, Styled, ViewContext,
|
StatefulInteractivity, StatelessInteractivity, StyleRefinement, Styled, ViewContext,
|
||||||
};
|
};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
pub struct Img<
|
pub struct Img<
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity = Anonymous,
|
I: ElementInteractivity<V> = StatelessInteractivity<V>,
|
||||||
F: ElementFocusability<V> = NonFocusable,
|
F: ElementFocusability<V> = NonFocusable,
|
||||||
> {
|
> {
|
||||||
base: Div<V, I, F>,
|
base: Div<V, I, F>,
|
||||||
@@ -17,7 +17,7 @@ pub struct Img<
|
|||||||
grayscale: bool,
|
grayscale: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn img<V>() -> Img<V, Anonymous, NonFocusable>
|
pub fn img<V>() -> Img<V, StatelessInteractivity<V>, NonFocusable>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ where
|
|||||||
impl<V, I, F> Img<V, I, F>
|
impl<V, I, F> Img<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
pub fn uri(mut self, uri: impl Into<SharedString>) -> Self {
|
pub fn uri(mut self, uri: impl Into<SharedString>) -> Self {
|
||||||
@@ -45,12 +45,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Img<V, Anonymous, F>
|
impl<V, F> Img<V, StatelessInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
pub fn id(self, id: impl Into<ElementId>) -> Img<V, Identified, F> {
|
pub fn id(self, id: impl Into<ElementId>) -> Img<V, StatefulInteractivity<V>, F> {
|
||||||
Img {
|
Img {
|
||||||
base: self.base.id(id),
|
base: self.base.id(id),
|
||||||
uri: self.uri,
|
uri: self.uri,
|
||||||
@@ -62,7 +62,7 @@ where
|
|||||||
impl<V, I, F> IntoAnyElement<V> for Img<V, I, F>
|
impl<V, I, F> IntoAnyElement<V> for Img<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn into_any(self) -> AnyElement<V> {
|
fn into_any(self) -> AnyElement<V> {
|
||||||
@@ -73,7 +73,7 @@ where
|
|||||||
impl<V, I, F> Element for Img<V, I, F>
|
impl<V, I, F> Element for Img<V, I, F>
|
||||||
where
|
where
|
||||||
V: Send + Sync + 'static,
|
V: Send + Sync + 'static,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
type ViewState = V;
|
type ViewState = V;
|
||||||
@@ -142,7 +142,7 @@ where
|
|||||||
impl<V, I, F> Styled for Img<V, I, F>
|
impl<V, I, F> Styled for Img<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn style(&mut self) -> &mut StyleRefinement {
|
fn style(&mut self) -> &mut StyleRefinement {
|
||||||
@@ -153,7 +153,7 @@ where
|
|||||||
impl<V, I, F> Interactive for Img<V, I, F>
|
impl<V, I, F> Interactive for Img<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn interactivity(&mut self) -> &mut Interactivity<V> {
|
fn interactivity(&mut self) -> &mut Interactivity<V> {
|
||||||
@@ -164,7 +164,7 @@ where
|
|||||||
impl<V, I, F> Hover for Img<V, I, F>
|
impl<V, I, F> Hover for Img<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||||
@@ -172,14 +172,14 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Click for Img<V, Identified, F>
|
impl<V, F> Click for Img<V, StatefulInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Active for Img<V, Identified, F>
|
impl<V, F> Active for Img<V, StatefulInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
@@ -192,7 +192,7 @@ where
|
|||||||
impl<V, I> Focus for Img<V, I, Focusable<V>>
|
impl<V, I> Focus for Img<V, I, Focusable<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
{
|
{
|
||||||
fn focus_listeners(&mut self) -> &mut FocusListeners<Self::ViewState> {
|
fn focus_listeners(&mut self) -> &mut FocusListeners<Self::ViewState> {
|
||||||
self.base.focus_listeners()
|
self.base.focus_listeners()
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
div, Active, Anonymous, AnyElement, Bounds, Click, Div, DivState, Element, ElementFocusability,
|
div, Active, AnyElement, Bounds, Click, Div, DivState, Element, ElementFocusability, ElementId,
|
||||||
ElementId, ElementIdentity, Focus, FocusListeners, Focusable, Hover, Identified, Interactive,
|
ElementInteractivity, Focus, FocusListeners, Focusable, Hover, Interactive, Interactivity,
|
||||||
Interactivity, IntoAnyElement, LayoutId, NonFocusable, Pixels, SharedString, StyleRefinement,
|
IntoAnyElement, LayoutId, NonFocusable, Pixels, SharedString, StatefulInteractivity,
|
||||||
Styled, ViewContext,
|
StatelessInteractivity, StyleRefinement, Styled, ViewContext,
|
||||||
};
|
};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
pub struct Svg<
|
pub struct Svg<
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity = Anonymous,
|
I: ElementInteractivity<V> = StatelessInteractivity<V>,
|
||||||
F: ElementFocusability<V> = NonFocusable,
|
F: ElementFocusability<V> = NonFocusable,
|
||||||
> {
|
> {
|
||||||
base: Div<V, I, F>,
|
base: Div<V, I, F>,
|
||||||
path: Option<SharedString>,
|
path: Option<SharedString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn svg<V>() -> Svg<V, Anonymous, NonFocusable>
|
pub fn svg<V>() -> Svg<V, StatelessInteractivity<V>, NonFocusable>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ where
|
|||||||
impl<V, I, F> Svg<V, I, F>
|
impl<V, I, F> Svg<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
pub fn path(mut self, path: impl Into<SharedString>) -> Self {
|
pub fn path(mut self, path: impl Into<SharedString>) -> Self {
|
||||||
@@ -37,12 +37,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Svg<V, Anonymous, F>
|
impl<V, F> Svg<V, StatelessInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
pub fn id(self, id: impl Into<ElementId>) -> Svg<V, Identified, F> {
|
pub fn id(self, id: impl Into<ElementId>) -> Svg<V, StatefulInteractivity<V>, F> {
|
||||||
Svg {
|
Svg {
|
||||||
base: self.base.id(id),
|
base: self.base.id(id),
|
||||||
path: self.path,
|
path: self.path,
|
||||||
@@ -53,7 +53,7 @@ where
|
|||||||
impl<V, I, F> IntoAnyElement<V> for Svg<V, I, F>
|
impl<V, I, F> IntoAnyElement<V> for Svg<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn into_any(self) -> AnyElement<V> {
|
fn into_any(self) -> AnyElement<V> {
|
||||||
@@ -64,7 +64,7 @@ where
|
|||||||
impl<V, I, F> Element for Svg<V, I, F>
|
impl<V, I, F> Element for Svg<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
type ViewState = V;
|
type ViewState = V;
|
||||||
@@ -116,7 +116,7 @@ where
|
|||||||
impl<V, I, F> Styled for Svg<V, I, F>
|
impl<V, I, F> Styled for Svg<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn style(&mut self) -> &mut StyleRefinement {
|
fn style(&mut self) -> &mut StyleRefinement {
|
||||||
@@ -127,7 +127,7 @@ where
|
|||||||
impl<V, I, F> Interactive for Svg<V, I, F>
|
impl<V, I, F> Interactive for Svg<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn interactivity(&mut self) -> &mut Interactivity<V> {
|
fn interactivity(&mut self) -> &mut Interactivity<V> {
|
||||||
@@ -138,7 +138,7 @@ where
|
|||||||
impl<V, I, F> Hover for Svg<V, I, F>
|
impl<V, I, F> Hover for Svg<V, I, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||||
@@ -146,14 +146,14 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Click for Svg<V, Identified, F>
|
impl<V, F> Click for Svg<V, StatefulInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, F> Active for Svg<V, Identified, F>
|
impl<V, F> Active for Svg<V, StatefulInteractivity<V>, F>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
F: ElementFocusability<V>,
|
F: ElementFocusability<V>,
|
||||||
@@ -166,7 +166,7 @@ where
|
|||||||
impl<V, I> Focus for Svg<V, I, Focusable<V>>
|
impl<V, I> Focus for Svg<V, I, Focusable<V>>
|
||||||
where
|
where
|
||||||
V: 'static + Send + Sync,
|
V: 'static + Send + Sync,
|
||||||
I: ElementIdentity,
|
I: ElementInteractivity<V>,
|
||||||
{
|
{
|
||||||
fn focus_listeners(&mut self) -> &mut FocusListeners<Self::ViewState> {
|
fn focus_listeners(&mut self) -> &mut FocusListeners<Self::ViewState> {
|
||||||
self.base.focus_listeners()
|
self.base.focus_listeners()
|
||||||
|
|||||||
Reference in New Issue
Block a user