cotis-modules-debug 0.1.0-alpha

Record, replay, and isolate Cotis layout and UI declaration pipelines
Documentation
//! Stage 2 of the debug pipeline: replay a stored UI declaration through a normal app.

use cotis::cotis_app::UiFn;
use cotis::element_configuring::{ConfigureElements, ConfiguredParentElement};
use cotis::utils::ElementIdConfig;
use cotis_defaults::colors::Color;
use cotis_defaults::element_configs::style::sizing::AxisSizing::{Fit, Grow};
use cotis_defaults::element_configs::style::sizing::{AxisSizing, DoubleAxisSizing, Sizing};
use cotis_defaults::element_configs::style::types::{
    Alignment, LayoutAlignmentX, LayoutAlignmentY, LayoutDirection, Padding,
};
use cotis_defaults::element_configs::style::{
    BorderElementStyle, BorderWidthStyle, CornerRadiiStyle, CotisStyle, LayoutStyle,
};
use cotis_defaults::element_configs::text_config::{
    TextAlignment, TextConfig, TextElementConfig, TextElementConfigWrapMode, TextStyle,
};
use cotis_modules_debug::declaration_debugger::debug_element_configuring::{
    DebugConfiguredParentElement, DebugInitialConfiguredParentElement,
};
use cotis_modules_debug::serialize_targets::leaf_serialization::{
    LeafConfigList, LeafConfigListNil,
};
use cotis_modules_debug::serialize_targets::{
    LeafedInterfaceDeclaration, SerializedInterfaceDeclaration,
};
use cotis_raylib::prelude::RaylibRender;
use raylib::consts::TextureFilter;

#[path = "common/support.rs"]
mod support;
use support::{ExampleConfig, SimpleRenderCmds, compute_frame, example_path, new_cotis_app};

type ListOfLeafs = LeafConfigList<TextElementConfig<'static>, LeafConfigListNil>;

fn main() {
    let replay = LeafedInterfaceDeclaration::<_, ListOfLeafs>::load_from(
        example_path("examples/interface_gradients_solid_example.json").as_path(),
        ListOfLeafs::new(),
    )
    .unwrap();
    test_entry(RaylibRender::auto_start(), replay);
}

fn test_entry(
    mut renderer: RaylibRender,
    replay: LeafedInterfaceDeclaration<ExampleConfig, ListOfLeafs>,
) {
    let mut app = new_cotis_app(renderer, cotis_utils::math::Dimensions::new(920.0, 640.0));
    let font_path = example_path("examples/fonts/Roboto-Regular.ttf");
    let _font = app
        .render()
        .load_font_ex_and_keep(
            font_path.to_str().expect("font path must be valid UTF-8"),
            24,
            None,
            Some(TextureFilter::TEXTURE_FILTER_BILINEAR),
        )
        .unwrap();
    while !app.render().window_should_close() {
        compute_frame::<SimpleRenderCmds, _>(&mut app, &replay);
    }
}