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