ui::Paint¶
Header: winui/ui/Paint.hpp.
What a color field takes: a fixed Color, a Brush (a gradient or acrylic), a ThemeColor read from the theme each time it is drawn, or nothing, which keeps the control's own color. A Color, an optional Color, any Brush, a ThemeColor and a captureless lambda taking a const Theme& all convert to it.
A control that paints one flat color (a text foreground, a background behind a Border, a table's row banding) paints a gradient as its first stop and an acrylic brush as its fallback_color. Shapes paint every kind.
Example:
ui::Property<ui::Color> picked{ui::colors::White};
ui::Property<bool> dark{false};
ui::Text{.text = "Fixed", .foreground = ui::Color::from_rgb(196, 43, 28)};
ui::Text{.text = "Themed", .foreground = [](const ui::Theme& t) { return t.colors().text_secondary; }};
ui::Rectangle{.fill = ui::LinearGradientBrush{{{0.0f, ui::colors::White}, {1.0f, ui::colors::Black}}}};
ui::Rectangle{.fill = picked}; // followed
ui::Rectangle{.fill = ui::bind(dark, [](bool on) { return on ? ui::colors::Black : ui::colors::White; })};
Paint¶
Nothing: the control keeps its own color.
Paint¶
Nothing, as the default.
Paint¶
A fixed color.
Paint¶
A fixed color, or nothing.
Paint¶
template <typename B>
Paint(B&& brush)
requires std::constructible_from<Brush, B> && (!std::same_as<std::remove_cvref_t<B>, Color>) && (!std::same_as<std::remove_cvref_t<B>, Paint>)
A Brush or one of its kinds: a LinearGradientBrush, RadialGradientBrush or AcrylicBrush.
Paint¶
A Brush, or nothing.
Paint¶
template <typename F>
Paint(F resource) noexcept
requires std::convertible_to<F, ThemeColor> && (!std::same_as<std::remove_cvref_t<F>, std::nullptr_t>)
A theme resource; a captureless lambda converts too. Null is nothing.
brush¶
The fixed brush (a Color included); nullopt for a resource or nothing.
color¶
The fixed paint as one color: the Color, a gradient's first stop or an acrylic brush's fallback_color; nullopt for a resource or nothing.
resource¶
The theme resource, or nullptr.
empty¶
True when neither a brush nor a resource is set.
resolve¶
The paint under theme as one color (see color()); nullopt when empty.
resolve_brush¶
The paint under theme as a brush, for a control that paints gradients and acrylic; nullopt when empty.
flat¶
The one color a brush paints in a control that paints flat colors.