Still need to wire up MouseMove with the new regions

This commit is contained in:
Nathan Sobo 2023-08-18 02:23:06 -06:00
parent 3709eff34b
commit b910c85f7f
7 changed files with 82 additions and 33 deletions

View file

@ -419,7 +419,7 @@ pub trait Element<V: 'static>: 'static {
self
}
fn hoverable(self) -> Hoverable<V, Self>
fn hover(self) -> Hoverable<V, Self>
where
Self: Sized,
{
@ -443,6 +443,18 @@ pub trait Element<V: 'static>: 'static {
}
}
pub trait ParentElement<V: 'static>: Element<V> {
fn child(self, child: impl IntoElement<V>) -> Self
where
Self: Sized;
fn children<I, E>(self, children: I) -> Self
where
Self: Sized,
I: IntoIterator<Item = E>,
E: IntoElement<V>;
}
// Object-safe counterpart of Element used by AnyElement to store elements as trait objects.
trait ElementObject<V> {
fn declared_style(&mut self) -> &mut StyleRefinement;
@ -516,19 +528,6 @@ impl<V: 'static> AnyElement<V> {
Ok(node_id)
}
pub fn push_text_style<'a: 'b, 'b>(&mut self, cx: &mut impl RenderContext<'a, 'b, V>) -> bool {
let text_style = self
.element
.computed_style(cx.as_view_context())
.text_style();
if let Some(text_style) = text_style {
cx.push_text_style(cx.text_style().refined(&text_style));
true
} else {
false
}
}
pub fn paint(&mut self, view: &mut V, cx: &mut PaintContext<V>) -> Result<()> {
let pushed_text_style = self.push_text_style(cx);
@ -586,6 +585,19 @@ impl<V: 'static> AnyElement<V> {
Ok(())
}
fn push_text_style<'a: 'b, 'b>(&mut self, cx: &mut impl RenderContext<'a, 'b, V>) -> bool {
let text_style = self
.element
.computed_style(cx.as_view_context())
.text_style();
if let Some(text_style) = text_style {
cx.push_text_style(cx.text_style().refined(&text_style));
true
} else {
false
}
}
}
impl<V: 'static> Element<V> for AnyElement<V> {