ailloli_ui_core/style/
mod.rs

1//! Visual and layout styling types (no paint implementation).
2//!
3//! Widgets combine layout/flex/box styles with [`Color`] and [`Theme`] tokens.
4//! Layout resolution: `ResolvedLayout`, `resolve_widget_size` (see `layout_resolve` module).
5
6/// Optional solid box backgrounds.
7///
8/// # Examples
9///
10/// ```
11/// use ailloli_ui_core::style::background::Background;
12/// assert_eq!(Background::default(), Background::None);
13/// ```
14pub mod background;
15/// Per-edge border appearance and inner geometry.
16///
17/// # Examples
18///
19/// ```
20/// use ailloli_ui_core::style::border::Border;
21/// assert!(!Border::none().is_visible());
22/// ```
23pub mod border;
24/// Composable margin and padding.
25///
26/// # Examples
27///
28/// ```
29/// use ailloli_ui_core::style::box_model::BoxModel;
30/// assert_eq!(BoxModel::new().padding.left, 0.0);
31/// ```
32pub mod box_model;
33/// Background, border, radius, shadow, and opacity bundles.
34///
35/// # Examples
36///
37/// ```
38/// use ailloli_ui_core::style::box_style::BoxStyle;
39/// assert!(BoxStyle::new().shadows.is_empty());
40/// ```
41pub mod box_style;
42/// Linear-RGBA colors and sRGB conversion.
43///
44/// # Examples
45///
46/// ```
47/// use ailloli_ui_core::style::color::Color;
48/// assert_eq!(Color::WHITE.as_rgba8(), (255, 255, 255, 255));
49/// ```
50pub mod color;
51/// Platform cursor hints.
52///
53/// # Examples
54///
55/// ```
56/// use ailloli_ui_core::style::cursor::CursorStyle;
57/// assert_eq!(CursorStyle::default(), CursorStyle::Auto);
58/// ```
59pub mod cursor;
60/// Per-child flex behavior.
61///
62/// # Examples
63///
64/// ```
65/// use ailloli_ui_core::style::flex_item_style::FlexItemStyle;
66/// assert_eq!(FlexItemStyle::new().flex_grow, 0.0);
67/// ```
68pub mod flex_item_style;
69/// Flex-container direction, alignment, and distribution.
70///
71/// # Examples
72///
73/// ```
74/// use ailloli_ui_core::style::flex_style::FlexStyle;
75/// assert_eq!(FlexStyle::row().gap, 0.0);
76/// ```
77pub mod flex_style;
78/// Interaction flags and state-style resolution.
79///
80/// # Examples
81///
82/// ```
83/// use ailloli_ui_core::style::interaction::InteractionState;
84/// assert!(!InteractionState::normal().disabled);
85/// ```
86pub mod interaction;
87/// Declarative-length resolution against constraints.
88///
89/// # Examples
90///
91/// ```
92/// use ailloli_ui_core::Constraints;
93/// use ailloli_ui_core::style::layout_resolve::resolve_widget_size;
94/// use ailloli_ui_core::style::LayoutStyle;
95/// assert_eq!(resolve_widget_size(ailloli_ui_core::Size::new(1.0, 2.0), LayoutStyle::new(), Constraints::loose(10.0, 10.0)).w, 1.0);
96/// ```
97pub mod layout_resolve;
98/// Compact width/height hints for parent layouts.
99///
100/// # Examples
101///
102/// ```
103/// use ailloli_ui_core::style::layout_size_hint::LayoutSizeHint;
104/// assert_eq!(LayoutSizeHint::default().width, ailloli_ui_core::style::Length::Auto);
105/// ```
106pub mod layout_size_hint;
107/// Per-widget dimensions, bounds, margin, and padding.
108///
109/// # Examples
110///
111/// ```
112/// use ailloli_ui_core::style::layout_style::LayoutStyle;
113/// assert_eq!(LayoutStyle::new().margin.left, 0.0);
114/// ```
115pub mod layout_style;
116/// Intrinsic, fixed, fill, and percentage lengths.
117///
118/// # Examples
119///
120/// ```
121/// use ailloli_ui_core::style::length::Length;
122/// assert_eq!(Length::px(10.0).resolve(20.0), Some(10.0));
123/// ```
124pub mod length;
125/// Clamped widget opacity multipliers.
126///
127/// # Examples
128///
129/// ```
130/// use ailloli_ui_core::style::opacity::Opacity;
131/// assert_eq!(Opacity::new(2.0), Opacity(1.0));
132/// ```
133pub mod opacity;
134/// Per-corner box radii.
135///
136/// # Examples
137///
138/// ```
139/// use ailloli_ui_core::style::radius::Radius;
140/// assert_eq!(Radius::uniform(3.0).tl, 3.0);
141/// ```
142pub mod radius;
143/// Outer and inset box-shadow geometry.
144///
145/// # Examples
146///
147/// ```
148/// use ailloli_ui_core::style::shadow::BoxShadow;
149/// assert_eq!(BoxShadow::sm().blur_radius, 2.0);
150/// ```
151pub mod shadow;
152/// Line cap, join, and stroke parameters.
153///
154/// # Examples
155///
156/// ```
157/// use ailloli_ui_core::style::stroke::StrokeStyle;
158/// assert_eq!(StrokeStyle::default().width, 1.0);
159/// ```
160pub mod stroke;
161/// Text font, size, color, and decoration.
162///
163/// # Examples
164///
165/// ```
166/// use ailloli_ui_core::FontId;
167/// use ailloli_ui_core::style::text_style::TextStyle;
168/// assert_eq!(TextStyle::new(FontId::Ui, 14, ailloli_ui_core::Color::WHITE).px_size, 14);
169/// ```
170pub mod text_style;
171/// Built-in semantic design tokens.
172///
173/// # Examples
174///
175/// ```
176/// use ailloli_ui_core::style::theme::Theme;
177/// assert_eq!(Theme::dark().spacing().md, 12.0);
178/// ```
179pub mod theme;
180
181pub use background::Background;
182pub use border::{Border, BorderStyle, EdgeColors};
183pub use box_model::BoxModel;
184pub use box_style::BoxStyle;
185#[allow(deprecated)]
186pub use color::Rgba;
187pub use color::{Color, ColorParseError};
188pub use cursor::CursorStyle;
189pub use flex_item_style::FlexItemStyle;
190pub use flex_style::{AlignItems, FlexDirection, FlexStyle, JustifyContent};
191pub use interaction::{InteractionState, StateStyle};
192pub use layout_resolve::{resolve_widget_size, ResolvedLayout};
193pub use layout_size_hint::LayoutSizeHint;
194pub use layout_style::LayoutStyle;
195pub use length::Length;
196pub use opacity::Opacity;
197pub use radius::Radius;
198pub use shadow::BoxShadow;
199#[allow(deprecated)]
200pub use shadow::Shadow;
201pub use stroke::{LineCap, LineJoin, StrokeStyle};
202pub use text_style::{TextDecoration, TextStyle};
203pub use theme::{
204    Theme, ThemePalette, ThemeRadius, ThemeShadows, ThemeSpacing, ThemeState, ThemeTypography,
205};