Checkpoint
This commit is contained in:
@@ -60,7 +60,7 @@ impl ScrollState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn div<V>() -> Div<Anonymous, NonFocusable, V>
|
||||
pub fn div<V>() -> Div<V, Anonymous, NonFocusable>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
@@ -81,7 +81,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Div<I: ElementIdentity, F: ElementFocusability, V: 'static + Send + Sync> {
|
||||
pub struct Div<V: 'static + Send + Sync, I: ElementIdentity, F: ElementFocusability> {
|
||||
identity: I,
|
||||
focusability: F,
|
||||
children: SmallVec<[AnyElement<V>; 2]>,
|
||||
@@ -102,12 +102,12 @@ struct GroupStyle {
|
||||
style: StyleRefinement,
|
||||
}
|
||||
|
||||
impl<F, V> Div<Anonymous, F, V>
|
||||
impl<V, F> Div<V, Anonymous, F>
|
||||
where
|
||||
F: ElementFocusability,
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
pub fn id(self, id: impl Into<ElementId>) -> Div<Identified, F, V> {
|
||||
pub fn id(self, id: impl Into<ElementId>) -> Div<V, Identified, F> {
|
||||
Div {
|
||||
identity: Identified(id.into()),
|
||||
focusability: self.focusability,
|
||||
@@ -126,7 +126,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> Div<I, F, V>
|
||||
impl<V, I, F> Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -341,12 +341,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, V> Div<I, NonFocusable, V>
|
||||
impl<V, I> Div<V, I, NonFocusable>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
pub fn focusable(self, handle: &FocusHandle) -> Div<I, Focusable, V> {
|
||||
pub fn focusable(self, handle: &FocusHandle) -> Div<V, I, Focusable> {
|
||||
Div {
|
||||
identity: self.identity,
|
||||
focusability: handle.clone().into(),
|
||||
@@ -365,7 +365,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, V> Focus for Div<I, Focusable, V>
|
||||
impl<V, I> Focus for Div<V, I, Focusable>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
V: 'static + Send + Sync,
|
||||
@@ -387,7 +387,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> Element for Div<I, F, V>
|
||||
impl<V, I, F> Element for Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -502,7 +502,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> IntoAnyElement<V> for Div<I, F, V>
|
||||
impl<V, I, F> IntoAnyElement<V> for Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -513,7 +513,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> ParentElement for Div<I, F, V>
|
||||
impl<V, I, F> ParentElement for Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -524,7 +524,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> Styled for Div<I, F, V>
|
||||
impl<V, I, F> Styled for Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -535,7 +535,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> Interactive for Div<I, F, V>
|
||||
impl<V, I, F> Interactive for Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -546,7 +546,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, F, V> Hover for Div<I, F, V>
|
||||
impl<V, I, F> Hover for Div<V, I, F>
|
||||
where
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
@@ -561,14 +561,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, V> Click for Div<Identified, F, V>
|
||||
impl<V, F> Click for Div<V, Identified, F>
|
||||
where
|
||||
F: ElementFocusability,
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
}
|
||||
|
||||
impl<F, V> Active for Div<Identified, F, V>
|
||||
impl<V, F> Active for Div<V, Identified, F>
|
||||
where
|
||||
F: ElementFocusability,
|
||||
V: 'static + Send + Sync,
|
||||
|
||||
@@ -7,7 +7,7 @@ use futures::FutureExt;
|
||||
use util::ResultExt;
|
||||
|
||||
pub struct Img<V: 'static + Send + Sync, K: ElementIdentity = Anonymous> {
|
||||
base: Div<K, NonFocusable, V>,
|
||||
base: Div<V, K, NonFocusable>,
|
||||
uri: Option<SharedString>,
|
||||
grayscale: bool,
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
use crate::{
|
||||
div, Active, Anonymous, AnyElement, Bounds, Click, Div, DivState, Element, ElementId,
|
||||
ElementIdentity, EventListeners, Hover, Identified, Interactive, IntoAnyElement, LayoutId,
|
||||
NonFocusable, Pixels, SharedString, StyleRefinement, Styled, ViewContext,
|
||||
div, Active, Anonymous, AnyElement, Bounds, Click, Div, DivState, Element, ElementFocusability,
|
||||
ElementId, ElementIdentity, EventListeners, Focus, Focusable, Hover, Identified, Interactive,
|
||||
IntoAnyElement, LayoutId, NonFocusable, Pixels, SharedString, StyleRefinement, Styled,
|
||||
ViewContext,
|
||||
};
|
||||
use util::ResultExt;
|
||||
|
||||
pub struct Svg<V: 'static + Send + Sync, K: ElementIdentity = Anonymous> {
|
||||
base: Div<K, NonFocusable, V>,
|
||||
pub struct Svg<V: 'static + Send + Sync, I: ElementIdentity, F: ElementFocusability> {
|
||||
base: Div<V, I, F>,
|
||||
path: Option<SharedString>,
|
||||
}
|
||||
|
||||
pub fn svg<V>() -> Svg<V, Anonymous>
|
||||
pub fn svg<V>() -> Svg<V, Anonymous, NonFocusable>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
@@ -20,10 +21,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, K> Svg<V, K>
|
||||
impl<V, I, F> Svg<V, I, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
pub fn path(mut self, path: impl Into<SharedString>) -> Self {
|
||||
self.path = Some(path.into());
|
||||
@@ -31,8 +33,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: 'static + Send + Sync> Svg<V, Anonymous> {
|
||||
pub fn id(self, id: impl Into<ElementId>) -> Svg<V, Identified> {
|
||||
impl<V, F> Svg<V, Anonymous, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
pub fn id(self, id: impl Into<ElementId>) -> Svg<V, Identified, F> {
|
||||
Svg {
|
||||
base: self.base.id(id),
|
||||
path: self.path,
|
||||
@@ -40,20 +46,22 @@ impl<V: 'static + Send + Sync> Svg<V, Anonymous> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, K> IntoAnyElement<V> for Svg<V, K>
|
||||
impl<V, I, F> IntoAnyElement<V> for Svg<V, I, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<V> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, K> Element for Svg<V, K>
|
||||
impl<V, I, F> Element for Svg<V, I, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
type ViewState = V;
|
||||
type ElementState = DivState;
|
||||
@@ -101,43 +109,74 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, K> Styled for Svg<V, K>
|
||||
impl<V, I, F> Styled for Svg<V, I, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
fn style(&mut self) -> &mut StyleRefinement {
|
||||
self.base.style()
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, K> Interactive for Svg<V, K>
|
||||
impl<V, I, F> Interactive for Svg<V, I, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
fn listeners(&mut self) -> &mut EventListeners<V> {
|
||||
self.base.listeners()
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, K> Hover for Svg<V, K>
|
||||
impl<V, I, F> Hover for Svg<V, I, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
I: ElementIdentity,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
self.base.set_hover_style(group, style);
|
||||
}
|
||||
}
|
||||
|
||||
impl<V> Click for Svg<V, Identified> where V: 'static + Send + Sync {}
|
||||
|
||||
impl<V> Active for Svg<V, Identified>
|
||||
impl<V, F> Click for Svg<V, Identified, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
}
|
||||
|
||||
impl<V, F> Active for Svg<V, Identified, F>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
F: ElementFocusability,
|
||||
{
|
||||
fn set_active_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
self.base.set_active_style(group, style)
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, I> Focus for Svg<V, I, Focusable>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
I: ElementIdentity,
|
||||
{
|
||||
fn set_focus_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_focus_style(style)
|
||||
}
|
||||
|
||||
fn set_focus_in_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_focus_in_style(style)
|
||||
}
|
||||
|
||||
fn set_in_focus_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_in_focus_style(style)
|
||||
}
|
||||
|
||||
fn handle(&self) -> &crate::FocusHandle {
|
||||
self.base.handle()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user