Checkpoint
This commit is contained in:
@@ -1,13 +1,25 @@
|
||||
use crate::StyleRefinement;
|
||||
use crate::{SharedString, StyleRefinement};
|
||||
|
||||
pub trait Active {
|
||||
fn set_active_style(&mut self, style: StyleRefinement);
|
||||
fn set_active_style(&mut self, group_name: Option<SharedString>, style: StyleRefinement);
|
||||
|
||||
fn active(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.set_active_style(f(StyleRefinement::default()));
|
||||
self.set_active_style(None, f(StyleRefinement::default()));
|
||||
self
|
||||
}
|
||||
|
||||
fn group_active(
|
||||
mut self,
|
||||
group_name: impl Into<SharedString>,
|
||||
f: impl FnOnce(StyleRefinement) -> StyleRefinement,
|
||||
) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.set_active_style(Some(group_name.into()), f(StyleRefinement::default()));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,16 +386,16 @@ where
|
||||
);
|
||||
this.paint_event_listeners(bounds, element_state.pending_click.clone(), cx);
|
||||
});
|
||||
});
|
||||
|
||||
style.apply_text_style(cx, |cx| {
|
||||
style.apply_overflow(bounds, cx, |cx| {
|
||||
cx.stack(z_index + 1, |cx| {
|
||||
for child in &mut this.children {
|
||||
child.paint(view_state, None, cx);
|
||||
}
|
||||
cx.stack(1, |cx| {
|
||||
style.apply_text_style(cx, |cx| {
|
||||
style.apply_overflow(bounds, cx, |cx| {
|
||||
for child in &mut this.children {
|
||||
child.paint(view_state, None, cx);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
if let Some(group) = this.group.as_ref() {
|
||||
@@ -454,8 +454,12 @@ where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
{
|
||||
fn set_hover_style(&mut self, style: StyleRefinement) {
|
||||
self.hover_style = style;
|
||||
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
if let Some(group) = group {
|
||||
self.group_hover = Some(GroupStyle { group, style });
|
||||
} else {
|
||||
self.hover_style = style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,8 +469,12 @@ impl<V> Active for Div<V, IdentifiedElement>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
fn set_active_style(&mut self, style: StyleRefinement) {
|
||||
self.active_style = style;
|
||||
fn set_active_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
if let Some(group) = group {
|
||||
self.group_active = Some(GroupStyle { group, style });
|
||||
} else {
|
||||
self.active_style = style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ where
|
||||
element_state: &mut Self::ElementState,
|
||||
cx: &mut ViewContext<Self::ViewState>,
|
||||
) {
|
||||
cx.stack(1, |cx| {
|
||||
cx.stack(0, |cx| {
|
||||
self.base.paint(bounds, view, element_state, cx);
|
||||
});
|
||||
|
||||
@@ -146,8 +146,8 @@ where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
{
|
||||
fn set_hover_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_hover_style(style);
|
||||
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
self.base.set_hover_style(group, style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ impl<V> Active for Img<V, IdentifiedElement>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
fn set_active_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_active_style(style)
|
||||
fn set_active_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
self.base.set_active_style(group, style)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ where
|
||||
V: 'static + Send + Sync,
|
||||
K: ElementIdentity,
|
||||
{
|
||||
fn set_hover_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_hover_style(style);
|
||||
fn set_hover_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
self.base.set_hover_style(group, style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ impl<V> Active for Svg<V, IdentifiedElement>
|
||||
where
|
||||
V: 'static + Send + Sync,
|
||||
{
|
||||
fn set_active_style(&mut self, style: StyleRefinement) {
|
||||
self.base.set_active_style(style)
|
||||
fn set_active_style(&mut self, group: Option<SharedString>, style: StyleRefinement) {
|
||||
self.base.set_active_style(group, style)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
use crate::StyleRefinement;
|
||||
use crate::{SharedString, StyleRefinement};
|
||||
|
||||
pub trait Hover {
|
||||
fn set_hover_style(&mut self, style: StyleRefinement);
|
||||
fn set_hover_style(&mut self, group_name: Option<SharedString>, style: StyleRefinement);
|
||||
|
||||
fn hover(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.set_hover_style(f(StyleRefinement::default()));
|
||||
self.set_hover_style(None, f(StyleRefinement::default()));
|
||||
self
|
||||
}
|
||||
|
||||
fn group_hover(
|
||||
mut self,
|
||||
group_name: impl Into<SharedString>,
|
||||
f: impl FnOnce(StyleRefinement) -> StyleRefinement,
|
||||
) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.set_hover_style(Some(group_name.into()), f(StyleRefinement::default()));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::{
|
||||
black, phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask,
|
||||
Corners, CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures,
|
||||
FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result,
|
||||
SharedString, Size, SizeRefinement, TextRun, ViewContext, WindowContext,
|
||||
SharedString, Size, SizeRefinement, Styled, TextRun, ViewContext, WindowContext,
|
||||
};
|
||||
use refineable::{Cascade, Refineable};
|
||||
use smallvec::SmallVec;
|
||||
@@ -101,6 +101,12 @@ pub struct Style {
|
||||
pub z_index: Option<u32>,
|
||||
}
|
||||
|
||||
impl Styled for StyleRefinement {
|
||||
fn style(&mut self) -> &mut StyleRefinement {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BoxShadow {
|
||||
pub color: Hsla,
|
||||
|
||||
@@ -1167,7 +1167,13 @@ impl From<i32> for ElementId {
|
||||
}
|
||||
|
||||
impl From<SharedString> for ElementId {
|
||||
fn from(id: SharedString) -> Self {
|
||||
ElementId::Name(id)
|
||||
fn from(name: SharedString) -> Self {
|
||||
ElementId::Name(name)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&'static str> for ElementId {
|
||||
fn from(name: &'static str) -> Self {
|
||||
ElementId::Name(name.into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user