Enable cycling colors when palette size=1 so RGB/HSV colors are converted to index=0 anyway

In this way after ChangeColor command to increase/decrease an index is
used, we always got an index selected (even index=0 if palette size=1)
This commit is contained in:
David Capello 2021-09-01 10:38:35 -03:00
parent edb9f89456
commit 845f275ae7

View File

@ -76,7 +76,7 @@ void ChangeColorCommand::onExecute(Context* context)
break;
case IncrementIndex: {
const int palSize = get_current_palette()->size();
if (palSize > 1) {
if (palSize >= 1) {
// Seems safe to assume getIndex() will return a
// positive number, so use truncation modulo.
color = app::Color::fromIndex((color.getIndex() + 1) % palSize);
@ -85,7 +85,7 @@ void ChangeColorCommand::onExecute(Context* context)
}
case DecrementIndex: {
const int palSize = get_current_palette()->size();
if (palSize > 1) {
if (palSize >= 1) {
// Floor modulo.
color = app::Color::fromIndex(((color.getIndex() - 1) % palSize + palSize) % palSize);
}