mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Palette: Now overwrites a default palette on ::initialize
This commit is contained in:
parent
a73a95d7a1
commit
074071d5d0
2 changed files with 25 additions and 25 deletions
|
@ -26,23 +26,11 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <Palette.h>
|
||||
#include <iostream> // TODO Remove.
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Palette::initialize (const Rules& rules)
|
||||
// Use a default palette, which is overwritten in ::initialize.
|
||||
Palette::Palette ()
|
||||
{
|
||||
for (auto& entry : rules.all ("theme.palette.color"))
|
||||
{
|
||||
std::cout << "# Palette " << entry << " = " << rules.get (entry) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color Palette::next ()
|
||||
{
|
||||
// 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"),
|
||||
|
@ -58,8 +46,20 @@ Color Palette::next ()
|
|||
Color ("black on bright cyan"),
|
||||
Color ("black on bright yellow"),
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Palette::initialize (const Rules& rules)
|
||||
{
|
||||
_colors.clear ();
|
||||
for (auto& entry : rules.all ("theme.palette.color"))
|
||||
_colors.push_back (Color (rules.get (entry)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the next color in the list. Cycle to the beginning if necessary.
|
||||
Color Palette::next ()
|
||||
{
|
||||
return _colors[_current++ % _colors.size ()];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
class Palette
|
||||
{
|
||||
public:
|
||||
Palette () = default;
|
||||
Palette ();
|
||||
void initialize (const Rules&);
|
||||
Color next ();
|
||||
int size () const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue