Palette: Now overwrites a default palette on ::initialize

This commit is contained in:
Paul Beckingham 2016-04-22 23:52:10 -04:00
parent a73a95d7a1
commit 074071d5d0
2 changed files with 25 additions and 25 deletions

View file

@ -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 ()];
}

View file

@ -35,7 +35,7 @@
class Palette
{
public:
Palette () = default;
Palette ();
void initialize (const Rules&);
Color next ();
int size () const;