ui::OsThemeSnapshot¶
Header: winui/ui/themes/ThemeSource.hpp.
The system's theme settings, before any app override is applied.
The library reads one from the system's settings. A default-constructed snapshot is light, with Windows' default blue accent and no high contrast, which resolves to the colors Windows 11 shows out of the box.
Example:
// Preview both modes side by side, whatever the OS is set to.
const ui::Theme light = ui::resolve_theme(ui::ThemeRequest{}, ui::OsThemeSnapshot{.dark = false});
const ui::Theme dark = ui::resolve_theme(ui::ThemeRequest{}, ui::OsThemeSnapshot{.dark = true});
ui::Window light_preview{{.title = "Light"}};
ui::Window dark_preview{{.title = "Dark"}};
light_preview.pin_theme(light);
dark_preview.pin_theme(dark);
| Field | Type | Default | |
|---|---|---|---|
dark |
bool |
false |
The system's app mode: true when "Choose your app mode" is set to Dark. |
accent |
Color |
Color::from_argb(0xFF0078D4) |
The user's accent color. |
accent_ramp |
AccentRamp |
The system's lighter and darker shades of accent. The defaults are the shades of Windows' default blue. |
|
high_contrast |
bool |
false |
Whether a contrast theme is on. When true, resolve_theme() draws with hc whatever the ThemeRequest says. |
hc |
HighContrastPalette |
The contrast theme's colors. Only read while high_contrast is true. |
|
menu_animation |
bool |
true |
The system's menu animation setting. With menu_fade and combo_box_animation, it sets how popups open in the Luna and Aero themes (Theme::popup_motion). All three are on by default. This one and combo_box_animation are off while the system turns UI effects off. |
menu_fade |
bool |
true |
See menu_animation: whether menus fade in (true) or slide in. |
combo_box_animation |
bool |
true |
See menu_animation: whether combo box drop-downs slide open. |
animations_enabled |
bool |
true |
The system's "Animation effects" setting. ThemeRequest::animations follows it by default. |
transparency_enabled |
bool |
true |
Whether the system draws transparency: "Transparency effects" is on in Settings, and neither Energy Saver nor a remote session turns it off. Fluent 2's in-app acrylic (Theme::overlay_material) follows it. |
system_variant |
ThemeVariant |
ThemeVariant::Fluent2 |
What ThemeVariant::System draws: Fluent2 on Windows 11 (build 22000 and later), Fluent on any earlier Windows. |