Skip to main content

Crate cotis_utils

Crate cotis_utils 

Source
Expand description

Shared utility types and trait boundaries for the Cotis ecosystem.

This crate contains cross-cutting primitives used by layout managers, renderers, and interactivity layers:

Unlike cotis, this crate does not define app orchestration or layout/renderer interfaces. Unlike cotis-defaults, it does not define concrete element config or render command structs.

§Features

  • serialization: enables serde derives for math structs (Vector2, Dimensions, and BoundingBox).

§Text and fonts (evolving API)

The text, font, and text-measuring APIs are functional today but are planned for refactoring. Integrators should treat font_id assignment, font_manager::FontManager, text::RendererTextMeasuringProvider, and text::LayoutTextMeasuring as subject to change across minor versions until that refactor lands.

§Quick start

use cotis_utils::interactivity::mouse::{MouseButton, MouseProvider};
use cotis_utils::math::{Dimensions, Vector2};
use cotis_utils::traits::{CotisFrameContext, CotisRenderContext, CotisWindowContext};

struct MyRenderer;

impl CotisWindowContext for MyRenderer {
    fn window_dimensions(&self) -> Dimensions {
        Dimensions::new(1280.0, 720.0)
    }
}

impl CotisFrameContext for MyRenderer {
    fn get_delta_time(&self) -> f32 {
        1.0 / 60.0
    }
}

// CotisRenderContext is implemented automatically.

impl MouseProvider for MyRenderer {
    fn get_mouse_position(&self) -> Vector2 {
        Vector2::new(0.0, 0.0)
    }

    fn mouse_button_down(&self, _button: MouseButton) -> bool {
        false
    }

    fn get_mouse_wheel_move_v(&self) -> Vector2 {
        Vector2::new(0.0, 0.0)
    }
}

Modules§

element_state
Element-state query traits used by hit-testing and debug tools.
font_manager
Thread-safe font registry and holder abstractions. Thread-safe font registry abstractions.
interactivity
Keyboard/mouse input traits and key/button enums. Input provider traits used by Cotis integrations.
math
Math primitives used by layout, rendering and input providers.
text
Text measurement provider traits shared by layout and renderers. Text measurement traits shared between layout and renderer crates.
traits
Renderer context traits for window state and frame timing.