ui::ThemeRequest¶
Header: winui/ui/themes/ThemeSource.hpp.
What an application asks for. Every field left at its default means "follow the system."
Pass one as ui::WindowOptions::theme, or later to Window::set_theme(), and the window resolves the Theme from it, and again whenever the system settings change. resolve_theme() makes a fixed Theme from one.
Example:
int run_app()
{
ui::ThemeRequest request;
request.mode = ui::ThemeMode::Dark;
request.accent_override = ui::Color::from_argb(0xFFE81123); // brand red instead of the OS accent
// The system decides everything the request leaves at its default:
ui::Window app{{.title = "App", .theme = request}};
// Later, follow the system's light or dark setting again:
request.mode = ui::ThemeMode::System;
app.set_theme(request);
return ui::run(app);
}
| Field | Type | Default | |
|---|---|---|---|
mode |
ThemeMode |
ThemeMode::System |
Light, Dark, HighContrast, or System (the default) to follow the system as it changes. |
accent_override |
std::optional<Color> |
A brand accent to use in place of OsThemeSnapshot::accent. Its lighter and darker shades are derived from it. Ignored by the light-only variants and under high contrast. | |
variant |
ThemeVariant |
ThemeVariant::System |
ThemeVariant::System, the default, follows mode, as do Fluent2, Fluent, Metro and Mdl2. Every other variant opts into a fixed, light-only palette true to its era, which ignores mode and accent_override since the era has no dark mode. The exception is a mode of HighContrast, which swaps in the era's contrast colors and keeps the era's shapes. theme_variant_supports_dark_mode() tells the two sets apart. |
classic_scheme |
std::optional<ClassicPalette> |
A ClassicPalette that replaces the era's default colors when variant is Windows9x or Windows3x. "Windows 9x with the Eggplant scheme" is one palette away, since those eras' themes are derived from a ClassicPalette alone. Ignored by every other variant, Luna and Aero included. |
|
early_scheme |
std::optional<EarlyPalette> |
The palette for variant Windows1x: Windows 1.01 or Windows 2.03, each in a color and a monochrome version. The variant defaults to EarlyPalette::windows_2x_color(), and this picks any of the other three. Ignored by every other variant. |
|
animations |
AnimationPreference |
AnimationPreference::System |
Whether controls animate (Theme::animations_enabled): System (the default) follows OsThemeSnapshot::animations_enabled, On and Off override it. Applies to every variant. |