libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TuiPalette Class Reference

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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ ColorGroup

Color group based on widget state.

Enumerator
Active 

Widget has focus.

Inactive 

Widget does not have focus.

Disabled 

Widget is disabled.

◆ ColorRole

Semantic style role.

Enumerator
Window 

Container/frame background.

WindowText 

Text on Window background.

Base 

Input/editable widget background.

Text 

Text on Base background.

Button 

Button background (legacy).

ButtonText 

Text on button backgrounds.

ButtonBorder 

Single-character border around buttons.

ButtonLight 

Button background in unpressed / active-tab state.

ButtonDark 

Button background in pressed / inactive-tab state.

FocusText 

Bright foreground for focused widgets.

Highlight 

Selected item / accent background.

HighlightedText 

Text on Highlight background.

PlaceholderText 

Placeholder/hint text.

Mid 

Borders, separators, frames.

StatusBar 

Status bar background.

StatusBarText 

Status bar text.

ProgressFilled 

Filled portion of progress bar.

ProgressFilledText 

Text on filled portion of progress bar.

ProgressEmpty 

Empty portion of progress bar.

ProgressEmptyText 

Text on empty portion of progress bar.

Member Function Documentation

◆ setStyle()

void TuiPalette::setStyle ( ColorGroup  group,
ColorRole  role,
const TuiStyle style 
)

Sets a style for a specific group and role.

Parameters
groupThe state group.
roleThe semantic color role.
styleThe style to set.

◆ style() [1/3]

TuiStyle TuiPalette::style ( ColorGroup  group,
ColorRole  role 
) const

Returns the style for a specific group and role.

Parameters
groupThe state group.
roleThe semantic color role.
Returns
The stored TuiStyle.

◆ style() [2/3]

TuiStyle TuiPalette::style ( ColorRole  role,
bool  focused,
bool  enabled = true 
) const

Convenience: picks the group from widget state flags.

Parameters
roleThe semantic color role.
focusedTrue if the widget has focus.
enabledTrue if the widget is enabled.

◆ style() [3/3]

TuiStyle TuiPalette::style ( ColorRole  role,
const TuiStyleState state 
) const

Returns the style for a role given widget state.

Selects the appropriate color group from the state and returns the stored TuiStyle.

Parameters
roleThe semantic color role.
stateThe widget state to derive the group from.
Returns
The stored TuiStyle for the derived group.

The documentation for this class was generated from the following file: