Skip to content

ui::ThumbnailButton

Header: winui/ui/WindowShell.hpp.

A button under the taskbar thumbnail, as media players use for play, pause and skip. A window has at most seven. The OS fixes the set of buttons at the first call, so later calls can change a button's icon, tooltip, enabled and visible state, but not add or remove one. tool_tip, enabled and visible take a value or a property, and the window follows a bound one for as long as it holds the buttons. on_click is a std::function, so the button stays copyable in a brace-initialized std::vector.

Example:

ui::Property<int>  track{0};
ui::Property<bool> playing{false};
ui::Property<bool> has_previous{false};
ui::Command        next_track{.text = "Next", .execute = [&] { track = track.get() + 1; }};
window.set_thumbnail_buttons({
    {.icon = {.glyph = ui::IconGlyph{0xE892}}, .tool_tip = "Previous", .enabled = has_previous,
     .on_click = [&] { track = track.get() - 1; }},
    {.icon     = {.glyph = ui::IconGlyph{0xE768}},
     .tool_tip = ui::bind(playing, [](bool on) { return std::string{on ? "Pause" : "Play"}; }),
     .on_click = [&] { playing = !playing.get(); }},
    {.icon = {.glyph = ui::IconGlyph{0xE893}}, .tool_tip = "Next", .command = next_track},
});

icon

WindowIcon icon {}

The button's picture, scaled to the thumbnail toolbar's size.

tool_tip

Binding<std::string> tool_tip {}

Shown when the pointer rests on the button. Falls back to the command's description.

enabled

Binding<bool> enabled {true}

False grays the button out; a disabled command does too.

visible

Binding<bool> visible {true}

False hides the button while keeping its slot in the fixed set.

command

CommandRef command {}

Run with command_parameter after on_click; it also disables the button while it is disabled.

command_parameter

std::string command_parameter {}

Passed to the command's execute.

on_click

std::function<void()> on_click {}

Run on the UI thread when the button is clicked, before the command.

display_tool_tip

std::string display_tool_tip() const

tool_tip, or the command's description when it is empty.

is_enabled

bool is_enabled() const

Enabled, and its command (if any) is too.