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

Visual properties of a TUI cell (everything except the character). More...

#include <style.h>

Public Types

enum  Attr : uint8_t {
  None = 0x00 , Bold = 0x01 , Dim = 0x02 , Italic = 0x04 ,
  Underline = 0x08 , Blink = 0x10 , Inverse = 0x20 , Strikethrough = 0x40
}
 Text attribute flags.
 

Public Member Functions

 TuiStyle ()=default
 Default constructor. All properties are ignored.
 
 TuiStyle (const Color &fg, const Color &bg, uint8_t attrs=None)
 Constructs with foreground, background, and attributes (all defined).
 
Color foreground () const
 Returns the foreground color.
 
Color background () const
 Returns the background color.
 
uint8_t attrs () const
 Returns the attribute flags.
 
uint8_t attrMask () const
 Returns the attribute mask (1 = defined, 0 = ignored).
 
void setForeground (const Color &color)
 Sets the foreground color.
 
void setBackground (const Color &color)
 Sets the background color.
 
void setAttrs (uint8_t attrs)
 Sets all attribute flags (marks all bits as defined).
 
void setAttrs (uint8_t attrs, uint8_t mask)
 Sets attribute flags with an explicit mask.
 
bool hasForeground () const
 Returns true if the foreground color is defined (not ignored).
 
bool hasBackground () const
 Returns true if the background color is defined (not ignored).
 
TuiStyle merged (const TuiStyle &below) const
 Merges this style on top of another.
 
bool operator== (const TuiStyle &o) const
 
bool operator!= (const TuiStyle &o) const
 

Static Public Member Functions

static TuiStyle fromForeground (const Color &fg, uint8_t attrs=None, uint8_t attrMask=0)
 Creates a foreground-only style (background ignored).
 
static TuiStyle fromBackground (const Color &bg)
 Creates a background-only style (foreground ignored).
 

Detailed Description

Visual properties of a TUI cell (everything except the character).

A TuiStyle bundles foreground color, background color, and text attributes into a single value. Any property can be flagged as "ignored" so that it inherits from a lower layer when styles are merged via merged().

An ignored color is represented by Color::Ignored (an invalid Color). Attributes use a separate mask: bits set in the mask are defined by this style; bits not in the mask are inherited during merging.

Member Function Documentation

◆ merged()

TuiStyle TuiStyle::merged ( const TuiStyle below) const

Merges this style on top of another.

Ignored properties in this style are filled from below.


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