Style palette for TUI widgets. More...
#include <palette.h>
Public Types | |
| enum | ColorGroup { Active , Inactive , Disabled , GroupCount } |
| Color group based on widget state. More... | |
| enum | ColorRole { Window , WindowText , Base , Text , Button , ButtonText , ButtonBorder , ButtonLight , ButtonDark , FocusText , Highlight , HighlightedText , PlaceholderText , Mid , StatusBar , StatusBarText , ProgressFilled , ProgressFilledText , ProgressEmpty , ProgressEmptyText , RoleCount } |
| Semantic style role. More... | |
Public Member Functions | |
| TuiPalette () | |
| Constructs a palette with default styles. | |
| void | setStyle (ColorGroup group, ColorRole role, const TuiStyle &style) |
| Sets a style for a specific group and role. | |
| TuiStyle | style (ColorGroup group, ColorRole role) const |
| Returns the style for a specific group and role. | |
| TuiStyle | style (ColorRole role, const TuiStyleState &state) const |
| Returns the style for a role given widget state. | |
| TuiStyle | style (ColorRole role, bool focused, bool enabled=true) const |
| Convenience: picks the group from widget state flags. | |
Style palette for TUI widgets.
Provides a centralized set of TuiStyle values organized by role and state group. Widgets query the palette for their styles instead of hardcoding colors, giving a consistent look.
Each role stores a TuiStyle whose foreground, background, and attributes may individually be set or left ignored. Widgets typically merge several roles together (e.g. a text role on top of a background role) using TuiStyle::merged().
The TUI rendering pipeline gracefully degrades palette colors to match the terminal's color capability (see Terminal::ColorSupport). While any palette will render at any color level, choosing colors that are distinct under the target mode (e.g. high-contrast values for Basic 16-color, or well-separated grays for grayscale modes) produces significantly better results.
Color group based on widget state.
| Enumerator | |
|---|---|
| Active | Widget has focus. |
| Inactive | Widget does not have focus. |
| Disabled | Widget is disabled. |
Semantic style role.
| void TuiPalette::setStyle | ( | ColorGroup | group, |
| ColorRole | role, | ||
| const TuiStyle & | style | ||
| ) |
Sets a style for a specific group and role.
| group | The state group. |
| role | The semantic color role. |
| style | The style to set. |
| TuiStyle TuiPalette::style | ( | ColorGroup | group, |
| ColorRole | role | ||
| ) | const |
Returns the style for a specific group and role.
| group | The state group. |
| role | The semantic color role. |
Convenience: picks the group from widget state flags.
| role | The semantic color role. |
| focused | True if the widget has focus. |
| enabled | True if the widget is enabled. |
| TuiStyle TuiPalette::style | ( | ColorRole | role, |
| const TuiStyleState & | state | ||
| ) | const |