Skip to main content

TextConfigurable

Trait TextConfigurable 

Source
pub trait TextConfigurable: Sized {
    // Required method
    fn synthetic_text_child(
        &self,
        layout_direction: LayoutDirection,
        child_gap: f32,
        width: AxisSizing,
        height: AxisSizing,
    ) -> Self;
}
Expand description

A configuration that can spawn transparent synthetic children used to lay out text.

Each line, word, and inter-word spacer of a text leaf becomes one of these children, so the layout engine can size and wrap them while keeping the real config type generic.

Implement this trait alongside CotisLayoutCompatible for custom config types that support ConfigureLeafElements with TextElementConfig.

The built-in implementation for ElementConfig strips background, border, and padding from the parent style so synthetic nodes contribute layout size only, not visuals.

§Examples

use cotis_defaults::element_configs::ElementConfig;
use cotis_defaults::element_configs::style::sizing::AxisSizing;
use cotis_defaults::element_configs::style::types::LayoutDirection;
use cotis_layout::preamble::TextConfigurable;

let parent: ElementConfig<'_, _, _, _, _> = /* ... */;
let child = parent.synthetic_text_child(
    LayoutDirection::LeftToRight,
    4.0,
    AxisSizing::Fixed(100.0),
    AxisSizing::Fixed(20.0),
);
// child has transparent background and zero padding

Required Methods§

Source

fn synthetic_text_child( &self, layout_direction: LayoutDirection, child_gap: f32, width: AxisSizing, height: AxisSizing, ) -> Self

Build a transparent, border-less, padding-less child derived from this (parent) config.

Called when expanding text leaves into line, word, and spacer nodes. The returned config is opened as a synthetic child with the given layout direction, gap, and axis sizing.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

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

Source§

fn synthetic_text_child( &self, layout_direction: LayoutDirection, child_gap: f32, width: AxisSizing, height: AxisSizing, ) -> Self

Source§

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

Source§

fn synthetic_text_child( &self, layout_direction: LayoutDirection, child_gap: f32, width: AxisSizing, height: AxisSizing, ) -> Self

Implementors§