cotis-layout 0.1.0-alpha.1

Flexbox-style layout engine for Cotis
Documentation
//! Reference layout engine for [Cotis](https://docs.rs/cotis) element trees.
//!
//! `cotis-layout` implements Cotis's [`LayoutManager`](cotis::layout::LayoutManager) and
//! [`LayoutFrameManager`](cotis::layout::LayoutFrameManager) traits. It runs a flexbox-like
//! sizing and positioning pass over a configured element tree and produces a stream of
//! [`RenderCommandOutput`](layout_struct::RenderCommandOutput) values for downstream pipes
//! (typically [`cotis-pipes`](https://docs.rs/cotis-pipes)) and renderers.
//!
//! # Frame lifecycle
//!
//! 1. Create a [`CotisLayoutManager`](preamble::CotisLayoutManager) with the viewport
//!    [`Dimensions`](cotis_utils::math::Dimensions).
//! 2. Wire it into a [`CotisApp`](cotis::cotis_app::CotisApp) with a renderer. The renderer
//!    supplies a text measurer and window dimensions via [`LayoutManagerCompatible`](cotis::layout::LayoutManagerCompatible).
//! 3. Each frame: `begin_frame()` returns a [`CotisLayoutRun`](preamble::CotisLayoutRun).
//! 4. UI code opens elements through [`ConfigureElements`](cotis::element_configuring::ConfigureElements)
//!    (`open_new_element`, `set_config`, `close_element`).
//! 5. Text leaves use [`ConfigureLeafElements`](cotis::element_configuring::ConfigureLeafElements)
//!    with [`TextElementConfig`](cotis_defaults::element_configs::text_config::TextElementConfig).
//! 6. `end()` runs layout (fit/grow/shrink, text wrap, positioning) and yields an iterator of
//!    [`RenderCommandOutput`](layout_struct::RenderCommandOutput).
//! 7. A pipe such as `CotisLayoutToRenderListPipeForGenerics` converts those commands into
//!    renderer-specific draw lists.
//!
//! # Quick start
//!
//! For a runnable desktop demo, use a renderer backend such as
//! [cotis-wgpu](https://github.com/igna-778/cotis-wgpu) or
//! [cotis-raylib](https://github.com/igna-778/cotis-raylib). Local examples under `examples/`
//! mirror the same wiring once ecosystem crates are on crates.io. A minimal setup looks like:
//!
//! ```rust,ignore
//! use cotis::cotis_app::CotisApp;
//! use cotis_layout::preamble::CotisLayoutManager;
//! use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
//! use cotis_utils::math::Dimensions;
//!
//! let dimensions = Dimensions::new(800.0, 600.0);
//! let manager = CotisLayoutManager::new(dimensions);
//! // let app = CotisApp::new(renderer, manager, CotisLayoutToRenderListPipeForGenerics);
//! ```
//!
//! # Modules
//!
//! - [`preamble`] — convenience re-exports: [`CotisLayoutManager`](preamble::CotisLayoutManager), [`CotisLayoutRun`](preamble::CotisLayoutRun),
//!   [`TextConfigurable`](preamble::TextConfigurable).
//! - [`layout_traits`] — [`CotisLayoutCompatible`](layout_traits::CotisLayoutCompatible), the bridge trait for custom config types.
//! - [`layout_struct`] — layout output types ([`RenderCommandOutput`](layout_struct::RenderCommandOutput), clip markers,
//!   [`TextDrawPayload`](layout_struct::TextDrawPayload)).
//! - [`cotis_traits`] — Cotis trait implementations for the default [`ElementConfig`](cotis_defaults::element_configs::ElementConfig)
//!   integration path and element-state query hooks.
//!
//! # Generic config types
//!
//! To use a config type other than `ElementConfig`, implement [`CotisLayoutCompatible`](layout_traits::CotisLayoutCompatible) to map
//! your type into the internal layout style representation, and [`TextConfigurable`](preamble::TextConfigurable) if your type
//! supports text leaves. Built-in wiring for `ElementConfig` lives in [`cotis_traits`].
//!
//! # Inspecting layout state
//!
//! After a frame completes, [`CotisLayoutManager::get_cache_element`](preamble::CotisLayoutManager::get_cache_element) exposes a snapshot of the
//! last layout tree for debugging and hit-testing. [`cotis_traits::secondary_traits`] implements
//! [`cotis_utils::element_state`] query traits on that cache.
//!
//! # Cargo features
//!
//! | Feature | Effect |
//! |---------|--------|
//! | `serialization` | Enables `serde` on render output types and serialization in `cotis`, `cotis-defaults`, and `cotis-utils`. |

pub(crate) mod layout_management;
pub mod layout_struct;

pub(crate) mod layout_algorithm;

pub(crate) mod text;

/// Entry-point re-exports for the layout manager and frame configurator.
///
/// Most applications use [`CotisLayoutManager`](crate::layout_management::CotisLayoutManager) as the `LayoutManager` type parameter on
/// [`CotisApp`](cotis::cotis_app::CotisApp) and interact with elements each frame through
/// [`CotisLayoutRun`](crate::layout_management::CotisLayoutRun) via the standard Cotis configuring traits (see [`crate::cotis_traits`]).
pub mod preamble {
    pub use crate::layout_management::CotisLayoutManager;
    pub use crate::layout_management::CotisLayoutRun;
    pub use crate::text::text_leafs::TextConfigurable;
}

pub mod layout_traits;

pub mod cotis_traits;