Skip to main content

CotisLayoutCompatible

Trait CotisLayoutCompatible 

Source
pub trait CotisLayoutCompatible<'name> {
    // Required methods
    fn get_style(&self) -> LayoutElementConfig;
    fn get_id(&self) -> ElementId;
    fn try_get_name(&self) -> Option<OwnedOrRef<'name, str>>;
}
Expand description

Maps a user-facing element config into layout-engine data.

Called when ConfigureElements::set_config is invoked on a CotisLayoutRun. The layout style is extracted and stored on the internal tree node; the original config is retained for render command emission.

Custom config authors typically implement this alongside TextConfigurable when text leaves are needed.

§Examples

use cotis::utils::ElementIdConfig;
use cotis_layout::layout_traits::CotisLayoutCompatible;
use cotis_defaults::element_configs::premade_configs::GenericElementConfig;

type MyConfig = GenericElementConfig<'static, (), ()>;

let config = MyConfig {
    id_config: ElementIdConfig::new_empty(),
    style: Default::default(),
    image: None,
    custom: None,
    extra_data: None,
};

let _id = CotisLayoutCompatible::get_id(&config);
let _name = CotisLayoutCompatible::try_get_name(&config);

Required Methods§

Source

fn get_style(&self) -> LayoutElementConfig

Layout style derived from this config (padding, sizing, clip, float, etc.).

Source

fn get_id(&self) -> ElementId

Stable element identifier used for tree nodes and render commands.

Source

fn try_get_name(&self) -> Option<OwnedOrRef<'name, str>>

Optional debug name appended to the internal layout node.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<'frame, I, C, E> CotisLayoutCompatible<'frame> for ElementConfig<'frame, DoubleAxisSizing, I, C, E>

Source§

fn get_style(&self) -> LayoutElementConfig

Source§

fn get_id(&self) -> ElementId

Source§

fn try_get_name(&self) -> Option<OwnedOrRef<'frame, str>>

Source§

impl<'frame, I, C, E> CotisLayoutCompatible<'frame> for ElementConfig<'frame, Sizing, I, C, E>

Source§

fn get_style(&self) -> LayoutElementConfig

Source§

fn get_id(&self) -> ElementId

Source§

fn try_get_name(&self) -> Option<OwnedOrRef<'frame, str>>

Implementors§