Skip to main content

CustomStyleProperty

Trait CustomStyleProperty 

Source
pub trait CustomStyleProperty:
    'static
    + Send
    + Sync {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn eq_property(&self, other: &dyn CustomStyleProperty) -> bool;
}
Expand description

A style property defined outside of GPUI’s core style structs.

Engines and forks carry their own rendering extensions - a backdrop blur radius, a custom shader’s parameters - through the style cascade by defining a type and setting it with Styled::custom_style, rather than adding a field to Style that every consumer of this crate has to know about.

The type itself keys the property, so a reader recovers exactly the type that was set. Any Send + Sync + PartialEq + 'static type is a custom property as-is; there is nothing to implement. Properties must be PartialEq because merging and subtracting style refinements diffs them.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Upcasts to Any so CustomStyles::get can recover the concrete type.

Source

fn eq_property(&self, other: &dyn CustomStyleProperty) -> bool

Compares two properties that share a concrete type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: 'static + Send + Sync + PartialEq> CustomStyleProperty for T