Skip to main content

native_theme/model/widgets/
mod.rs

1// Per-widget struct pairs: all 26 per-variant widgets + LayoutTheme use #[derive(ThemeWidget)].
2
3use crate::Rgba;
4use crate::model::border::{ResolvedWidgetBorder, WidgetBorderSpec};
5use crate::model::{
6    ArrowSide, DialogButtonOrder, DialogEntranceStyle, FontSpec, ResolvedFontSpec, TabIndicatorSide,
7};
8use native_theme_derive::{ThemeFields, ThemeWidget};
9
10// ── 2.2 Window / Application Chrome ────────────────────────────────────────
11
12/// Window chrome: background, title bar colors, inactive states, geometry.
13#[serde_with::skip_serializing_none]
14#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
15#[serde(default)]
16#[theme_inherit(border_kind = "full_lg", font = "title_bar_font")]
17pub struct WindowTheme {
18    /// Main window background fill.
19    #[theme(inherit_from = "defaults.background_color")]
20    pub background_color: Option<Rgba>,
21    /// Active title bar background fill.
22    #[theme(inherit_from = "defaults.surface_color")]
23    pub title_bar_background: Option<Rgba>,
24    /// Title bar background when the window is unfocused.
25    pub inactive_title_bar_background: Option<Rgba>,
26    /// Title bar text color when the window is unfocused.
27    pub inactive_title_bar_text_color: Option<Rgba>,
28    /// Title bar font specification.
29    #[theme(nested, resolved_type = "ResolvedFontSpec")]
30    pub title_bar_font: Option<FontSpec>,
31    /// Window border specification.
32    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
33    pub border: Option<WidgetBorderSpec>,
34}
35
36// ── 2.3 Button ──────────────────────────────────────────────────────────────
37
38/// Push button: colors, sizing, spacing, geometry.
39#[serde_with::skip_serializing_none]
40#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
41#[serde(default)]
42#[theme_inherit(border_kind = "full", font = "font")]
43pub struct ButtonTheme {
44    /// Button background fill at rest.
45    #[theme(inherit_from = "defaults.background_color")]
46    pub background_color: Option<Rgba>,
47    /// Primary / accent button background fill.
48    #[theme(inherit_from = "defaults.accent_color")]
49    pub primary_background: Option<Rgba>,
50    /// Primary / accent button text/icon color.
51    #[theme(inherit_from = "defaults.accent_text_color")]
52    pub primary_text_color: Option<Rgba>,
53    /// Minimum button width in logical pixels.
54    #[serde(rename = "min_width_px")]
55    #[theme(check = "non_negative")]
56    pub min_width: Option<f32>,
57    /// Minimum button height in logical pixels.
58    #[serde(rename = "min_height_px")]
59    #[theme(check = "non_negative")]
60    pub min_height: Option<f32>,
61    /// Space between icon and label.
62    #[serde(rename = "icon_text_gap_px")]
63    #[theme(check = "non_negative")]
64    pub icon_text_gap: Option<f32>,
65    /// Opacity multiplier when the button is disabled (0.0-1.0), applied to
66    /// the whole button on top of its disabled colours (see
67    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
68    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
69    pub disabled_opacity: Option<f32>,
70    /// Button background on hover.
71    #[theme(inherit_from = "defaults.background_color")]
72    pub hover_background: Option<Rgba>,
73    /// Button text color on hover.
74    pub hover_text_color: Option<Rgba>,
75    /// Button text color when pressed/active.
76    pub active_text_color: Option<Rgba>,
77    /// Button text color when disabled.
78    #[theme(inherit_from = "defaults.disabled_text_color")]
79    pub disabled_text_color: Option<Rgba>,
80    /// Button background when pressed/active.
81    #[theme(category = "soft_option")]
82    pub active_background: Option<Rgba>,
83    /// Button background when disabled; `None`, the enabled background.
84    #[theme(category = "soft_option")]
85    pub disabled_background: Option<Rgba>,
86    /// Background of a toggle button that is on (checked): Breeze's
87    /// `Button` mixed an eighth towards `ButtonText`, WinUI's accent fill,
88    /// libadwaita's pressed fill, Material's `secondary`. `None` where the
89    /// platform states none (AppKit); a connector then shows the pressed
90    /// pair, `active_background` and `active_text_color`
91    /// (docs/platform-facts.md §2.3).
92    #[theme(category = "soft_option")]
93    pub checked_background: Option<Rgba>,
94    /// Label color of a toggle button that is on; `None`, as for
95    /// `checked_background`, the pressed pair's (docs/platform-facts.md §2.3).
96    #[theme(category = "soft_option")]
97    pub checked_text_color: Option<Rgba>,
98    /// Border colour of a hovered button, which a pressed button keeps (it is under
99    /// the pointer). `None` where the theme states none; a connector then draws
100    /// `border.color` (docs/platform-facts.md §2.3).
101    #[theme(category = "soft_option")]
102    pub hover_border_color: Option<Rgba>,
103    /// Border colour of a button with the keyboard focus. `None` where the theme
104    /// states none; a connector then draws the hover border, else `border.color`, where
105    /// it shows a focused button by its border (docs/platform-facts.md §2.3).
106    #[theme(category = "soft_option")]
107    pub focus_border_color: Option<Rgba>,
108    /// Fill of a dialog's default button, the one Enter activates, where the
109    /// platform gives it a look of its own: Breeze's `Button` mixed a fifth
110    /// towards `Highlight`. `None` where the default button is the primary
111    /// one (macOS, Windows): a connector then draws `primary_background` and
112    /// `primary_text_color` in every state. Where it is stated, the default
113    /// button is this fill, lettered in `default_button_text_color` (else
114    /// `font.color`) and framed in `default_button_border_color` (else
115    /// `border.color`): the fill decides (docs/platform-facts.md §2.3).
116    /// Breeze tints its default button only in an active window; the
117    /// connectors draw this look whatever the window's state.
118    #[theme(category = "soft_option")]
119    pub default_button_background: Option<Rgba>,
120    /// Label colour of a dialog's default button, read only where
121    /// `default_button_background` is stated; `None` there is `font.color`,
122    /// as Breeze letters it (docs/platform-facts.md §2.3).
123    #[theme(category = "soft_option")]
124    pub default_button_text_color: Option<Rgba>,
125    /// Border colour of a dialog's default button, read only where
126    /// `default_button_background` is stated; `None` there is `border.color`
127    /// (docs/platform-facts.md §2.3).
128    #[theme(category = "soft_option")]
129    pub default_button_border_color: Option<Rgba>,
130    /// Button label font specification.
131    #[theme(nested, resolved_type = "ResolvedFontSpec")]
132    pub font: Option<FontSpec>,
133    /// Button border specification.
134    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
135    pub border: Option<WidgetBorderSpec>,
136}
137
138// ── 2.4 Text Input ──────────────────────────────────────────────────────────
139
140/// Single-line and multi-line text input fields: everything of a multi-line
141/// field but its padding, which is [`TextAreaTheme`]'s.
142#[serde_with::skip_serializing_none]
143#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
144#[serde(default)]
145#[theme_inherit(border_kind = "full", font = "font")]
146pub struct InputTheme {
147    /// Input field background fill.
148    #[theme(inherit_from = "defaults.background_color")]
149    pub background_color: Option<Rgba>,
150    /// Placeholder text color.
151    #[theme(inherit_from = "defaults.muted_color")]
152    pub placeholder_color: Option<Rgba>,
153    /// Text cursor (caret) color.
154    pub caret_color: Option<Rgba>,
155    /// How long the caret is shown in each blink cycle, in milliseconds, 1 or
156    /// more. A blink is stated whole, with
157    /// [`caret_blink_off`](Self::caret_blink_off), or not at all; `None`
158    /// where the theme states none, and the toolkit's own blink applies
159    /// (docs/platform-facts.md §2.4).
160    #[serde(rename = "caret_blink_on_ms")]
161    #[theme(category = "soft_option", min_u32 = "1")]
162    pub caret_blink_on: Option<u32>,
163    /// How long the caret is hidden in each blink cycle, in milliseconds; 0
164    /// means the caret does not blink, whatever
165    /// [`caret_blink_on`](Self::caret_blink_on) is. `None` where the theme
166    /// states no blink (docs/platform-facts.md §2.4).
167    #[serde(rename = "caret_blink_off_ms")]
168    #[theme(category = "soft_option")]
169    pub caret_blink_off: Option<u32>,
170    /// How long after the last input the caret stops blinking, shown, in
171    /// milliseconds, 1 or more; stated only beside `caret_blink_off`. `None` where the
172    /// platform's caret never stops (KDE, Material, iOS) or no source gives
173    /// its time-out (Windows, macOS) (docs/platform-facts.md §2.4).
174    #[serde(rename = "caret_blink_timeout_ms")]
175    #[theme(category = "soft_option", min_u32 = "1")]
176    pub caret_blink_timeout: Option<u32>,
177    /// Text selection highlight color.
178    #[theme(inherit_from = "defaults.text_selection_background")]
179    pub selection_background: Option<Rgba>,
180    /// Text color inside the selection highlight.
181    #[theme(inherit_from = "defaults.text_selection_color")]
182    pub selection_text_color: Option<Rgba>,
183    /// Minimum field height in logical pixels.
184    #[serde(rename = "min_height_px")]
185    #[theme(check = "non_negative")]
186    pub min_height: Option<f32>,
187    /// Opacity multiplier when disabled (0.0-1.0), applied to the whole
188    /// widget on top of its disabled colours (see
189    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
190    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
191    pub disabled_opacity: Option<f32>,
192    /// Input text color when disabled.
193    #[theme(inherit_from = "defaults.disabled_text_color")]
194    pub disabled_text_color: Option<Rgba>,
195    /// Border color when the input is hovered.
196    #[theme(category = "soft_option")]
197    pub hover_border_color: Option<Rgba>,
198    /// Border color when the input has focus.
199    #[theme(category = "soft_option")]
200    pub focus_border_color: Option<Rgba>,
201    /// Input background when disabled; `None`, the enabled background.
202    #[theme(category = "soft_option")]
203    pub disabled_background: Option<Rgba>,
204    /// Input text font specification.
205    #[theme(nested, resolved_type = "ResolvedFontSpec")]
206    pub font: Option<FontSpec>,
207    /// Input border specification.
208    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
209    pub border: Option<WidgetBorderSpec>,
210}
211
212// ── 2.29 Text Area (multi-line) ──────────────────────────────────────────────
213
214/// Multi-line text field: the padding in which it differs from the
215/// single-line field. Everything else a text area shows -- its fill, text,
216/// placeholder, caret, selection, states and font -- is [`InputTheme`]'s.
217#[serde_with::skip_serializing_none]
218#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
219#[serde(default)]
220pub struct TextAreaTheme {
221    /// Text area border specification. Its padding sides are the multi-line
222    /// field's own, `None` where the platform states none
223    /// (docs/platform-facts.md §2.29); its colour, corner radius, line width
224    /// and shadow inherit `input.border`'s: the platforms frame both fields
225    /// alike.
226    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
227    pub border: Option<WidgetBorderSpec>,
228}
229
230// ── 2.5 Checkbox / Radio Button ────────────────────────────────────────────
231
232/// Checkbox and radio button theme: colors, indicator, label font, border, and interactive states.
233#[serde_with::skip_serializing_none]
234#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
235#[serde(default)]
236#[theme_inherit(border_kind = "full", font = "font")]
237pub struct CheckboxTheme {
238    /// Checkbox background color.
239    #[theme(inherit_from = "defaults.background_color")]
240    pub background_color: Option<Rgba>,
241    /// Indicator background when checked.
242    #[theme(inherit_from = "defaults.accent_color")]
243    pub checked_background: Option<Rgba>,
244    /// Indicator (check mark / radio dot) color.
245    #[theme(inherit_from = "defaults.accent_text_color")]
246    pub indicator_color: Option<Rgba>,
247    /// Side length of the checkbox indicator (square), or diameter of the
248    /// radio indicator (circle), in logical pixels: the whole indicator, not
249    /// the mark drawn inside it (docs/platform-facts.md:984).
250    #[serde(rename = "indicator_width_px")]
251    #[theme(check = "non_negative")]
252    pub indicator_width: Option<f32>,
253    /// Diameter of the radio indicator (circle) in logical pixels, where the
254    /// platform sizes it apart from the checkbox's square: Material's radio is
255    /// 20 across, its checkbox 18. `None` where the platform sizes both alike,
256    /// and the radio is `indicator_width` across (docs/platform-facts.md §2.5).
257    #[serde(rename = "radio_indicator_width_px")]
258    #[theme(category = "soft_option", check = "non_negative")]
259    pub radio_indicator_width: Option<f32>,
260    /// Diameter of the filled dot a selected radio button draws at the centre
261    /// of its indicator, in logical pixels. `None` where the theme states no
262    /// dot size (ios-13 and the community presets); a connector then draws
263    /// its toolkit's own dot (docs/platform-facts.md §2.5).
264    #[serde(rename = "radio_dot_diameter_px")]
265    #[theme(category = "soft_option", check = "non_negative")]
266    pub radio_dot_diameter: Option<f32>,
267    /// Stroke width of the check mark a checked checkbox draws, in logical
268    /// pixels. `None` where the platform states none: WinUI's mark is a font
269    /// glyph and AppKit publishes none (docs/platform-facts.md §2.5).
270    #[serde(rename = "check_mark_stroke_width_px")]
271    #[theme(category = "soft_option", check = "non_negative")]
272    pub check_mark_stroke_width: Option<f32>,
273    /// Space between indicator and label.
274    #[serde(rename = "label_gap_px")]
275    #[theme(check = "non_negative")]
276    pub label_gap: Option<f32>,
277    /// Opacity multiplier when disabled (0.0-1.0), applied to the whole
278    /// widget on top of its disabled colours (see
279    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
280    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
281    pub disabled_opacity: Option<f32>,
282    /// Checkbox label text color when disabled.
283    #[theme(inherit_from = "defaults.disabled_text_color")]
284    pub disabled_text_color: Option<Rgba>,
285    /// Checkbox background on hover.
286    #[theme(category = "soft_option")]
287    pub hover_background: Option<Rgba>,
288    /// Border colour of a check box's or a radio button's indicator under the
289    /// pointer, checked or not. `None` where the theme states none; a connector
290    /// then keeps the border at rest (docs/platform-facts.md §2.5).
291    #[theme(category = "soft_option")]
292    pub hover_border_color: Option<Rgba>,
293    /// Checkbox background when disabled; `None`, the enabled box of its
294    /// state (checked or unchecked).
295    #[theme(category = "soft_option")]
296    pub disabled_background: Option<Rgba>,
297    /// Indicator background when unchecked.
298    #[theme(category = "soft_option")]
299    pub unchecked_background: Option<Rgba>,
300    /// Border color when unchecked.
301    #[theme(category = "soft_option")]
302    pub unchecked_border_color: Option<Rgba>,
303    /// Checkbox label font specification.
304    #[theme(nested, resolved_type = "ResolvedFontSpec")]
305    pub font: Option<FontSpec>,
306    /// Checkbox border specification.
307    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
308    pub border: Option<WidgetBorderSpec>,
309}
310
311// ── 2.6 Menu ────────────────────────────────────────────────────────────────
312
313/// Popup and context menu appearance, and the menu bar's titles.
314///
315/// A menu bar is filled with `toolbar.background_color`, the fill of the one
316/// tools area Breeze paints (docs/platform-facts.md §2.6, §2.13).
317#[serde_with::skip_serializing_none]
318#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
319#[serde(default)]
320#[theme_layer(border_kind = "none")]
321#[theme_inherit(font = "font")]
322pub struct MenuTheme {
323    /// Menu panel background fill.
324    #[theme(inherit_from = "defaults.background_color")]
325    pub background_color: Option<Rgba>,
326    /// Separator line color between menu items.
327    #[theme(inherit_from = "defaults.border.color")]
328    pub separator_color: Option<Rgba>,
329    /// Height of an item row, drawn exactly at a text scale of 1. `None`
330    /// where the platform states no fixed row height: KDE's rows size to
331    /// their content with a floor, `min_row_height`. Where both are stated,
332    /// this one is drawn and `min_row_height` is not applied
333    /// (docs/platform-facts.md §2.6).
334    #[serde(rename = "row_height_px")]
335    #[theme(category = "soft_option", check = "non_negative")]
336    pub row_height: Option<f32>,
337    /// Least height of a one-line item row in logical pixels; content taller
338    /// than it grows the row. Breeze's row is 29 wherever the text line and
339    /// the icon are 20 px or less, and the text + 9 above that, where the
340    /// model's row grows as the text + `border`'s vertical padding: one pixel
341    /// short there. Not applied where `row_height` is stated. `None`: the row
342    /// is its content's height (docs/platform-facts.md §2.6).
343    #[serde(rename = "min_row_height_px")]
344    #[theme(category = "soft_option", check = "non_negative")]
345    pub min_row_height: Option<f32>,
346    /// Space between a menu item's icon and its label.
347    #[serde(rename = "icon_text_gap_px")]
348    #[theme(check = "non_negative")]
349    pub icon_text_gap: Option<f32>,
350    /// Menu item icon size in logical pixels.
351    #[serde(rename = "icon_size_px")]
352    #[theme(check = "non_negative", inherit_from = "defaults.icon_sizes.toolbar")]
353    pub icon_size: Option<f32>,
354    /// Menu item background on hover. It may be translucent, a layer over the
355    /// menu's `background_color` (kde-breeze states `#3daee94d`, windows-11
356    /// `#00000009` light and `#ffffff0f` dark): lay it over that fill, with
357    /// [`composite_over`](crate::color::composite_over) where the toolkit
358    /// replaces the fill rather than painting the highlight over it.
359    #[theme(inherit_from = "defaults.selection_background")]
360    pub hover_background: Option<Rgba>,
361    /// Menu item text color on hover.
362    #[theme(inherit_from = "defaults.selection_text_color")]
363    pub hover_text_color: Option<Rgba>,
364    /// Disabled menu item text color.
365    #[theme(inherit_from = "defaults.disabled_text_color")]
366    pub disabled_text_color: Option<Rgba>,
367    /// Outline of a hovered item's highlight, drawn at
368    /// `defaults.border.line_width` inside the highlight, over the item's
369    /// padding, so nothing moves, and rounded by `border.corner_radius`:
370    /// Breeze's focus colour mixed 15 % towards `WindowText`. A pressed item
371    /// draws none where `active_background` is stated. `None`: no outline
372    /// (docs/platform-facts.md §2.6).
373    #[theme(category = "soft_option")]
374    pub hover_border_color: Option<Rgba>,
375    /// Fill of a menu-bar title under the pointer, rounded by
376    /// `border.corner_radius`: Breeze's opaque hover colour. `None`: the title
377    /// keeps the connector's own look (docs/platform-facts.md §2.6).
378    #[theme(category = "soft_option")]
379    pub bar_hover_background: Option<Rgba>,
380    /// Fill of a menu-bar title whose menu is open: Breeze's focus colour.
381    /// `None`: `bar_hover_background`; with both `None`, the connector's own
382    /// look (docs/platform-facts.md §2.6).
383    #[theme(category = "soft_option")]
384    pub bar_open_background: Option<Rgba>,
385    /// Text colour of a menu-bar title under the pointer or open: Breeze's
386    /// `HighlightedText`. `None`: the title keeps its text colour
387    /// (docs/platform-facts.md §2.6).
388    #[theme(category = "soft_option")]
389    pub bar_hover_text_color: Option<Rgba>,
390    /// Inset of a menu-bar title's text from its left and right edge, in
391    /// logical pixels: Breeze's `MenuBarItem_MarginWidth` 10; titles so padded
392    /// touch. `None`: the connector's own title padding
393    /// (docs/platform-facts.md §2.6).
394    #[serde(rename = "bar_padding_horizontal_px")]
395    #[theme(category = "soft_option", check = "non_negative")]
396    pub bar_padding_horizontal: Option<f32>,
397    /// Inset of a menu-bar title's text from its top and bottom edge, in
398    /// logical pixels: Breeze's `MenuBarItem_MarginHeight` 6. `None`: the
399    /// connector's own title padding (docs/platform-facts.md §2.6).
400    #[serde(rename = "bar_padding_vertical_px")]
401    #[theme(category = "soft_option", check = "non_negative")]
402    pub bar_padding_vertical: Option<f32>,
403    /// Fill of an item while the mouse button is held on it: Breeze's opaque
404    /// focus colour. Where it is stated, a pressed item draws no
405    /// `hover_border_color` outline (Breeze's outline is the fill's own
406    /// colour). `None`: a pressed item keeps the hover look, outline included
407    /// (docs/platform-facts.md §2.6).
408    #[theme(category = "soft_option")]
409    pub active_background: Option<Rgba>,
410    /// Text colour of a pressed item: Breeze's `HighlightedText`. `None`:
411    /// `hover_text_color` (docs/platform-facts.md §2.6).
412    #[theme(category = "soft_option")]
413    pub active_text_color: Option<Rgba>,
414    /// Inset of the items from the left and right of the menu panel's frame
415    /// line, in logical pixels; the frame is `popover.border`'s. Breeze's
416    /// `PM_MenuHMargin` 4 counts from the panel's outer edge, its 1 px line
417    /// included, so kde-breeze states 3. Rows so inset touch. `None`: the
418    /// items are inset by `popover.border`'s padding (docs/platform-facts.md
419    /// §2.6).
420    #[serde(rename = "panel_padding_horizontal_px")]
421    #[theme(category = "soft_option", check = "non_negative")]
422    pub panel_padding_horizontal: Option<f32>,
423    /// Inset of the items from the top and bottom of the menu panel's frame
424    /// line, in logical pixels; the frame is `popover.border`'s. Breeze's
425    /// `PM_MenuVMargin` 4 counts from the panel's outer edge, its 1 px line
426    /// included, so kde-breeze states 3. Rows so inset touch. `None`: the
427    /// items are inset by `popover.border`'s padding (docs/platform-facts.md
428    /// §2.6).
429    #[serde(rename = "panel_padding_vertical_px")]
430    #[theme(category = "soft_option", check = "non_negative")]
431    pub panel_padding_vertical: Option<f32>,
432    /// Menu item font specification.
433    #[theme(nested, resolved_type = "ResolvedFontSpec")]
434    pub font: Option<FontSpec>,
435    /// Menu border specification: its padding insets an item's contents from
436    /// the edges of the item's highlight. Its corner radius is the platform's
437    /// menu radius, which KDE gives a hovered item's highlight and Material the
438    /// menu's container (the iced connector rounds a drop-down's panel with
439    /// it, the egui connector a menu's items). It has no colour of its own:
440    /// the menu's popup frame is the popover's, `popover.border`
441    /// (docs/platform-facts.md §2.6, §2.16). No bundled preset states this border's colour or width; unstated,
442    /// they resolve to transparent and 0.
443    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
444    pub border: Option<WidgetBorderSpec>,
445}
446
447// ── 2.7 Tooltip ─────────────────────────────────────────────────────────────
448
449/// Tooltip popup appearance.
450#[serde_with::skip_serializing_none]
451#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
452#[serde(default)]
453#[theme_inherit(border_kind = "full", font = "font")]
454pub struct TooltipTheme {
455    /// Tooltip background fill.
456    #[theme(inherit_from = "defaults.background_color")]
457    pub background_color: Option<Rgba>,
458    /// Maximum tooltip width before wrapping.
459    #[serde(rename = "max_width_px")]
460    #[theme(check = "non_negative")]
461    pub max_width: Option<f32>,
462    /// Delay in milliseconds between the pointer coming to rest on an element
463    /// and its tooltip showing. `None` where the platform states none: AppKit
464    /// documents no delay (docs/platform-facts.md §2.7).
465    #[serde(rename = "show_delay_ms")]
466    #[theme(category = "soft_option")]
467    pub show_delay: Option<u16>,
468    /// Tooltip font specification.
469    #[theme(nested, resolved_type = "ResolvedFontSpec")]
470    pub font: Option<FontSpec>,
471    /// Tooltip border specification.
472    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
473    pub border: Option<WidgetBorderSpec>,
474}
475
476// ── 2.8 Scrollbar ───────────────────────────────────────────────────────────
477
478/// Scrollbar colors and geometry.
479#[serde_with::skip_serializing_none]
480#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
481#[serde(default)]
482pub struct ScrollbarTheme {
483    /// Scrollbar track (gutter) color. A transparent track means the platform
484    /// draws no groove: the view under the bar shows beside the handle
485    /// (kde-breeze, macos-monterey, macos-tahoe and windows-11 state one).
486    pub track_color: Option<Rgba>,
487    /// Scrollbar thumb color.
488    #[theme(inherit_from = "defaults.muted_color")]
489    pub thumb_color: Option<Rgba>,
490    /// Thumb color on hover.
491    #[theme(inherit_from = "defaults.muted_color")]
492    pub thumb_hover_color: Option<Rgba>,
493    /// Scrollbar groove width in logical pixels.
494    #[serde(rename = "groove_width_px")]
495    #[theme(check = "non_negative")]
496    pub groove_width: Option<f32>,
497    /// Minimum thumb length in logical pixels.
498    #[serde(rename = "min_thumb_length_px")]
499    #[theme(check = "non_negative")]
500    pub min_thumb_length: Option<f32>,
501    /// Width of the thumb rail within the scrollbar.
502    #[serde(rename = "thumb_width_px")]
503    #[theme(check = "non_negative")]
504    pub thumb_width: Option<f32>,
505    /// Whether the scrollbar overlays content instead of taking layout space.
506    pub overlay_mode: Option<bool>,
507    /// Thumb color when pressed/dragging.
508    #[theme(category = "soft_option")]
509    pub thumb_active_color: Option<Rgba>,
510}
511
512// ── 2.9 Slider ──────────────────────────────────────────────────────────────
513
514/// Slider control colors and geometry.
515#[serde_with::skip_serializing_none]
516#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
517#[serde(default)]
518pub struct SliderTheme {
519    /// Filled portion of the slider track.
520    #[theme(inherit_from = "defaults.accent_color")]
521    pub fill_color: Option<Rgba>,
522    /// Unfilled track color.
523    #[theme(inherit_from = "defaults.muted_color")]
524    pub track_color: Option<Rgba>,
525    /// Thumb (handle) color.
526    #[theme(inherit_from = "defaults.surface_color")]
527    pub thumb_color: Option<Rgba>,
528    /// Track height in logical pixels.
529    #[serde(rename = "track_height_px")]
530    #[theme(check = "non_negative")]
531    pub track_height: Option<f32>,
532    /// Thumb diameter in logical pixels.
533    #[serde(rename = "thumb_diameter_px")]
534    #[theme(check = "non_negative")]
535    pub thumb_diameter: Option<f32>,
536    /// Tick mark length in logical pixels.
537    #[serde(rename = "tick_mark_length_px")]
538    #[theme(check = "non_negative")]
539    pub tick_mark_length: Option<f32>,
540    /// Opacity multiplier when disabled (0.0-1.0), applied to the whole
541    /// widget on top of its disabled colours (see
542    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
543    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
544    pub disabled_opacity: Option<f32>,
545    /// Thumb color on hover.
546    #[theme(category = "soft_option")]
547    pub thumb_hover_color: Option<Rgba>,
548    /// Filled track color when disabled; `None`, the enabled colour (as for
549    /// the two below).
550    #[theme(category = "soft_option")]
551    pub disabled_fill_color: Option<Rgba>,
552    /// Unfilled track color when disabled.
553    #[theme(category = "soft_option")]
554    pub disabled_track_color: Option<Rgba>,
555    /// Thumb color when disabled.
556    #[theme(category = "soft_option")]
557    pub disabled_thumb_color: Option<Rgba>,
558    /// The handle's outline at rest, `thumb_border_line_width` wide inside
559    /// the handle: Breeze's `Button` mixed `frameContrast` towards
560    /// `ButtonText`. `None` with the width stated: no line at rest, the
561    /// handle keeping its outer size (docs/platform-facts.md §2.9).
562    #[theme(category = "soft_option")]
563    pub thumb_border_color: Option<Rgba>,
564    /// Width of the handle's outline in logical pixels; 0 draws no outline in
565    /// any state, a connector's own included. `None`: the connector draws the
566    /// handle as it does without this field (its own outline, if any)
567    /// (docs/platform-facts.md §2.9).
568    #[serde(rename = "thumb_border_line_width_px")]
569    #[theme(category = "soft_option", check = "non_negative")]
570    pub thumb_border_line_width: Option<f32>,
571    /// The handle's outline with the pointer on it and while it is dragged,
572    /// over the focus outline: Breeze's hover colour. `None`:
573    /// `thumb_border_color` (docs/platform-facts.md §2.9).
574    #[theme(category = "soft_option")]
575    pub thumb_hover_border_color: Option<Rgba>,
576    /// The handle's outline while the slider has the focus, from a click or a
577    /// key: Breeze's focus colour. `None`: `thumb_border_color`
578    /// (docs/platform-facts.md §2.9).
579    #[theme(category = "soft_option")]
580    pub thumb_focus_border_color: Option<Rgba>,
581}
582
583// ── 2.10 Progress Bar ───────────────────────────────────────────────────────
584
585/// Progress bar colors and geometry.
586#[serde_with::skip_serializing_none]
587#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
588#[serde(default)]
589#[theme_inherit(border_kind = "full")]
590pub struct ProgressBarTheme {
591    /// Filled progress bar color.
592    #[theme(inherit_from = "defaults.accent_color")]
593    pub fill_color: Option<Rgba>,
594    /// Background track color.
595    #[theme(inherit_from = "defaults.muted_color")]
596    pub track_color: Option<Rgba>,
597    /// Bar height in logical pixels.
598    #[serde(rename = "track_height_px")]
599    #[theme(check = "non_negative")]
600    pub track_height: Option<f32>,
601    /// Minimum bar width in logical pixels.
602    #[serde(rename = "min_width_px")]
603    #[theme(check = "non_negative")]
604    pub min_width: Option<f32>,
605    /// Progress bar border specification.
606    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
607    pub border: Option<WidgetBorderSpec>,
608}
609
610// ── 2.11 Tab Bar ─────────────────────────────────────────────────────────────
611
612/// Tab bar colors and sizing.
613#[serde_with::skip_serializing_none]
614#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
615#[serde(default)]
616#[theme_layer(border_kind = "none")]
617#[theme_inherit(font = "font")]
618pub struct TabTheme {
619    /// Inactive tab background.
620    #[theme(inherit_from = "defaults.background_color")]
621    pub background_color: Option<Rgba>,
622    /// Active (selected) tab background.
623    #[theme(inherit_from = "defaults.background_color")]
624    pub active_background: Option<Rgba>,
625    /// Active (selected) tab text color.
626    #[theme(inherit_from = "defaults.text_color")]
627    pub active_text_color: Option<Rgba>,
628    /// Tab bar strip background.
629    #[theme(inherit_from = "defaults.background_color")]
630    pub bar_background: Option<Rgba>,
631    /// Minimum tab width in logical pixels.
632    #[serde(rename = "min_width_px")]
633    #[theme(check = "non_negative")]
634    pub min_width: Option<f32>,
635    /// Minimum tab height in logical pixels.
636    #[serde(rename = "min_height_px")]
637    #[theme(check = "non_negative")]
638    pub min_height: Option<f32>,
639    /// Space between adjacent tabs in logical pixels. `None` where the
640    /// platform states none: AppKit publishes no tab spacing
641    /// (docs/platform-facts.md §2.11).
642    #[serde(rename = "item_gap_px")]
643    #[theme(category = "soft_option", check = "non_negative")]
644    pub item_gap: Option<f32>,
645    /// Color of the line that marks the active tab: Breeze's `Highlight`
646    /// strip, libadwaita's accent, Material's `primary` indicator. `None`
647    /// where the platform marks the active tab without one, by its fill and
648    /// border (docs/platform-facts.md §2.11); a connector draws the line only
649    /// where the theme states its color, width and side.
650    #[theme(category = "soft_option")]
651    pub active_indicator_color: Option<Rgba>,
652    /// Thickness of the active tab's indicator line in logical pixels:
653    /// KDE 3, GNOME 4, Material 3 (docs/platform-facts.md §2.11).
654    #[serde(rename = "active_indicator_width_px")]
655    #[theme(category = "soft_option", check = "non_negative")]
656    pub active_indicator_width: Option<f32>,
657    /// Which edge of the active tab its indicator line lies along, for tabs
658    /// above their pages: KDE top, GNOME and Material bottom
659    /// (docs/platform-facts.md §2.11).
660    #[theme(category = "soft_option")]
661    pub active_indicator_side: Option<TabIndicatorSide>,
662    /// Radius of the outward curves at the selected tab's two bottom corners,
663    /// which spread its fill into the bar's bottom edge, as WinUI 3's `TabView`
664    /// draws its selected tab (4, against 8 on its top corners). Where it is
665    /// stated, the selected tab's outline (`border`) has no bottom edge and
666    /// runs on down the curves. `None` where the platform's selected tab does
667    /// not curve out at its feet: all but Windows; macOS publishes no shape
668    /// (docs/platform-facts.md §2.11).
669    #[serde(rename = "active_outward_corner_radius_px")]
670    #[theme(category = "soft_option", check = "non_negative")]
671    pub active_outward_corner_radius: Option<f32>,
672    /// Tab text color on hover.
673    pub hover_text_color: Option<Rgba>,
674    /// Tab background on hover.
675    #[theme(category = "soft_option")]
676    pub hover_background: Option<Rgba>,
677    /// Tab font specification.
678    #[theme(nested, resolved_type = "ResolvedFontSpec")]
679    pub font: Option<FontSpec>,
680    /// Tab border specification.
681    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
682    pub border: Option<WidgetBorderSpec>,
683}
684
685// ── 2.12 Sidebar ─────────────────────────────────────────────────────────────
686
687/// Sidebar panel background, selection, and hover colors.
688#[serde_with::skip_serializing_none]
689#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
690#[serde(default)]
691#[theme_layer(border_kind = "partial")]
692#[theme_inherit(border_kind = "partial", font = "font")]
693pub struct SidebarTheme {
694    /// Sidebar panel background fill.
695    #[theme(inherit_from = "defaults.background_color")]
696    pub background_color: Option<Rgba>,
697    /// Selected item background color.
698    #[theme(inherit_from = "defaults.selection_background")]
699    pub selection_background: Option<Rgba>,
700    /// Selected item text color.
701    #[theme(inherit_from = "defaults.selection_text_color")]
702    pub selection_text_color: Option<Rgba>,
703    /// Hovered item background color; unstated, the sidebar's own
704    /// `background_color`, no tint (a widget-to-widget rule,
705    /// `resolve_widget_to_widget`).
706    pub hover_background: Option<Rgba>,
707    /// Sidebar font specification.
708    #[theme(nested, resolved_type = "ResolvedFontSpec")]
709    pub font: Option<FontSpec>,
710    /// Sidebar border specification.
711    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
712    pub border: Option<WidgetBorderSpec>,
713}
714
715// ── 2.13 Toolbar ─────────────────────────────────────────────────────────────
716
717/// Toolbar sizing, spacing, font, and its buttons' states.
718///
719/// The five `button_*` fields are the platform's toolbar-button look. A
720/// platform may give that look to some of a toolbar's buttons only (GNOME to
721/// image, image-text and arrow buttons; a button with a text label alone keeps
722/// the ordinary button's look, libadwaita 1.10.0 `_toolbars.scss:2-8`); an
723/// application applies the connector's toolbar-button style to those buttons,
724/// and the ordinary button's style to the others.
725#[serde_with::skip_serializing_none]
726#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
727#[serde(default)]
728#[theme_inherit(border_kind = "full", font = "font")]
729pub struct ToolbarTheme {
730    /// Toolbar background color, also a menu bar's fill: Breeze fills the
731    /// menu bar and the toolbars as one tools area (docs/platform-facts.md
732    /// §2.13).
733    #[theme(inherit_from = "defaults.background_color")]
734    pub background_color: Option<Rgba>,
735    /// Toolbar height in logical pixels. `None` where the platform states
736    /// no toolbar height: KDE's toolbar sizes to its content, and GNOME's
737    /// `.toolbar` sets no minimum height (docs/platform-facts.md §2.13).
738    #[serde(rename = "bar_height_px")]
739    #[theme(category = "soft_option", check = "non_negative")]
740    pub bar_height: Option<f32>,
741    /// Horizontal space between toolbar items. `None` where the theme cites
742    /// no source for one (docs/platform-facts.md §2.13 states it for every
743    /// platform, but a colour scheme has none).
744    #[serde(rename = "item_gap_px")]
745    #[theme(category = "soft_option", check = "non_negative")]
746    pub item_gap: Option<f32>,
747    /// Toolbar icon size in logical pixels.
748    #[serde(rename = "icon_size_px")]
749    #[theme(check = "non_negative", inherit_from = "defaults.icon_sizes.toolbar")]
750    pub icon_size: Option<f32>,
751    /// Fill of a toolbar button under the pointer, painted over the toolbar:
752    /// a translucent colour is a layer, a transparent one paints nothing.
753    /// `None` where the theme states none: a connector draws the hover as it
754    /// draws a flat button's (docs/platform-facts.md §2.13).
755    #[theme(category = "soft_option")]
756    pub button_hover_background: Option<Rgba>,
757    /// Outline of a toolbar button under the pointer, and while it is pressed.
758    /// `None` where the theme states none: a connector draws the outline as it
759    /// draws a flat button's (docs/platform-facts.md §2.13).
760    #[theme(category = "soft_option")]
761    pub button_hover_border_color: Option<Rgba>,
762    /// Fill of a toolbar button while it is pressed, painted over the toolbar.
763    /// `None` where the theme states none: a connector draws it as it draws a
764    /// pressed flat button (docs/platform-facts.md §2.13).
765    #[theme(category = "soft_option")]
766    pub button_active_background: Option<Rgba>,
767    /// Fill of a toolbar button that is checked (a toggle that is on), painted
768    /// over the toolbar. `None` where the theme states none: a connector draws
769    /// it as it draws a selected flat button (docs/platform-facts.md §2.13).
770    #[theme(category = "soft_option")]
771    pub button_checked_background: Option<Rgba>,
772    /// Outline of a checked toolbar button, drawn at
773    /// `button.border.line_width`: Breeze's ordinary button pen, `Button`
774    /// mixed `frameContrast` towards `ButtonText`; under the pointer and
775    /// pressed `button_hover_border_color` applies. `None` where the theme
776    /// states none: a connector draws it as it draws a selected flat button's
777    /// (docs/platform-facts.md §2.13).
778    #[theme(category = "soft_option")]
779    pub button_checked_border_color: Option<Rgba>,
780    /// Toolbar label font specification.
781    #[theme(nested, resolved_type = "ResolvedFontSpec")]
782    pub font: Option<FontSpec>,
783    /// Toolbar border specification.
784    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
785    pub border: Option<WidgetBorderSpec>,
786}
787
788// ── 2.14 Status Bar ──────────────────────────────────────────────────────────
789
790/// Status bar font and background.
791#[serde_with::skip_serializing_none]
792#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
793#[serde(default)]
794#[theme_layer(border_kind = "partial")]
795#[theme_inherit(border_kind = "partial", font = "font")]
796pub struct StatusBarTheme {
797    /// Status bar background color.
798    #[theme(inherit_from = "defaults.background_color")]
799    pub background_color: Option<Rgba>,
800    /// Status bar font specification.
801    #[theme(nested, resolved_type = "ResolvedFontSpec")]
802    pub font: Option<FontSpec>,
803    /// Status bar border specification.
804    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
805    pub border: Option<WidgetBorderSpec>,
806}
807
808// ── 2.15 List / Table ────────────────────────────────────────────────────────
809
810/// List and table colors and row geometry.
811#[serde_with::skip_serializing_none]
812#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
813#[serde(default)]
814#[theme_inherit(border_kind = "full", font = "item_font")]
815#[theme_inherit(font = "header_font")]
816pub struct ListTheme {
817    /// List background fill.
818    pub background_color: Option<Rgba>,
819    /// Alternate row background for striped lists.
820    pub alternate_row_background: Option<Rgba>,
821    /// Selected row highlight color.
822    #[theme(inherit_from = "defaults.selection_background")]
823    pub selection_background: Option<Rgba>,
824    /// Text color inside a selected row.
825    #[theme(inherit_from = "defaults.selection_text_color")]
826    pub selection_text_color: Option<Rgba>,
827    /// Column header background fill.
828    #[theme(inherit_from = "defaults.surface_color")]
829    pub header_background: Option<Rgba>,
830    /// Grid line color between rows/columns: a table's grid. A separating
831    /// line elsewhere takes `separator.line_color`.
832    #[theme(inherit_from = "defaults.border.color")]
833    pub grid_color: Option<Rgba>,
834    /// Row height in logical pixels. `None` where the platform states no row
835    /// height: KDE's rows size to their content, and GNOME's plain list sets
836    /// no minimum height (docs/platform-facts.md §2.15).
837    #[serde(rename = "row_height_px")]
838    #[theme(category = "soft_option", check = "non_negative")]
839    pub row_height: Option<f32>,
840    /// Column header row height in logical pixels. `None` where the platform
841    /// states none: KDE's header sizes to its content, and WinUI has no
842    /// column header (docs/platform-facts.md §2.15).
843    #[serde(rename = "header_height_px")]
844    #[theme(category = "soft_option", check = "positive")]
845    pub header_height: Option<f32>,
846    /// Fill of a hovered column-header section, in place of
847    /// `header_background`: Breeze's `Button` mixed a fifth towards the hover
848    /// colour. `None` where the platform states none: a hovered section keeps
849    /// `header_background` (docs/platform-facts.md §2.15).
850    #[theme(category = "soft_option")]
851    pub header_hover_background: Option<Rgba>,
852    /// Fill of a pressed column-header section, in place of
853    /// `header_background`: Breeze's `Button` mixed a fifth towards the focus
854    /// colour. `None` where the platform states none: a pressed section keeps
855    /// the hovered fill, else `header_background` (docs/platform-facts.md
856    /// §2.15).
857    #[theme(category = "soft_option")]
858    pub header_active_background: Option<Rgba>,
859    /// The line on each column-header section's trailing edge (the last and
860    /// a lone section have none) and along the header's bottom, laid over
861    /// the header's fill: Breeze's `WindowText` at `frameContrast`, a
862    /// translucent layer. `None`: `grid_color` (docs/platform-facts.md
863    /// §2.15).
864    #[theme(category = "soft_option")]
865    pub header_separator_color: Option<Rgba>,
866    /// Hovered row background color; unstated, the list's own
867    /// `background_color`, no tint (a widget-to-widget rule,
868    /// `resolve_widget_to_widget`). It may be translucent, a layer over the
869    /// row's fill (kde-breeze states `#3daee94d`, windows-11 `#00000009` light
870    /// and `#ffffff0f` dark): lay it over that fill, with
871    /// [`composite_over`](crate::color::composite_over) where the toolkit
872    /// replaces the fill rather than painting the highlight over it.
873    pub hover_background: Option<Rgba>,
874    /// Hovered row text color.
875    pub hover_text_color: Option<Rgba>,
876    /// Outline of a hovered, unselected row, drawn at
877    /// `defaults.border.line_width` on the shape of the row's hover fill:
878    /// Breeze's `Highlight` at alpha 0.8, a translucent layer. `None`: no
879    /// outline (docs/platform-facts.md §2.15).
880    #[theme(category = "soft_option")]
881    pub hover_border_color: Option<Rgba>,
882    /// Disabled row text color.
883    #[theme(inherit_from = "defaults.disabled_text_color")]
884    pub disabled_text_color: Option<Rgba>,
885    /// List item font specification.
886    #[theme(nested, resolved_type = "ResolvedFontSpec")]
887    pub item_font: Option<FontSpec>,
888    /// Column header font specification.
889    #[theme(nested, resolved_type = "ResolvedFontSpec")]
890    pub header_font: Option<FontSpec>,
891    /// List border specification.
892    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
893    pub border: Option<WidgetBorderSpec>,
894}
895
896// ── 2.16 Popover / Dropdown ──────────────────────────────────────────────────
897
898/// Popover / dropdown panel appearance.
899#[serde_with::skip_serializing_none]
900#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
901#[serde(default)]
902#[theme_inherit(border_kind = "full_lg", font = "font")]
903pub struct PopoverTheme {
904    /// Panel background fill.
905    pub background_color: Option<Rgba>,
906    /// Popover font specification.
907    #[theme(nested, resolved_type = "ResolvedFontSpec")]
908    pub font: Option<FontSpec>,
909    /// Popover border specification.
910    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
911    pub border: Option<WidgetBorderSpec>,
912}
913
914// ── 2.17 Splitter ────────────────────────────────────────────────────────────
915
916/// Splitter handle width and color.
917#[serde_with::skip_serializing_none]
918#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
919#[serde(default)]
920pub struct SplitterTheme {
921    /// Handle width in logical pixels.
922    #[serde(rename = "divider_width_px")]
923    #[theme(check = "non_negative")]
924    pub divider_width: Option<f32>,
925    /// Divider color.
926    #[theme(inherit_from = "defaults.border.color")]
927    pub divider_color: Option<Rgba>,
928    /// Divider color on hover.
929    pub hover_color: Option<Rgba>,
930}
931
932// ── 2.18 Separator ───────────────────────────────────────────────────────────
933
934/// Separator line color and width.
935#[serde_with::skip_serializing_none]
936#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
937#[serde(default)]
938pub struct SeparatorTheme {
939    /// Separator line color.
940    #[theme(inherit_from = "defaults.border.color")]
941    pub line_color: Option<Rgba>,
942    /// Separator line width in logical pixels.
943    #[serde(rename = "line_width_px")]
944    #[theme(check = "non_negative", inherit_from = "defaults.border.line_width")]
945    pub line_width: Option<f32>,
946}
947
948// ── 2.21 Switch / Toggle ─────────────────────────────────────────────────────
949
950/// Toggle switch track, thumb, geometry, and interactive states.
951#[serde_with::skip_serializing_none]
952#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
953#[serde(default)]
954pub struct SwitchTheme {
955    /// Track background when the switch is on.
956    #[theme(inherit_from = "defaults.accent_color")]
957    pub checked_background: Option<Rgba>,
958    /// Track background when the switch is off.
959    pub unchecked_background: Option<Rgba>,
960    /// Thumb (knob) color; while the switch is off, `unchecked_thumb_background`
961    /// where the theme states one.
962    #[theme(inherit_from = "defaults.surface_color")]
963    pub thumb_background: Option<Rgba>,
964    /// Thumb color while the switch is off, where the platform colours it
965    /// apart: Material's `outline`, WinUI's `TextFillColorSecondary`,
966    /// libadwaita's `$slider_color`. `None` where the thumb is one colour in
967    /// both states, `thumb_background` (docs/platform-facts.md §2.21).
968    #[theme(category = "soft_option")]
969    pub unchecked_thumb_background: Option<Rgba>,
970    /// Track width in logical pixels.
971    #[serde(rename = "track_width_px")]
972    #[theme(check = "non_negative")]
973    pub track_width: Option<f32>,
974    /// Track height in logical pixels.
975    #[serde(rename = "track_height_px")]
976    #[theme(check = "non_negative")]
977    pub track_height: Option<f32>,
978    /// Thumb diameter in logical pixels; while the switch is off,
979    /// `unchecked_thumb_diameter` where the theme states one. A thumb
980    /// shorter than the track is centred in it; a taller one overhangs it
981    /// above and below and sits flush with its ends, as qqc2-desktop-style's
982    /// (docs/platform-facts.md §2.21).
983    #[serde(rename = "thumb_diameter_px")]
984    #[theme(check = "non_negative")]
985    pub thumb_diameter: Option<f32>,
986    /// Thumb diameter while the switch is off, in logical pixels, where the
987    /// platform sizes it apart: Material's is 16 off, 24 on. `None` where the
988    /// thumb is one size in both states, `thumb_diameter`
989    /// (docs/platform-facts.md §2.21).
990    #[serde(rename = "unchecked_thumb_diameter_px")]
991    #[theme(category = "soft_option", check = "non_negative")]
992    pub unchecked_thumb_diameter: Option<f32>,
993    /// Track corner radius in logical pixels.
994    #[serde(rename = "track_radius_px")]
995    #[theme(check = "non_negative")]
996    pub track_radius: Option<f32>,
997    /// Opacity multiplier when disabled (0.0-1.0), applied to the whole
998    /// widget on top of its disabled colours (see
999    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
1000    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
1001    pub disabled_opacity: Option<f32>,
1002    /// Track hover color when checked (on).
1003    #[theme(category = "soft_option")]
1004    pub hover_checked_background: Option<Rgba>,
1005    /// Track hover color when unchecked (off).
1006    #[theme(category = "soft_option")]
1007    pub hover_unchecked_background: Option<Rgba>,
1008    /// Track color when disabled and checked; `None`, the enabled colour (as
1009    /// for the two below).
1010    #[theme(category = "soft_option")]
1011    pub disabled_checked_background: Option<Rgba>,
1012    /// Track color when disabled and unchecked.
1013    #[theme(category = "soft_option")]
1014    pub disabled_unchecked_background: Option<Rgba>,
1015    /// Thumb color when disabled.
1016    #[theme(category = "soft_option")]
1017    pub disabled_thumb_color: Option<Rgba>,
1018    /// The off track's outline, `track_border_line_width` wide inside the
1019    /// track: WinUI's `ToggleSwitchStrokeOff`, Material's
1020    /// `unselected-track-outline-color`, qqc2-desktop-style's
1021    /// `handleBorderColor`. `None` draws no outline, as libadwaita and
1022    /// macOS (docs/platform-facts.md §2.21).
1023    #[theme(category = "soft_option")]
1024    pub unchecked_track_border_color: Option<Rgba>,
1025    /// The on track's outline: qqc2-desktop-style's `highlightColor`. `None`
1026    /// draws none, as WinUI and Material, which outline only the off track
1027    /// (docs/platform-facts.md §2.21).
1028    #[theme(category = "soft_option")]
1029    pub checked_track_border_color: Option<Rgba>,
1030    /// The off track's outline when disabled; `None`, the enabled one (as
1031    /// for the one below).
1032    #[theme(category = "soft_option")]
1033    pub disabled_unchecked_track_border_color: Option<Rgba>,
1034    /// The on track's outline when disabled.
1035    #[theme(category = "soft_option")]
1036    pub disabled_checked_track_border_color: Option<Rgba>,
1037    /// The track outline's width in logical pixels, on and off; `None`
1038    /// draws no outline.
1039    #[serde(rename = "track_border_line_width_px")]
1040    #[theme(category = "soft_option", check = "non_negative")]
1041    pub track_border_line_width: Option<f32>,
1042    /// The thumb's outline, `thumb_border_line_width` wide inside the thumb,
1043    /// on and off: qqc2-desktop-style's `handleBorderColor`. `None` draws
1044    /// none (docs/platform-facts.md §2.21).
1045    #[theme(category = "soft_option")]
1046    pub thumb_border_color: Option<Rgba>,
1047    /// The thumb outline's width in logical pixels; `None` draws no outline.
1048    #[serde(rename = "thumb_border_line_width_px")]
1049    #[theme(category = "soft_option", check = "non_negative")]
1050    pub thumb_border_line_width: Option<f32>,
1051}
1052
1053// ── 2.22 Dialog ──────────────────────────────────────────────────────────────
1054
1055/// Dialog sizing, spacing, button order, fonts, border, and background.
1056#[serde_with::skip_serializing_none]
1057#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1058#[serde(default)]
1059#[theme_inherit(border_kind = "full_lg", font = "title_font")]
1060#[theme_inherit(font = "body_font")]
1061pub struct DialogTheme {
1062    /// Dialog background color.
1063    pub background_color: Option<Rgba>,
1064    /// Minimum dialog width in logical pixels.
1065    #[serde(rename = "min_width_px")]
1066    #[theme(check = "non_negative", min_max_pair = "max_width")]
1067    pub min_width: Option<f32>,
1068    /// Maximum dialog width in logical pixels.
1069    #[serde(rename = "max_width_px")]
1070    #[theme(check = "non_negative")]
1071    pub max_width: Option<f32>,
1072    /// Minimum dialog height in logical pixels.
1073    #[serde(rename = "min_height_px")]
1074    #[theme(check = "non_negative", min_max_pair = "max_height")]
1075    pub min_height: Option<f32>,
1076    /// Maximum dialog height in logical pixels.
1077    #[serde(rename = "max_height_px")]
1078    #[theme(check = "non_negative")]
1079    pub max_height: Option<f32>,
1080    /// Horizontal space between dialog buttons.
1081    #[serde(rename = "button_gap_px")]
1082    #[theme(check = "non_negative")]
1083    pub button_gap: Option<f32>,
1084    /// Icon size for dialog type icons (warning, error, etc.).
1085    #[serde(rename = "icon_size_px")]
1086    #[theme(check = "non_negative")]
1087    pub icon_size: Option<f32>,
1088    /// Platform button order convention (e.g., OK/Cancel vs Cancel/OK).
1089    pub button_order: Option<DialogButtonOrder>,
1090    /// How the dialog moves onto the screen as it opens: scaling up while it
1091    /// fades in, or fading in while it rises into place. `None` where the
1092    /// platform states none: AppKit names no dialog motion
1093    /// (docs/platform-facts.md §2.22).
1094    #[theme(category = "soft_option")]
1095    pub entrance: Option<DialogEntranceStyle>,
1096    /// Dialog title font specification.
1097    #[theme(nested, resolved_type = "ResolvedFontSpec")]
1098    pub title_font: Option<FontSpec>,
1099    /// Dialog body font specification.
1100    #[theme(nested, resolved_type = "ResolvedFontSpec")]
1101    pub body_font: Option<FontSpec>,
1102    /// Dialog border specification.
1103    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
1104    pub border: Option<WidgetBorderSpec>,
1105}
1106
1107// ── 2.23 Spinner / Progress Ring ─────────────────────────────────────────────
1108
1109/// Spinner / indeterminate progress indicator.
1110#[serde_with::skip_serializing_none]
1111#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1112#[serde(default)]
1113pub struct SpinnerTheme {
1114    /// Spinner arc fill color.
1115    pub fill_color: Option<Rgba>,
1116    /// Spinner outer diameter in logical pixels.
1117    #[serde(rename = "diameter_px")]
1118    #[theme(check = "non_negative")]
1119    pub diameter: Option<f32>,
1120    /// Minimum rendered size in logical pixels.
1121    #[serde(rename = "min_diameter_px")]
1122    #[theme(check = "non_negative")]
1123    pub min_diameter: Option<f32>,
1124    /// Arc stroke width in logical pixels.
1125    #[serde(rename = "stroke_width_px")]
1126    #[theme(check = "non_negative")]
1127    pub stroke_width: Option<f32>,
1128}
1129
1130// ── 2.24 ComboBox / Dropdown Trigger ─────────────────────────────────────────
1131
1132/// ComboBox / dropdown trigger: colours, sizing, and states (hover, open,
1133/// disabled).
1134#[serde_with::skip_serializing_none]
1135#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1136#[serde(default)]
1137#[theme_inherit(border_kind = "full", font = "font")]
1138pub struct ComboBoxTheme {
1139    /// ComboBox background color.
1140    #[theme(inherit_from = "defaults.background_color")]
1141    pub background_color: Option<Rgba>,
1142    /// Minimum trigger height in logical pixels.
1143    #[serde(rename = "min_height_px")]
1144    #[theme(check = "non_negative")]
1145    pub min_height: Option<f32>,
1146    /// Minimum trigger width in logical pixels.
1147    #[serde(rename = "min_width_px")]
1148    #[theme(check = "non_negative")]
1149    pub min_width: Option<f32>,
1150    /// Dropdown arrow size in logical pixels.
1151    #[serde(rename = "arrow_icon_size_px")]
1152    #[theme(check = "non_negative")]
1153    pub arrow_icon_size: Option<f32>,
1154    /// Width of the arrow clickable area, in logical pixels. `None` where the
1155    /// theme states no width (docs/platform-facts.md §2.24): GNOME's dropdown
1156    /// draws its arrow inline, macOS's width is only a measured range
1157    /// (~16–18px), and the iOS and Material platform presets and the community
1158    /// colour-scheme presets cite none.
1159    #[serde(rename = "arrow_area_width_px")]
1160    #[theme(category = "soft_option", check = "non_negative")]
1161    pub arrow_area_width: Option<f32>,
1162    /// Opacity multiplier when disabled (0.0-1.0), applied to the whole
1163    /// widget on top of its disabled colours (see
1164    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
1165    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
1166    pub disabled_opacity: Option<f32>,
1167    /// ComboBox text color when disabled.
1168    #[theme(inherit_from = "defaults.disabled_text_color")]
1169    pub disabled_text_color: Option<Rgba>,
1170    /// ComboBox background on hover.
1171    #[theme(category = "soft_option")]
1172    pub hover_background: Option<Rgba>,
1173    /// Border colour of the trigger under the pointer. `None` where the theme
1174    /// states none; a connector then keeps the border at rest
1175    /// (docs/platform-facts.md §2.24).
1176    #[theme(category = "soft_option")]
1177    pub hover_border_color: Option<Rgba>,
1178    /// ComboBox background when disabled; `None`, the enabled background.
1179    #[theme(category = "soft_option")]
1180    pub disabled_background: Option<Rgba>,
1181    /// Fill of a combo box while its popup is open, whatever the pointer
1182    /// does: Breeze draws it as a pressed button, `Button` mixed 0.3 towards
1183    /// `Highlight`. `None`: the fill the connector draws for the pointer's
1184    /// state (docs/platform-facts.md §2.24).
1185    #[theme(category = "soft_option")]
1186    pub open_background: Option<Rgba>,
1187    /// Border colour of an open combo box, drawn at `border.line_width`:
1188    /// Breeze's `Highlight`. `None`: the border the connector draws for the
1189    /// pointer's state (docs/platform-facts.md §2.24).
1190    #[theme(category = "soft_option")]
1191    pub open_border_color: Option<Rgba>,
1192    /// ComboBox font specification.
1193    #[theme(nested, resolved_type = "ResolvedFontSpec")]
1194    pub font: Option<FontSpec>,
1195    /// ComboBox border specification.
1196    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
1197    pub border: Option<WidgetBorderSpec>,
1198}
1199
1200// ── 2.25 Segmented Control ───────────────────────────────────────────────────
1201
1202/// Segmented control colours and sizing (macOS-primary; KDE uses tab bar metrics as proxy).
1203#[serde_with::skip_serializing_none]
1204#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1205#[serde(default)]
1206#[theme_inherit(border_kind = "full", font = "font")]
1207pub struct SegmentedControlTheme {
1208    /// Segmented control background color.
1209    #[theme(inherit_from = "defaults.background_color")]
1210    pub background_color: Option<Rgba>,
1211    /// Active segment background.
1212    #[theme(inherit_from = "defaults.accent_color")]
1213    pub active_background: Option<Rgba>,
1214    /// Active segment text color.
1215    #[theme(inherit_from = "defaults.accent_text_color")]
1216    pub active_text_color: Option<Rgba>,
1217    /// Segment height in logical pixels.
1218    #[serde(rename = "segment_height_px")]
1219    #[theme(check = "non_negative")]
1220    pub segment_height: Option<f32>,
1221    /// Width of the separator between segments.
1222    #[serde(rename = "separator_width_px")]
1223    #[theme(check = "non_negative")]
1224    pub separator_width: Option<f32>,
1225    /// Opacity multiplier when disabled (0.0-1.0), applied to the whole
1226    /// widget on top of its disabled colours (see
1227    /// [`ThemeDefaults::disabled_opacity`](crate::model::ThemeDefaults::disabled_opacity)).
1228    #[theme(range = "0.0..=1.0", inherit_from = "defaults.disabled_opacity")]
1229    pub disabled_opacity: Option<f32>,
1230    /// Segment background on hover.
1231    #[theme(category = "soft_option")]
1232    pub hover_background: Option<Rgba>,
1233    /// Segmented control font specification.
1234    #[theme(nested, resolved_type = "ResolvedFontSpec")]
1235    pub font: Option<FontSpec>,
1236    /// Segmented control border specification.
1237    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
1238    pub border: Option<WidgetBorderSpec>,
1239}
1240
1241// ── 2.26 Card / Container ────────────────────────────────────────────────────
1242
1243/// Card / container colors and geometry.
1244#[serde_with::skip_serializing_none]
1245#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1246#[serde(default)]
1247#[theme_layer(border_kind = "none")]
1248pub struct CardTheme {
1249    /// Card background fill.
1250    #[theme(inherit_from = "defaults.surface_color")]
1251    pub background_color: Option<Rgba>,
1252    /// Card border specification.
1253    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
1254    pub border: Option<WidgetBorderSpec>,
1255}
1256
1257// ── 2.27 Expander / Disclosure ───────────────────────────────────────────────
1258
1259/// Expander / disclosure row: geometry, arrow, and hover colours.
1260#[serde_with::skip_serializing_none]
1261#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1262#[serde(default)]
1263#[theme_inherit(border_kind = "full", font = "font")]
1264pub struct ExpanderTheme {
1265    /// Collapsed header row height in logical pixels.
1266    #[serde(rename = "header_height_px")]
1267    #[theme(check = "non_negative")]
1268    pub header_height: Option<f32>,
1269    /// Disclosure arrow size in logical pixels.
1270    #[serde(rename = "arrow_icon_size_px")]
1271    #[theme(check = "non_negative")]
1272    pub arrow_icon_size: Option<f32>,
1273    /// Expander header background on hover.
1274    #[theme(category = "soft_option")]
1275    pub hover_background: Option<Rgba>,
1276    /// Disclosure arrow/chevron color.
1277    #[theme(category = "soft_option")]
1278    pub arrow_color: Option<Rgba>,
1279    /// Which end of the header row the disclosure arrow sits at: before the
1280    /// title, or at the row's end. `None` where the theme states none
1281    /// (docs/platform-facts.md §2.27).
1282    #[theme(category = "soft_option")]
1283    pub arrow_side: Option<ArrowSide>,
1284    /// Space between the arrow's icon box (`arrow_icon_size` square) and the
1285    /// title after it, or, for a trailing arrow, the header content before
1286    /// it, in logical pixels. `None` where the platform states none: AppKit
1287    /// documents no disclosure geometry (docs/platform-facts.md §2.27).
1288    #[serde(rename = "arrow_gap_px")]
1289    #[theme(category = "soft_option", check = "non_negative")]
1290    pub arrow_gap: Option<f32>,
1291    /// Horizontal distance from the expander's leading inner edge (inside
1292    /// its frame, where it has one) to the content it reveals, in logical
1293    /// pixels. `None` where the platform states none: AppKit documents no
1294    /// disclosure geometry (docs/platform-facts.md §2.27).
1295    #[serde(rename = "content_indent_px")]
1296    #[theme(category = "soft_option", check = "non_negative")]
1297    pub content_indent: Option<f32>,
1298    /// Whether the expander draws a frame (its `border`) around its header
1299    /// and the content it reveals: KDE's has none, libadwaita's and WinUI's
1300    /// are framed. `None` where the theme states none
1301    /// (docs/platform-facts.md §2.27).
1302    #[theme(category = "soft_option")]
1303    pub frame_enabled: Option<bool>,
1304    /// Expander font specification.
1305    #[theme(nested, resolved_type = "ResolvedFontSpec")]
1306    pub font: Option<FontSpec>,
1307    /// Expander border specification.
1308    #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
1309    pub border: Option<WidgetBorderSpec>,
1310}
1311
1312// ── 2.28 Link ────────────────────────────────────────────────────────────────
1313
1314/// Hyperlink colors and underline setting.
1315#[serde_with::skip_serializing_none]
1316#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget)]
1317#[serde(default)]
1318#[theme_inherit(font = "font")]
1319pub struct LinkTheme {
1320    /// Visited link text color.
1321    #[theme(inherit_from = "defaults.link_color")]
1322    pub visited_text_color: Option<Rgba>,
1323    /// Whether links are underlined.
1324    pub underline_enabled: Option<bool>,
1325    /// Link background fill (typically transparent).
1326    pub background_color: Option<Rgba>,
1327    /// Link background on hover.
1328    pub hover_background: Option<Rgba>,
1329    /// Link text color on hover.
1330    pub hover_text_color: Option<Rgba>,
1331    /// Link text color when pressed/active.
1332    pub active_text_color: Option<Rgba>,
1333    /// Link text color when disabled.
1334    #[theme(inherit_from = "defaults.disabled_text_color")]
1335    pub disabled_text_color: Option<Rgba>,
1336    /// Link font specification.
1337    #[theme(nested, resolved_type = "ResolvedFontSpec")]
1338    pub font: Option<FontSpec>,
1339}
1340
1341// -- Layout (top-level, not per-variant) ------------------------------------------
1342
1343/// Layout spacing constants shared between light and dark variants.
1344///
1345/// Unlike other widget themes, LayoutTheme lives on [`crate::Theme`] (top-level)
1346/// rather than [`crate::ThemeMode`] because spacing is variant-independent.
1347// LayoutTheme keeps `skip_inventory` so it does NOT register
1348// in the per-variant WidgetFieldInfo registry (it is top-level, not per-variant),
1349// but also derives ThemeFields so lint_toml can look up its fields in the
1350// non-widget FieldInfo registry under the key "LayoutTheme".
1351#[serde_with::skip_serializing_none]
1352#[derive(
1353    Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget, ThemeFields,
1354)]
1355#[serde(default)]
1356#[theme_layer(skip_inventory)]
1357pub struct LayoutTheme {
1358    /// Space between adjacent widgets in logical pixels.
1359    #[serde(rename = "widget_gap_px")]
1360    #[theme(check = "non_negative")]
1361    pub widget_gap: Option<f32>,
1362    /// Padding inside containers in logical pixels.
1363    #[serde(rename = "container_margin_px")]
1364    #[theme(check = "non_negative")]
1365    pub container_margin: Option<f32>,
1366    /// Padding inside the main window in logical pixels.
1367    #[serde(rename = "window_margin_px")]
1368    #[theme(check = "non_negative")]
1369    pub window_margin: Option<f32>,
1370    /// Space between major content sections in logical pixels.
1371    #[serde(rename = "section_gap_px")]
1372    #[theme(check = "non_negative")]
1373    pub section_gap: Option<f32>,
1374}
1375
1376#[cfg(test)]
1377#[allow(clippy::unwrap_used, clippy::expect_used, dead_code)]
1378mod tests {
1379    use super::*;
1380    use crate::Rgba;
1381    use crate::model::border::{ResolvedWidgetBorder, WidgetBorderSpec};
1382    use crate::model::font::FontSize;
1383    use crate::model::{DialogButtonOrder, FontSpec};
1384
1385    // Test widget using derive (validates derive macro works in test context)
1386    /// Test widget for macro verification.
1387    #[serde_with::skip_serializing_none]
1388    #[derive(
1389        Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget,
1390    )]
1391    #[serde(default)]
1392    #[theme_layer(skip_inventory)]
1393    pub struct TestWidget {
1394        pub size: Option<f32>,
1395        pub label: Option<String>,
1396        #[theme(nested, resolved_type = "ResolvedFontSpec")]
1397        pub font: Option<FontSpec>,
1398    }
1399
1400    // === ResolvedFontSpec tests ===
1401
1402    #[test]
1403    fn resolved_font_spec_fields_are_concrete() {
1404        let rfs = ResolvedFontSpec {
1405            family: "Inter".into(),
1406            size: 14.0,
1407            defined_size: Some(crate::model::font::FontSize::Px(14.0)),
1408            weight: 400,
1409            style: crate::model::font::FontStyle::Normal,
1410            color: crate::Rgba::rgb(0, 0, 0),
1411        };
1412        assert_eq!(rfs.family.as_ref(), "Inter");
1413        assert_eq!(rfs.size, 14.0);
1414        assert_eq!(rfs.weight, 400);
1415    }
1416
1417    // === derive(ThemeWidget) generated struct tests ===
1418
1419    #[test]
1420    fn generated_option_struct_has_option_fields() {
1421        let w = TestWidget::default();
1422        assert!(w.size.is_none());
1423        assert!(w.label.is_none());
1424        assert!(w.font.is_none());
1425    }
1426
1427    #[test]
1428    fn generated_option_struct_is_empty_by_default() {
1429        assert!(TestWidget::default().is_empty());
1430    }
1431
1432    #[test]
1433    fn generated_option_struct_not_empty_when_size_set() {
1434        let w = TestWidget {
1435            size: Some(24.0),
1436            ..Default::default()
1437        };
1438        assert!(!w.is_empty());
1439    }
1440
1441    #[test]
1442    fn generated_option_struct_not_empty_when_font_set() {
1443        let w = TestWidget {
1444            font: Some(FontSpec {
1445                size: Some(FontSize::Px(14.0)),
1446                ..Default::default()
1447            }),
1448            ..Default::default()
1449        };
1450        assert!(!w.is_empty());
1451    }
1452
1453    #[test]
1454    fn generated_resolved_struct_has_concrete_fields() {
1455        let resolved = ResolvedTestWidget {
1456            size: 24.0,
1457            label: "Click me".into(),
1458            font: ResolvedFontSpec {
1459                family: "Inter".into(),
1460                size: 14.0,
1461                defined_size: Some(crate::model::font::FontSize::Px(14.0)),
1462                weight: 400,
1463                style: crate::model::font::FontStyle::Normal,
1464                color: crate::Rgba::rgb(0, 0, 0),
1465            },
1466        };
1467        assert_eq!(resolved.size, 24.0);
1468        assert_eq!(resolved.label, "Click me");
1469        assert_eq!(resolved.font.family.as_ref(), "Inter");
1470    }
1471
1472    // === merge tests for generated structs ===
1473
1474    #[test]
1475    fn generated_merge_option_field_overlay_wins() {
1476        let mut base = TestWidget {
1477            size: Some(20.0),
1478            ..Default::default()
1479        };
1480        let overlay = TestWidget {
1481            size: Some(24.0),
1482            ..Default::default()
1483        };
1484        base.merge(&overlay);
1485        assert_eq!(base.size, Some(24.0));
1486    }
1487
1488    #[test]
1489    fn generated_merge_option_field_none_preserves_base() {
1490        let mut base = TestWidget {
1491            size: Some(20.0),
1492            ..Default::default()
1493        };
1494        let overlay = TestWidget::default();
1495        base.merge(&overlay);
1496        assert_eq!(base.size, Some(20.0));
1497    }
1498
1499    #[test]
1500    fn generated_merge_optional_nested_both_some_merges_inner() {
1501        let mut base = TestWidget {
1502            font: Some(FontSpec {
1503                family: Some("Noto Sans".into()),
1504                size: Some(FontSize::Px(12.0)),
1505                weight: None,
1506                ..Default::default()
1507            }),
1508            ..Default::default()
1509        };
1510        let overlay = TestWidget {
1511            font: Some(FontSpec {
1512                family: None,
1513                size: None,
1514                weight: Some(700),
1515                ..Default::default()
1516            }),
1517            ..Default::default()
1518        };
1519        base.merge(&overlay);
1520        let font = base.font.as_ref().unwrap();
1521        assert_eq!(font.family.as_deref(), Some("Noto Sans")); // preserved
1522        assert_eq!(font.size, Some(FontSize::Px(12.0))); // preserved
1523        assert_eq!(font.weight, Some(700)); // overlay sets
1524    }
1525
1526    #[test]
1527    fn generated_merge_optional_nested_none_plus_some_clones() {
1528        let mut base = TestWidget::default();
1529        let overlay = TestWidget {
1530            font: Some(FontSpec {
1531                family: Some("Inter".into()),
1532                size: Some(FontSize::Px(14.0)),
1533                weight: Some(400),
1534                ..Default::default()
1535            }),
1536            ..Default::default()
1537        };
1538        base.merge(&overlay);
1539        let font = base.font.as_ref().unwrap();
1540        assert_eq!(font.family.as_deref(), Some("Inter"));
1541        assert_eq!(font.size, Some(FontSize::Px(14.0)));
1542        assert_eq!(font.weight, Some(400));
1543    }
1544
1545    #[test]
1546    fn generated_merge_optional_nested_some_plus_none_preserves_base() {
1547        let mut base = TestWidget {
1548            font: Some(FontSpec {
1549                family: Some("Inter".into()),
1550                size: Some(FontSize::Px(14.0)),
1551                weight: Some(400),
1552                ..Default::default()
1553            }),
1554            ..Default::default()
1555        };
1556        let overlay = TestWidget::default();
1557        base.merge(&overlay);
1558        let font = base.font.as_ref().unwrap();
1559        assert_eq!(font.family.as_deref(), Some("Inter"));
1560    }
1561
1562    #[test]
1563    fn generated_merge_optional_nested_none_plus_none_stays_none() {
1564        let mut base = TestWidget::default();
1565        let overlay = TestWidget::default();
1566        base.merge(&overlay);
1567        assert!(base.font.is_none());
1568    }
1569
1570    // === impl_merge! optional_nested clause direct tests ===
1571
1572    // Verify the optional_nested clause directly on a FontSpec-containing struct
1573    #[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
1574    struct WithFont {
1575        name: Option<String>,
1576        font: Option<FontSpec>,
1577    }
1578
1579    impl_merge!(WithFont {
1580        option { name }
1581        optional_nested { font }
1582    });
1583
1584    #[test]
1585    fn impl_merge_optional_nested_none_none_stays_none() {
1586        let mut base = WithFont::default();
1587        let overlay = WithFont::default();
1588        base.merge(&overlay);
1589        assert!(base.font.is_none());
1590    }
1591
1592    #[test]
1593    fn impl_merge_optional_nested_some_none_preserves_base() {
1594        let mut base = WithFont {
1595            font: Some(FontSpec {
1596                size: Some(FontSize::Px(12.0)),
1597                ..Default::default()
1598            }),
1599            ..Default::default()
1600        };
1601        let overlay = WithFont::default();
1602        base.merge(&overlay);
1603        assert_eq!(base.font.as_ref().unwrap().size, Some(FontSize::Px(12.0)));
1604    }
1605
1606    #[test]
1607    fn impl_merge_optional_nested_none_some_clones_overlay() {
1608        let mut base = WithFont::default();
1609        let overlay = WithFont {
1610            font: Some(FontSpec {
1611                family: Some("Inter".into()),
1612                ..Default::default()
1613            }),
1614            ..Default::default()
1615        };
1616        base.merge(&overlay);
1617        assert_eq!(base.font.as_ref().unwrap().family.as_deref(), Some("Inter"));
1618    }
1619
1620    #[test]
1621    fn impl_merge_optional_nested_some_some_merges_inner() {
1622        let mut base = WithFont {
1623            font: Some(FontSpec {
1624                family: Some("Noto".into()),
1625                size: Some(FontSize::Px(11.0)),
1626                weight: None,
1627                ..Default::default()
1628            }),
1629            ..Default::default()
1630        };
1631        let overlay = WithFont {
1632            font: Some(FontSpec {
1633                family: None,
1634                size: Some(FontSize::Px(14.0)),
1635                weight: Some(400),
1636                ..Default::default()
1637            }),
1638            ..Default::default()
1639        };
1640        base.merge(&overlay);
1641        let f = base.font.as_ref().unwrap();
1642        assert_eq!(f.family.as_deref(), Some("Noto")); // preserved
1643        assert_eq!(f.size, Some(FontSize::Px(14.0))); // overlay wins
1644        assert_eq!(f.weight, Some(400)); // overlay sets
1645    }
1646
1647    #[test]
1648    fn impl_merge_optional_nested_is_empty_none() {
1649        let w = WithFont::default();
1650        assert!(w.is_empty());
1651    }
1652
1653    #[test]
1654    fn impl_merge_optional_nested_is_empty_some_default() {
1655        // Some(FontSpec::default()) with all-None sub-fields counts as empty (D-2 fix).
1656        let w = WithFont {
1657            font: Some(FontSpec::default()),
1658            ..Default::default()
1659        };
1660        assert!(w.is_empty());
1661    }
1662
1663    #[test]
1664    fn impl_merge_optional_nested_is_not_empty_when_populated() {
1665        let w = WithFont {
1666            font: Some(FontSpec {
1667                size: Some(FontSize::Px(14.0)),
1668                ..Default::default()
1669            }),
1670            ..Default::default()
1671        };
1672        assert!(!w.is_empty());
1673    }
1674
1675    // === ButtonTheme tests ===
1676
1677    #[test]
1678    fn button_theme_default_is_empty() {
1679        assert!(ButtonTheme::default().is_empty());
1680    }
1681
1682    #[test]
1683    fn button_theme_not_empty_when_set() {
1684        let b = ButtonTheme {
1685            background_color: Some(Rgba::rgb(200, 200, 200)),
1686            min_width: Some(64.0),
1687            ..Default::default()
1688        };
1689        assert!(!b.is_empty());
1690    }
1691
1692    #[test]
1693    fn button_theme_merge_font_optional_nested() {
1694        let mut base = ButtonTheme {
1695            font: Some(FontSpec {
1696                family: Some("Noto Sans".into()),
1697                size: Some(FontSize::Px(11.0)),
1698                weight: None,
1699                ..Default::default()
1700            }),
1701            ..Default::default()
1702        };
1703        let overlay = ButtonTheme {
1704            font: Some(FontSpec {
1705                family: None,
1706                weight: Some(700),
1707                ..Default::default()
1708            }),
1709            ..Default::default()
1710        };
1711        base.merge(&overlay);
1712        let f = base.font.as_ref().unwrap();
1713        assert_eq!(f.family.as_deref(), Some("Noto Sans")); // preserved
1714        assert_eq!(f.weight, Some(700)); // overlay
1715    }
1716
1717    #[test]
1718    fn button_theme_toml_round_trip_with_font_and_border() {
1719        let b = ButtonTheme {
1720            background_color: Some(Rgba::rgb(200, 200, 200)),
1721            font: Some(FontSpec {
1722                family: Some("Inter".into()),
1723                size: Some(FontSize::Px(14.0)),
1724                weight: Some(400),
1725                ..Default::default()
1726            }),
1727            border: Some(WidgetBorderSpec {
1728                corner_radius: Some(4.0),
1729                ..Default::default()
1730            }),
1731            ..Default::default()
1732        };
1733        let toml_str = toml::to_string(&b).unwrap();
1734        let b2: ButtonTheme = toml::from_str(&toml_str).unwrap();
1735        assert_eq!(b, b2);
1736    }
1737
1738    // === WindowTheme tests ===
1739
1740    #[test]
1741    fn window_theme_has_new_fields() {
1742        let w = WindowTheme {
1743            inactive_title_bar_background: Some(Rgba::rgb(180, 180, 180)),
1744            inactive_title_bar_text_color: Some(Rgba::rgb(120, 120, 120)),
1745            title_bar_font: Some(FontSpec {
1746                weight: Some(700),
1747                ..Default::default()
1748            }),
1749            border: Some(WidgetBorderSpec {
1750                corner_radius: Some(4.0),
1751                shadow_enabled: Some(true),
1752                ..Default::default()
1753            }),
1754            ..Default::default()
1755        };
1756        assert!(!w.is_empty());
1757        assert!(w.inactive_title_bar_background.is_some());
1758        assert!(w.inactive_title_bar_text_color.is_some());
1759        assert!(w.title_bar_font.is_some());
1760        assert!(w.border.is_some());
1761    }
1762
1763    #[test]
1764    fn window_theme_default_is_empty() {
1765        assert!(WindowTheme::default().is_empty());
1766    }
1767
1768    // === DialogTheme tests ===
1769
1770    #[test]
1771    fn dialog_theme_button_order_works() {
1772        let d = DialogTheme {
1773            button_order: Some(DialogButtonOrder::PrimaryRight),
1774            min_width: Some(300.0),
1775            ..Default::default()
1776        };
1777        assert_eq!(d.button_order, Some(DialogButtonOrder::PrimaryRight));
1778        assert_eq!(d.min_width, Some(300.0));
1779        assert!(!d.is_empty());
1780    }
1781
1782    #[test]
1783    fn dialog_theme_button_order_toml_round_trip() {
1784        let d = DialogTheme {
1785            button_order: Some(DialogButtonOrder::PrimaryLeft),
1786            ..Default::default()
1787        };
1788        let toml_str = toml::to_string(&d).unwrap();
1789        let d2: DialogTheme = toml::from_str(&toml_str).unwrap();
1790        assert_eq!(d, d2);
1791    }
1792
1793    #[test]
1794    fn dialog_theme_default_is_empty() {
1795        assert!(DialogTheme::default().is_empty());
1796    }
1797
1798    // === SplitterTheme tests ===
1799
1800    #[test]
1801    fn splitter_theme_single_field_merge() {
1802        let mut base = SplitterTheme {
1803            divider_width: Some(4.0),
1804            ..Default::default()
1805        };
1806        let overlay = SplitterTheme {
1807            divider_width: Some(6.0),
1808            ..Default::default()
1809        };
1810        base.merge(&overlay);
1811        assert_eq!(base.divider_width, Some(6.0));
1812    }
1813
1814    #[test]
1815    fn splitter_theme_merge_none_preserves_base() {
1816        let mut base = SplitterTheme {
1817            divider_width: Some(4.0),
1818            ..Default::default()
1819        };
1820        let overlay = SplitterTheme::default();
1821        base.merge(&overlay);
1822        assert_eq!(base.divider_width, Some(4.0));
1823    }
1824
1825    #[test]
1826    fn splitter_theme_default_is_empty() {
1827        assert!(SplitterTheme::default().is_empty());
1828    }
1829
1830    #[test]
1831    fn splitter_theme_not_empty_when_set() {
1832        assert!(
1833            !SplitterTheme {
1834                divider_width: Some(4.0),
1835                ..Default::default()
1836            }
1837            .is_empty()
1838        );
1839    }
1840
1841    // === SeparatorTheme tests ===
1842
1843    #[test]
1844    fn separator_theme_single_field() {
1845        let s = SeparatorTheme {
1846            line_color: Some(Rgba::rgb(200, 200, 200)),
1847            ..Default::default()
1848        };
1849        assert!(!s.is_empty());
1850    }
1851
1852    // === All 25 widget theme defaults are empty ===
1853
1854    #[test]
1855    fn all_widget_theme_defaults_are_empty() {
1856        assert!(WindowTheme::default().is_empty());
1857        assert!(ButtonTheme::default().is_empty());
1858        assert!(InputTheme::default().is_empty());
1859        assert!(CheckboxTheme::default().is_empty());
1860        assert!(MenuTheme::default().is_empty());
1861        assert!(TooltipTheme::default().is_empty());
1862        assert!(ScrollbarTheme::default().is_empty());
1863        assert!(SliderTheme::default().is_empty());
1864        assert!(ProgressBarTheme::default().is_empty());
1865        assert!(TabTheme::default().is_empty());
1866        assert!(SidebarTheme::default().is_empty());
1867        assert!(ToolbarTheme::default().is_empty());
1868        assert!(StatusBarTheme::default().is_empty());
1869        assert!(ListTheme::default().is_empty());
1870        assert!(PopoverTheme::default().is_empty());
1871        assert!(SplitterTheme::default().is_empty());
1872        assert!(SeparatorTheme::default().is_empty());
1873        assert!(SwitchTheme::default().is_empty());
1874        assert!(DialogTheme::default().is_empty());
1875        assert!(SpinnerTheme::default().is_empty());
1876        assert!(ComboBoxTheme::default().is_empty());
1877        assert!(SegmentedControlTheme::default().is_empty());
1878        assert!(CardTheme::default().is_empty());
1879        assert!(ExpanderTheme::default().is_empty());
1880        assert!(LinkTheme::default().is_empty());
1881    }
1882
1883    // === Representative TOML round-trips ===
1884
1885    #[test]
1886    fn input_theme_toml_round_trip() {
1887        let t = InputTheme {
1888            background_color: Some(Rgba::rgb(255, 255, 255)),
1889            font: Some(FontSpec {
1890                family: Some("Noto Sans".into()),
1891                ..Default::default()
1892            }),
1893            border: Some(WidgetBorderSpec {
1894                color: Some(Rgba::rgb(180, 180, 180)),
1895                corner_radius: Some(4.0),
1896                ..Default::default()
1897            }),
1898            ..Default::default()
1899        };
1900        let toml_str = toml::to_string(&t).unwrap();
1901        let t2: InputTheme = toml::from_str(&toml_str).unwrap();
1902        assert_eq!(t, t2);
1903    }
1904
1905    #[test]
1906    fn switch_theme_toml_round_trip() {
1907        let s = SwitchTheme {
1908            checked_background: Some(Rgba::rgb(0, 120, 215)),
1909            track_width: Some(40.0),
1910            track_height: Some(20.0),
1911            thumb_diameter: Some(14.0),
1912            track_radius: Some(10.0),
1913            ..Default::default()
1914        };
1915        let toml_str = toml::to_string(&s).unwrap();
1916        let s2: SwitchTheme = toml::from_str(&toml_str).unwrap();
1917        assert_eq!(s, s2);
1918    }
1919
1920    #[test]
1921    fn new_sizes_use_px_keys() {
1922        let m = MenuTheme {
1923            bar_padding_horizontal: Some(10.0),
1924            bar_padding_vertical: Some(6.0),
1925            ..Default::default()
1926        };
1927        let toml_str = toml::to_string(&m).unwrap();
1928        assert!(
1929            toml_str.contains("bar_padding_horizontal_px = 10.0"),
1930            "{toml_str}"
1931        );
1932        assert!(
1933            toml_str.contains("bar_padding_vertical_px = 6.0"),
1934            "{toml_str}"
1935        );
1936        let m2: MenuTheme = toml::from_str(&toml_str).unwrap();
1937        assert_eq!(m, m2);
1938
1939        let m = MenuTheme {
1940            min_row_height: Some(29.0),
1941            panel_padding_horizontal: Some(3.0),
1942            panel_padding_vertical: Some(3.0),
1943            ..Default::default()
1944        };
1945        let toml_str = toml::to_string(&m).unwrap();
1946        for key in [
1947            "min_row_height_px = 29.0",
1948            "panel_padding_horizontal_px = 3.0",
1949            "panel_padding_vertical_px = 3.0",
1950        ] {
1951            assert!(toml_str.contains(key), "{toml_str}");
1952        }
1953        let m2: MenuTheme = toml::from_str(&toml_str).unwrap();
1954        assert_eq!(m, m2);
1955
1956        let s = SliderTheme {
1957            thumb_border_line_width: Some(1.0),
1958            ..Default::default()
1959        };
1960        let toml_str = toml::to_string(&s).unwrap();
1961        assert!(
1962            toml_str.contains("thumb_border_line_width_px = 1.0"),
1963            "{toml_str}"
1964        );
1965        let s2: SliderTheme = toml::from_str(&toml_str).unwrap();
1966        assert_eq!(s, s2);
1967    }
1968
1969    #[test]
1970    fn card_theme_with_border() {
1971        let c = CardTheme {
1972            background_color: Some(Rgba::rgb(255, 255, 255)),
1973            border: Some(WidgetBorderSpec {
1974                corner_radius: Some(8.0),
1975                shadow_enabled: Some(true),
1976                ..Default::default()
1977            }),
1978        };
1979        assert!(!c.is_empty());
1980    }
1981
1982    #[test]
1983    fn link_theme_has_underline_enabled_bool_field() {
1984        let l = LinkTheme {
1985            visited_text_color: Some(Rgba::rgb(100, 0, 200)),
1986            underline_enabled: Some(true),
1987            ..Default::default()
1988        };
1989        assert!(!l.is_empty());
1990        assert_eq!(l.underline_enabled, Some(true));
1991    }
1992
1993    #[test]
1994    fn status_bar_theme_has_font_and_background() {
1995        let s = StatusBarTheme {
1996            background_color: Some(Rgba::rgb(240, 240, 240)),
1997            font: Some(FontSpec {
1998                size: Some(FontSize::Px(11.0)),
1999                ..Default::default()
2000            }),
2001            ..Default::default()
2002        };
2003        assert!(!s.is_empty());
2004    }
2005
2006    // === SC4: Dual optional_nested (font + border) test widget ===
2007
2008    // SC4: Verify derive handles dual optional_nested (font + border)
2009    /// Test widget with both font and border nested sub-structs.
2010    #[serde_with::skip_serializing_none]
2011    #[derive(
2012        Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize, ThemeWidget,
2013    )]
2014    #[serde(default)]
2015    #[theme_layer(skip_inventory)]
2016    pub struct DualNestedTestWidget {
2017        pub background: Option<Rgba>,
2018        pub min_height: Option<f32>,
2019        #[theme(nested, resolved_type = "ResolvedFontSpec")]
2020        pub font: Option<FontSpec>,
2021        #[theme(nested, resolved_type = "ResolvedWidgetBorder")]
2022        pub border: Option<WidgetBorderSpec>,
2023    }
2024
2025    #[test]
2026    fn dual_nested_default_is_empty() {
2027        assert!(DualNestedTestWidget::default().is_empty());
2028    }
2029
2030    #[test]
2031    fn dual_nested_field_names() {
2032        assert_eq!(DualNestedTestWidget::FIELD_NAMES.len(), 4);
2033        assert!(DualNestedTestWidget::FIELD_NAMES.contains(&"background"));
2034        assert!(DualNestedTestWidget::FIELD_NAMES.contains(&"min_height"));
2035        assert!(DualNestedTestWidget::FIELD_NAMES.contains(&"font"));
2036        assert!(DualNestedTestWidget::FIELD_NAMES.contains(&"border"));
2037    }
2038
2039    #[test]
2040    fn dual_nested_not_empty_when_font_set() {
2041        let w = DualNestedTestWidget {
2042            font: Some(FontSpec {
2043                family: Some("Inter".into()),
2044                ..Default::default()
2045            }),
2046            ..Default::default()
2047        };
2048        assert!(!w.is_empty());
2049    }
2050
2051    #[test]
2052    fn dual_nested_not_empty_when_border_set() {
2053        let w = DualNestedTestWidget {
2054            border: Some(WidgetBorderSpec {
2055                color: Some(Rgba::rgb(100, 100, 100)),
2056                ..Default::default()
2057            }),
2058            ..Default::default()
2059        };
2060        assert!(!w.is_empty());
2061    }
2062
2063    #[test]
2064    fn dual_nested_merge_both_nested() {
2065        let mut base = DualNestedTestWidget {
2066            font: Some(FontSpec {
2067                family: Some("Noto Sans".into()),
2068                ..Default::default()
2069            }),
2070            ..Default::default()
2071        };
2072        let overlay = DualNestedTestWidget {
2073            border: Some(WidgetBorderSpec {
2074                corner_radius: Some(4.0),
2075                ..Default::default()
2076            }),
2077            ..Default::default()
2078        };
2079        base.merge(&overlay);
2080        assert!(base.font.is_some());
2081        assert!(base.border.is_some());
2082        assert_eq!(
2083            base.font.as_ref().and_then(|f| f.family.as_deref()),
2084            Some("Noto Sans")
2085        );
2086        assert_eq!(
2087            base.border.as_ref().and_then(|b| b.corner_radius),
2088            Some(4.0)
2089        );
2090    }
2091
2092    #[test]
2093    fn dual_nested_merge_inner_font_fields() {
2094        let mut base = DualNestedTestWidget {
2095            font: Some(FontSpec {
2096                family: Some("Noto Sans".into()),
2097                ..Default::default()
2098            }),
2099            ..Default::default()
2100        };
2101        let overlay = DualNestedTestWidget {
2102            font: Some(FontSpec {
2103                size: Some(FontSize::Px(14.0)),
2104                ..Default::default()
2105            }),
2106            ..Default::default()
2107        };
2108        base.merge(&overlay);
2109        let font = base.font.as_ref().unwrap();
2110        assert_eq!(font.family.as_deref(), Some("Noto Sans")); // preserved
2111        assert_eq!(font.size, Some(FontSize::Px(14.0))); // overlay sets
2112    }
2113
2114    #[test]
2115    fn dual_nested_toml_round_trip() {
2116        let w = DualNestedTestWidget {
2117            background: Some(Rgba::rgb(240, 240, 240)),
2118            min_height: Some(32.0),
2119            font: Some(FontSpec {
2120                family: Some("Inter".into()),
2121                size: Some(FontSize::Px(14.0)),
2122                weight: Some(400),
2123                ..Default::default()
2124            }),
2125            border: Some(WidgetBorderSpec {
2126                color: Some(Rgba::rgb(180, 180, 180)),
2127                corner_radius: Some(4.0),
2128                line_width: Some(1.0),
2129                ..Default::default()
2130            }),
2131        };
2132        let toml_str = toml::to_string(&w).unwrap();
2133        let w2: DualNestedTestWidget = toml::from_str(&toml_str).unwrap();
2134        assert_eq!(w, w2);
2135    }
2136
2137    // === LayoutTheme tests ===
2138
2139    // === validate_widget() generation tests ===
2140
2141    #[test]
2142    fn button_validate_widget_extracts_all_fields() {
2143        let button = ButtonTheme {
2144            background_color: Some(Rgba::rgb(200, 200, 200)),
2145            primary_background: Some(Rgba::rgb(0, 120, 215)),
2146            primary_text_color: Some(Rgba::rgb(255, 255, 255)),
2147            min_width: Some(80.0),
2148            min_height: Some(32.0),
2149            icon_text_gap: Some(8.0),
2150            disabled_opacity: Some(0.4),
2151            hover_background: Some(Rgba::rgb(210, 210, 210)),
2152            hover_text_color: Some(Rgba::rgb(0, 0, 0)),
2153            active_text_color: Some(Rgba::rgb(0, 0, 0)),
2154            disabled_text_color: Some(Rgba::rgb(128, 128, 128)),
2155            active_background: Some(Rgba::rgb(180, 180, 180)),
2156            disabled_background: Some(Rgba::rgb(220, 220, 220)),
2157            checked_background: Some(Rgba::rgb(190, 190, 190)),
2158            checked_text_color: None,
2159            hover_border_color: Some(Rgba::rgb(0, 120, 215)),
2160            focus_border_color: None,
2161            default_button_background: Some(Rgba::rgb(210, 230, 245)),
2162            default_button_text_color: None,
2163            default_button_border_color: None,
2164            font: Some(FontSpec {
2165                family: Some("Inter".into()),
2166                size: Some(FontSize::Px(14.0)),
2167                weight: Some(400),
2168                style: Some(crate::model::font::FontStyle::Normal),
2169                color: Some(Rgba::rgb(0, 0, 0)),
2170            }),
2171            border: Some(WidgetBorderSpec {
2172                color: Some(Rgba::rgb(100, 100, 100)),
2173                corner_radius: Some(4.0),
2174                line_width: Some(1.0),
2175                shadow_enabled: Some(false),
2176                padding_top: Some(6.0),
2177                padding_right: Some(12.0),
2178                padding_bottom: Some(6.0),
2179                padding_left: Some(12.0),
2180            }),
2181        };
2182        let mut missing = Vec::new();
2183        let resolved = ResolvedButtonTheme::validate_widget(&button, "button", 96.0, &mut missing);
2184        assert!(missing.is_empty(), "unexpected missing: {missing:?}");
2185        assert_eq!(resolved.background_color, Rgba::rgb(200, 200, 200));
2186        assert_eq!(resolved.min_width, 80.0);
2187        assert_eq!(resolved.font.family.as_ref(), "Inter");
2188        assert_eq!(resolved.font.size, 14.0);
2189        assert_eq!(resolved.border.corner_radius, 4.0);
2190        // soft_option fields pass through as Option
2191        assert_eq!(resolved.active_background, Some(Rgba::rgb(180, 180, 180)));
2192        assert_eq!(resolved.disabled_background, Some(Rgba::rgb(220, 220, 220)));
2193        assert_eq!(resolved.checked_background, Some(Rgba::rgb(190, 190, 190)));
2194        assert_eq!(resolved.checked_text_color, None);
2195        assert_eq!(resolved.hover_border_color, Some(Rgba::rgb(0, 120, 215)));
2196        assert_eq!(resolved.focus_border_color, None);
2197        assert_eq!(
2198            resolved.default_button_background,
2199            Some(Rgba::rgb(210, 230, 245))
2200        );
2201        assert_eq!(resolved.default_button_text_color, None);
2202        assert_eq!(resolved.default_button_border_color, None);
2203    }
2204
2205    #[test]
2206    fn button_validate_widget_records_missing_fields() {
2207        let button = ButtonTheme::default(); // all None
2208        let mut missing = Vec::new();
2209        let _ = ResolvedButtonTheme::validate_widget(&button, "button", 96.0, &mut missing);
2210        // option fields should be recorded as missing
2211        assert!(missing.contains(&"button.background_color".to_string()));
2212        assert!(missing.contains(&"button.min_width_px".to_string()));
2213        // font (optional_nested) should be recorded
2214        assert!(missing.contains(&"button.font".to_string()));
2215        // border (optional_nested) should be recorded
2216        assert!(missing.contains(&"button.border".to_string()));
2217        // soft_option fields should NOT be recorded as missing
2218        assert!(!missing.iter().any(|m| m.contains("active_background")));
2219        assert!(!missing.iter().any(|m| m.contains("disabled_background")));
2220    }
2221
2222    // === LayoutTheme tests ===
2223
2224    #[test]
2225    fn layout_theme_default_is_empty() {
2226        assert!(LayoutTheme::default().is_empty());
2227    }
2228
2229    #[test]
2230    fn layout_theme_not_empty_when_widget_gap_set() {
2231        let l = LayoutTheme {
2232            widget_gap: Some(8.0),
2233            ..Default::default()
2234        };
2235        assert!(!l.is_empty());
2236    }
2237
2238    #[test]
2239    fn layout_theme_field_names() {
2240        assert_eq!(LayoutTheme::FIELD_NAMES.len(), 4);
2241        assert!(LayoutTheme::FIELD_NAMES.contains(&"widget_gap_px"));
2242        assert!(LayoutTheme::FIELD_NAMES.contains(&"container_margin_px"));
2243        assert!(LayoutTheme::FIELD_NAMES.contains(&"window_margin_px"));
2244        assert!(LayoutTheme::FIELD_NAMES.contains(&"section_gap_px"));
2245    }
2246
2247    #[test]
2248    fn layout_theme_toml_round_trip() {
2249        let l = LayoutTheme {
2250            widget_gap: Some(8.0),
2251            container_margin: Some(12.0),
2252            window_margin: Some(16.0),
2253            section_gap: Some(24.0),
2254        };
2255        let toml_str = toml::to_string(&l).unwrap();
2256        let l2: LayoutTheme = toml::from_str(&toml_str).unwrap();
2257        assert_eq!(l, l2);
2258    }
2259
2260    #[test]
2261    fn layout_theme_merge() {
2262        let mut base = LayoutTheme {
2263            widget_gap: Some(6.0),
2264            container_margin: Some(10.0),
2265            ..Default::default()
2266        };
2267        let overlay = LayoutTheme {
2268            widget_gap: Some(8.0),
2269            section_gap: Some(24.0),
2270            ..Default::default()
2271        };
2272        base.merge(&overlay);
2273        // overlay widget_gap replaces base
2274        assert_eq!(base.widget_gap, Some(8.0));
2275        // base container_margin preserved
2276        assert_eq!(base.container_margin, Some(10.0));
2277        // overlay section_gap added
2278        assert_eq!(base.section_gap, Some(24.0));
2279        // window_margin stays None
2280        assert!(base.window_margin.is_none());
2281    }
2282}