mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Palette: Defaults now applied only on demand
This commit is contained in:
parent
8befd604bb
commit
b5ec5d2440
2 changed files with 23 additions and 20 deletions
|
@ -40,28 +40,33 @@ void Palette::initialize (const Rules& rules)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color Palette::next ()
|
||||
{
|
||||
return _colors[_current++ % _colors.size ()];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Palette::defaults ()
|
||||
{
|
||||
_colors =
|
||||
{
|
||||
// If there are no colors, then ::initialize was not provided with any, so use
|
||||
// a default set.
|
||||
if (! _colors.size ())
|
||||
_colors = {
|
||||
Color ("white on red"),
|
||||
Color ("white on blue"),
|
||||
Color ("black on green"),
|
||||
Color ("white on green"),
|
||||
Color ("black on magenta"),
|
||||
Color ("black on cyan"),
|
||||
Color ("black on yellow"),
|
||||
Color ("black on white"),
|
||||
Color ("white on bright red"),
|
||||
Color ("white on bright blue"),
|
||||
Color ("black on bright green"),
|
||||
Color ("white on bright green"),
|
||||
Color ("black on bright magenta"),
|
||||
Color ("black on bright cyan"),
|
||||
Color ("black on bright yellow"),
|
||||
};
|
||||
|
||||
// Return the next color in the list. Cycle to the beginning if necessary.
|
||||
return _colors[_current++ % _colors.size ()];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Palette::size () const
|
||||
{
|
||||
return static_cast <int> (_colors.size ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -38,9 +38,7 @@ public:
|
|||
Palette () = default;
|
||||
void initialize (const Rules&);
|
||||
Color next ();
|
||||
|
||||
private:
|
||||
void defaults ();
|
||||
int size () const;
|
||||
|
||||
private:
|
||||
std::vector <Color> _colors {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue