ailloli_ui_core/lib.rs
1//! Pure data types shared across the Ailloli UI framework.
2//!
3//! # Boundaries
4//!
5//! This crate intentionally has:
6//!
7//! - **No** `winit` / `wgpu` dependencies,
8//! - **No** runtime widget tree (`Element`, `Widget` live in `ailloli_ui_runtime`),
9//! - **Only** portable values: geometry, styling, identifiers, input events, and DPI math.
10//!
11//! Higher crates (`ailloli_ui_runtime`, `ailloli_ui_widgets`, `ailloli_ui_render_wgpu`, `ailloli_ui_winit`)
12//! build behavior on top of these types.
13
14/// Portable application identity and conventional icon descriptors.
15///
16/// # Examples
17///
18/// ```
19/// use ailloli_ui_core::app_identity::ApplicationId;
20/// assert_eq!(ApplicationId::parse("org.example.app")?.as_str(), "org.example.app");
21/// # Ok::<(), ailloli_ui_core::AppIdentityError>(())
22/// ```
23pub mod app_identity;
24/// Pure chart value mapping and series helpers.
25///
26/// # Examples
27///
28/// ```
29/// use ailloli_ui_core::chart::ChartRange;
30/// assert_eq!(ChartRange::new(0.0, 10.0).fraction_for_value(5.0), 0.5);
31/// ```
32pub mod chart;
33/// Pure transport-agnostic chat session and message state.
34///
35/// # Examples
36///
37/// ```
38/// use ailloli_ui_core::chat::{ChatSessionId, ChatSessionState};
39/// assert!(ChatSessionState::new(ChatSessionId::new("1"), "Demo").messages.is_empty());
40/// ```
41pub mod chat;
42/// Pure color picker values and conversions.
43///
44/// # Examples
45///
46/// ```
47/// use ailloli_ui_core::color_picker::color_to_hsv;
48/// assert_eq!(color_to_hsv(ailloli_ui_core::Color::rgb(255, 0, 0)).h, 0.0);
49/// ```
50pub mod color_picker;
51/// Pure date picker values and calendar helpers.
52///
53/// # Examples
54///
55/// ```
56/// use ailloli_ui_core::date_picker::DateValue;
57/// assert_eq!(DateValue::new(2024, 2, 31).day, 29);
58/// ```
59pub mod date_picker;
60/// Platform-neutral input events (pointer, keyboard, IME, window).
61///
62/// # Examples
63///
64/// ```
65/// use ailloli_ui_core::event::{FocusEvent, Event};
66/// assert!(matches!(Event::Focus(FocusEvent::new(true)), Event::Focus(_)));
67/// ```
68pub mod event;
69/// Logical clip shapes and 2D primitives (`Rect`, `Size`, …).
70///
71/// # Examples
72///
73/// ```
74/// use ailloli_ui_core::geometry::Rect;
75/// assert!(Rect::new(0.0, 0.0, 10.0, 10.0).contains(5.0, 5.0));
76/// ```
77pub mod geometry;
78/// Stable identifiers for elements, widgets, fonts, and icons.
79///
80/// # Examples
81///
82/// ```
83/// use ailloli_ui_core::ids::WidgetId;
84/// assert_eq!(WidgetId(3).0, 3);
85/// ```
86pub mod ids;
87/// Logical ↔ physical coordinate conversion and snapping.
88///
89/// # Examples
90///
91/// ```
92/// use ailloli_ui_core::math::{to_physical_f32, Scale};
93/// assert_eq!(to_physical_f32(2.0, Scale::new(2.0)), 4.0);
94/// ```
95pub mod math;
96/// Pure progress value mapping.
97///
98/// # Examples
99///
100/// ```
101/// use ailloli_ui_core::progress::ProgressSpec;
102/// assert_eq!(ProgressSpec::new(0.0, 10.0).fraction_for_value(5.0), 0.5);
103/// ```
104pub mod progress;
105/// Pure scroll state, metrics, and wheel normalization.
106///
107/// # Examples
108///
109/// ```
110/// use ailloli_ui_core::scroll::{ScrollAxes, ScrollState};
111/// assert_eq!(ScrollState::new().offset, ailloli_ui_core::Offset::default());
112/// assert!(ScrollAxes::BOTH.vertical);
113/// ```
114pub mod scroll;
115/// Pure slider value mapping, snapping, and range helpers.
116///
117/// # Examples
118///
119/// ```
120/// use ailloli_ui_core::slider::SliderSpec;
121/// assert_eq!(SliderSpec::new(0.0, 10.0).with_step(2.0).snap_value(3.0), 4.0);
122/// ```
123pub mod slider;
124/// Colors, layout lengths, flex, theme, and box styling.
125///
126/// # Examples
127///
128/// ```
129/// use ailloli_ui_core::style::{Color, Length};
130/// assert_eq!(Length::percent(50.0).resolve(100.0), Some(50.0));
131/// assert_eq!(Color::WHITE.as_rgba8(), (255, 255, 255, 255));
132/// ```
133pub mod style;
134/// Pure time picker values and formatting helpers.
135///
136/// # Examples
137///
138/// ```
139/// use ailloli_ui_core::time_picker::{TimeFormat, TimeValue};
140/// assert_eq!(TimeValue::new(13, 5).format(TimeFormat::Hour12), "1:05 PM");
141/// ```
142pub mod time_picker;
143/// Pure upload/dropzone metadata and accept matching.
144///
145/// # Examples
146///
147/// ```
148/// use ailloli_ui_core::upload::{UploadAccept, UploadFile};
149/// assert!(UploadAccept::new([".png"]).accepts(&UploadFile::named("icon.png")));
150/// ```
151pub mod upload;
152
153pub use app_identity::{
154 AppIcon, AppIconMetadata, AppIdentity, AppIdentityError, AppIdentityMetadata, ApplicationId,
155 ValidatedAppIdentity, AILLOLI_UI_PACKAGE_METADATA_PATH_ENV, APP_IDENTITY_METADATA_VERSION,
156 CONVENTIONAL_APP_ICON_PATH, OCTAVUI_PACKAGE_METADATA_PATH_ENV,
157};
158pub use chart::{auto_x_range, auto_y_range, ChartPoint, ChartRange, ChartSeries};
159pub use chat::{
160 ChatEvent, ChatItemId, ChatMessage, ChatMessageKind, ChatMessageStatus, ChatRequestId,
161 ChatRole, ChatSessionId, ChatSessionState, ChatSessionStatus, ChatSessionSummary,
162};
163pub use color_picker::{color_to_hsv, format_hex_rgb, hsv_to_color, parse_hex_rgb, HsvColor};
164pub use date_picker::{DateValue, MonthValue, WeekStart};
165pub use event::Event;
166pub use geometry::{ClipShape, Constraints, EdgeInsets, Offset, Point, Rect, Size};
167pub use ids::{ElementId, FontId, IconId, ImageId, LogicalWindowId, SvgSource, WidgetId};
168pub use math::{PhysicalRectI32, Scale};
169pub use progress::ProgressSpec;
170pub use scroll::{
171 ScrollAxes, ScrollBehavior, ScrollMetrics, ScrollOutcome, ScrollState, ScrollbarAxis,
172 ScrollbarDrag, ScrollbarGeometry, ScrollbarGeometrySpec, ScrollbarPart,
173};
174pub use slider::{SliderRangeValue, SliderSpec, SliderThumb};
175#[allow(deprecated)]
176pub use style::Rgba;
177#[allow(deprecated)]
178pub use style::Shadow;
179pub use style::{
180 Border, BorderStyle, BoxShadow, Color, ColorParseError, EdgeColors, LineCap, LineJoin, Radius,
181 StrokeStyle, TextDecoration, TextStyle, Theme, ThemePalette, ThemeRadius, ThemeShadows,
182 ThemeSpacing, ThemeState, ThemeTypography,
183};
184pub use time_picker::{TimeFormat, TimeValue};
185pub use upload::{UploadAccept, UploadFile};