Get everything rendering again

This commit is contained in:
Nathan Sobo 2023-10-16 20:15:24 +02:00
parent 5e43c332f1
commit 1a3650ef2a
4 changed files with 12 additions and 43 deletions

View file

@ -154,6 +154,10 @@ impl Refineable for TextStyleRefinement {
self.underline = refinement.underline;
}
}
fn refined(self, refinement: Self::Refinement) -> Self {
todo!()
}
}
#[derive(JsonSchema)]

View file

@ -2,7 +2,7 @@ use crate::{
group_bounds, AnyElement, DispatchPhase, Element, IntoAnyElement, MouseMoveEvent, SharedString,
Style, StyleCascade, StyleRefinement,
};
use refineable::CascadeSlot;
use refineable::{CascadeSlot, Refineable};
use smallvec::SmallVec;
use std::sync::{
atomic::{AtomicBool, Ordering::SeqCst},
@ -237,7 +237,7 @@ impl<V: 'static + Send + Sync> Styled for LayoutNodeState<V> {
fn computed_style(&mut self) -> &Style {
self.computed_style
.get_or_insert_with(|| Style::from(self.style_cascade.merged()))
.get_or_insert_with(|| Style::default().refined(self.style_cascade.merged()))
}
}

View file

@ -7,10 +7,7 @@ pub trait Styled {
fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement;
fn computed_style(&mut self) -> Self::Style {
todo!()
// let x: StyleRefinement = self.style_cascade().merged();
// x.into();
Self::Style::default().refined(self.style_cascade().merged())
}
fn hover(self) -> Hoverable<Self>

View file

@ -157,7 +157,7 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
})
.collect();
let refinement_refined_assigments: Vec<TokenStream2> = fields
let refinement_refined_assignments: Vec<TokenStream2> = fields
.iter()
.map(|field| {
let name = &field.ident;
@ -169,37 +169,14 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
}
} else {
quote! {
if let Some(value) = refinement.#name {
self.#name = Some(value);
if refinement.#name.is_some() {
self.#name = refinement.#name;
}
}
}
})
.collect();
let from_refinement_assigments: Vec<TokenStream2> = fields
.iter()
.map(|field| {
let name = &field.ident;
let is_refineable = is_refineable_field(field);
let is_optional = is_optional_field(field);
if is_refineable {
quote! {
#name: value.#name.into(),
}
} else if is_optional {
quote! {
#name: value.#name.map(|v| v.into()),
}
} else {
quote! {
#name: value.#name.map(|v| v.into()).unwrap_or_default(),
}
}
})
.collect();
let debug_impl = if impl_debug_on_refinement {
let refinement_field_debugs: Vec<TokenStream2> = fields
.iter()
@ -266,21 +243,11 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
}
fn refined(mut self, refinement: Self::Refinement) -> Self {
#( #refinement_refined_assigments )*
#( #refinement_refined_assignments )*
self
}
}
impl #impl_generics From<#refinement_ident #ty_generics> for #ident #ty_generics
#where_clause
{
fn from(value: #refinement_ident #ty_generics) -> Self {
Self {
#( #from_refinement_assigments )*
}
}
}
impl #impl_generics ::core::default::Default for #refinement_ident #ty_generics
#where_clause
{
@ -306,6 +273,7 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
#debug_impl
};
gen.into()
}