1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Bridge trait connecting custom element config types to the layout engine.
//!
//! Any config type `T` used with [`CotisLayoutManager`](crate::preamble::CotisLayoutManager) as
//! `LayoutManager<T, RenderCommandOutput<T>>` must implement [`CotisLayoutCompatible`]. The
//! built-in implementation for [`ElementConfig`](cotis_defaults::element_configs::ElementConfig)
//! lives in [`crate::cotis_traits`].
use crateLayoutElementConfig;
use ElementId;
use OwnedOrRef;
/// Maps a user-facing element config into layout-engine data.
///
/// Called when [`ConfigureElements::set_config`](cotis::element_configuring::ConfigureElements::set_config)
/// is invoked on a [`CotisLayoutRun`](crate::preamble::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`](crate::preamble::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);
/// ```