use cotis::cotis_app::{CotisApp, RenderApp, UiFn};
use cotis::utils::ElementIdConfig;
use cotis_defaults::element_configs::image_config::ImageConfig;
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, ClipEnd, ClipStart, Image, Rectangle, Text};
use cotis_layout::layout_struct::RenderCommandOutput;
use cotis_layout::preamble::CotisLayoutManager;
use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
use cotis_raylib::cotis_defaults_images::{JPEGImage, PNGImage, PathBasedImage, SVGImage};
use cotis_raylib::prelude::RaylibRender;
use cotis_utils::math::Dimensions;
pub type ExampleConfig = GenericElementConfig<'static, PathBasedImage, ()>;
pub type StandardRenderCmds = RenderTList<
ClipStart<'static, ()>,
RenderTList<
ClipEnd,
RenderTList<
Rectangle<'static, ()>,
RenderTList<
Image<'static, PathBasedImage, ()>,
RenderTList<Border<'static, ()>, RenderTList<Text<'static, ()>, ()>>,
>,
>,
>,
>;
pub type SimpleRenderCmds = RenderTList<
Rectangle<'static, ()>,
RenderTList<
Image<'static, PathBasedImage, ()>,
RenderTList<Border<'static, ()>, RenderTList<Text<'static, ()>, ()>>,
>,
>;
pub type ExampleCotisApp =
CotisApp<RaylibRender, CotisLayoutManager, CotisLayoutToRenderListPipeForGenerics>;
pub fn new_cotis_app(renderer: RaylibRender, dimensions: Dimensions) -> ExampleCotisApp {
let manager = CotisLayoutManager::new(dimensions);
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 image_config(image: PathBasedImage) -> ImageConfig<'static, PathBasedImage> {
ImageConfig::new_owned(image)
}
pub mod example_images {
use super::{JPEGImage, PNGImage, PathBasedImage, SVGImage};
pub fn apple_png() -> PathBasedImage {
PathBasedImage::Png(PNGImage::new_const("./examples/Apple.png"))
}
pub fn calendar_png() -> PathBasedImage {
PathBasedImage::Png(PNGImage::new_const("./examples/calendar_icon_2.png"))
}
pub fn apple_jpeg() -> PathBasedImage {
PathBasedImage::Jpeg(JPEGImage::new_const("./examples/Apple.png"))
}
pub fn calendar_svg() -> PathBasedImage {
PathBasedImage::Svg(SVGImage::new_const("./examples/calendar_icon_2.png"))
}
}
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);
}