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

View File

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