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:
- math types such as
math::Vector2andmath::BoundingBox - renderer frame/window contracts in
traits - keyboard and mouse provider traits in
interactivity - text measuring hooks in
text - font registry helpers in
font_manager - runtime element inspection traits in
element_state
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: enablesserdederives formathstructs (Vector2,Dimensions, andBoundingBox).
§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.