Add PalettePicks::invert() member function

This commit is contained in:
David Capello 2021-05-20 17:57:22 -03:00
parent de8b6ff2b4
commit 2bc64cf5ff
2 changed files with 10 additions and 9 deletions

View File

@ -197,10 +197,8 @@ void SelectPaletteColorsCommand::onExecute(Context* context)
}
}
if (m_modifier == Modifier::UnusedColors) {
for (int i=0; i<usedEntries.size(); ++i)
usedEntries[i] = !usedEntries[i];
}
if (m_modifier == Modifier::UnusedColors)
usedEntries.invert();
context->setSelectedColors(usedEntries);
}
else if (m_modifier == Modifier::UsedTiles ||
@ -217,10 +215,8 @@ void SelectPaletteColorsCommand::onExecute(Context* context)
}
}
if (m_modifier == Modifier::UnusedTiles) {
for (int i=0; i<usedTiles.size(); ++i)
usedTiles[i] = !usedTiles[i];
}
if (m_modifier == Modifier::UnusedTiles)
usedTiles.invert();
context->setSelectedTiles(usedTiles);
}
}

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2019 Igara Studio S.A.
// Copyright (c) 2019-2021 Igara Studio S.A.
// Copyright (c) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
@ -80,6 +80,11 @@ namespace doc {
return result;
}
void invert() {
for (int i=0; i<size(); ++i)
m_items[i] = !m_items[i];
}
private:
list_type m_items;
};