use std::path::PathBuf;
use cotis::cotis_app::{CotisApp, RenderApp, UiFn};
use cotis::utils::ElementIdConfig;
use cotis_defaults::element_configs::premade_configs::GenericElementConfig;
use cotis_defaults::element_configs::style::CotisStyle;
use cotis_defaults::render_commands::render_t_list::RenderTList;
use cotis_defaults::render_commands::{Border, Rectangle, Text};
use cotis_layout::layout_struct::RenderCommandOutput;
use cotis_layout::preamble::CotisLayoutManager;
use cotis_modules_debug::layout_module_debugger::capture::LayoutModuleCapture;
use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
use cotis_raylib::prelude::RaylibRender;
use cotis_utils::math::Dimensions;
pub fn example_path(rel: &str) -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(rel)
}
pub type ExampleConfig = GenericElementConfig<'static, (), ()>;
pub type SimpleRenderCmds = RenderTList<
Rectangle<'static, ()>,
RenderTList<Border<'static, ()>, RenderTList<Text<'static, ()>, ()>>,
>;
pub type ExampleCotisApp =
CotisApp<RaylibRender, CotisLayoutManager, CotisLayoutToRenderListPipeForGenerics>;
pub type ExampleCotisAppDBG = CotisApp<
RaylibRender,
LayoutModuleCapture<CotisLayoutManager, RenderCommandOutput<ExampleConfig>>,
CotisLayoutToRenderListPipeForGenerics,
>;
pub fn new_cotis_app(renderer: RaylibRender, dimensions: Dimensions) -> ExampleCotisApp {
let manager = CotisLayoutManager::new(dimensions);
CotisApp::new(renderer, manager, CotisLayoutToRenderListPipeForGenerics)
}
pub fn new_cotis_app_dbg(renderer: RaylibRender, dimensions: Dimensions) -> ExampleCotisAppDBG {
let manager = CotisLayoutManager::new(dimensions);
let manager = LayoutModuleCapture::new(manager);
CotisApp::new(renderer, manager, CotisLayoutToRenderListPipeForGenerics)
}
pub fn empty_example_config() -> ExampleConfig {
ExampleConfig {
id_config: ElementIdConfig::new_empty(),
style: CotisStyle::default(),
image: None,
custom: None,
extra_data: None,
}
}
pub fn compute_frame<'layout, Cmds, Ui>(app: &'layout mut ExampleCotisApp, ui: Ui)
where
RaylibRender: cotis::renders::CotisRenderer<Cmds>,
CotisLayoutToRenderListPipeForGenerics:
cotis::pipes::LayoutRenderPipe<RenderCommandOutput<ExampleConfig>, Cmds>,
Ui: for<'a> UiFn<
'a,
cotis_layout::preamble::CotisLayoutRun<'layout, ExampleConfig>,
ExampleConfig,
>,
{
RenderApp::<
ExampleConfig,
RenderCommandOutput<ExampleConfig>,
Cmds,
RaylibRender,
CotisLayoutManager,
>::compute_frame(app, ui);
}
pub fn compute_frame_dbg<'layout, Cmds, Ui>(app: &'layout mut ExampleCotisAppDBG, ui: Ui)
where
RaylibRender: cotis::renders::CotisRenderer<Cmds>,
CotisLayoutToRenderListPipeForGenerics:
cotis::pipes::LayoutRenderPipe<RenderCommandOutput<ExampleConfig>, Cmds>,
Ui: for<'a> UiFn<
'a,
cotis_layout::preamble::CotisLayoutRun<'layout, ExampleConfig>,
ExampleConfig,
>,
{
RenderApp::<
ExampleConfig,
RenderCommandOutput<ExampleConfig>,
Cmds,
RaylibRender,
LayoutModuleCapture<CotisLayoutManager, RenderCommandOutput<ExampleConfig>>,
>::compute_frame(app, ui);
}