Skip to main content

cotis_utils/
lib.rs

1//! Shared utility types and trait boundaries for the Cotis ecosystem.
2//!
3//! This crate contains cross-cutting primitives used by layout managers, renderers,
4//! and interactivity layers:
5//! - math types such as [`math::Vector2`] and [`math::BoundingBox`]
6//! - renderer frame/window contracts in [`traits`]
7//! - keyboard and mouse provider traits in [`interactivity`]
8//! - text measuring hooks in [`text`]
9//! - font registry helpers in [`font_manager`]
10//! - runtime element inspection traits in [`element_state`]
11//!
12//! Unlike `cotis`, this crate does not define app orchestration or layout/renderer
13//! interfaces. Unlike `cotis-defaults`, it does not define concrete element config
14//! or render command structs.
15//!
16//! # Features
17//!
18//! - `serialization`: enables `serde` derives for [`math`] structs (`Vector2`,
19//!   `Dimensions`, and `BoundingBox`).
20//!
21//! # Text and fonts (evolving API)
22//!
23//! The text, font, and text-measuring APIs are functional today but are planned for
24//! refactoring. Integrators should treat `font_id` assignment, [`font_manager::FontManager`],
25//! [`text::RendererTextMeasuringProvider`], and [`text::LayoutTextMeasuring`] as
26//! subject to change across minor versions until that refactor lands.
27//!
28//! # Quick start
29//!
30//! ```rust,ignore
31//! use cotis_utils::interactivity::mouse::{MouseButton, MouseProvider};
32//! use cotis_utils::math::{Dimensions, Vector2};
33//! use cotis_utils::traits::{CotisFrameContext, CotisRenderContext, CotisWindowContext};
34//!
35//! struct MyRenderer;
36//!
37//! impl CotisWindowContext for MyRenderer {
38//!     fn window_dimensions(&self) -> Dimensions {
39//!         Dimensions::new(1280.0, 720.0)
40//!     }
41//! }
42//!
43//! impl CotisFrameContext for MyRenderer {
44//!     fn get_delta_time(&self) -> f32 {
45//!         1.0 / 60.0
46//!     }
47//! }
48//!
49//! // CotisRenderContext is implemented automatically.
50//!
51//! impl MouseProvider for MyRenderer {
52//!     fn get_mouse_position(&self) -> Vector2 {
53//!         Vector2::new(0.0, 0.0)
54//!     }
55//!
56//!     fn mouse_button_down(&self, _button: MouseButton) -> bool {
57//!         false
58//!     }
59//!
60//!     fn get_mouse_wheel_move_v(&self) -> Vector2 {
61//!         Vector2::new(0.0, 0.0)
62//!     }
63//! }
64//! ```
65/// Element-state query traits used by hit-testing and debug tools.
66pub mod element_state;
67/// Thread-safe font registry and holder abstractions.
68pub mod font_manager;
69/// Keyboard/mouse input traits and key/button enums.
70pub mod interactivity;
71/// Math primitives used by layout, rendering and input providers.
72pub mod math;
73/// Text measurement provider traits shared by layout and renderers.
74pub mod text;
75/// Renderer context traits for window state and frame timing.
76pub mod traits;