mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
963602444f
@ -53,7 +53,7 @@ Aseprite is being developed by [Igara Studio](https://www.igarastudio.com/):
|
||||
|
||||
* [David Capello](https://davidcapello.com/)
|
||||
* [Gaspar Capello](https://github.com/Gasparoken)
|
||||
* [Martin Capello](https://github.com/martincapello)
|
||||
* [Martín Capello](https://github.com/martincapello)
|
||||
|
||||
## Credits
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<separator text="Developer Team" horizontal="true" />
|
||||
<link text="David Capello" url="https://twitter.com/davidcapello" />
|
||||
<link text="Gaspar Capello" url="https://twitter.com/Gasparoken" />
|
||||
<link text="Martin Capello" url="https://twitter.com/martincapell0" />
|
||||
<link text="Martín Capello" url="https://twitter.com/martincapell0" />
|
||||
<vbox minheight="8" />
|
||||
</vbox>
|
||||
<separator vertical="true" />
|
||||
|
@ -831,6 +831,12 @@ void ColorBar::onRemapPalButtonClick()
|
||||
}
|
||||
|
||||
if (remap.isInvertible(usedEntries)) {
|
||||
for (int i=0; i<remap.size(); ++i) {
|
||||
if (i >= usedEntries.size() || !usedEntries[i]) {
|
||||
remap.unused(i);
|
||||
}
|
||||
}
|
||||
|
||||
tx(new cmd::RemapColors(sprite, remap));
|
||||
remapPixels = false;
|
||||
}
|
||||
|
@ -119,6 +119,9 @@ void ColorButton::onInitTheme(InitThemeEvent& ev)
|
||||
{
|
||||
ButtonBase::onInitTheme(ev);
|
||||
setStyle(SkinTheme::instance()->styles.colorButton());
|
||||
|
||||
if (m_window)
|
||||
m_window->initTheme();
|
||||
}
|
||||
|
||||
bool ColorButton::onProcessMessage(Message* msg)
|
||||
|
@ -806,7 +806,7 @@ static void remove_unused_tiles_from_tileset(
|
||||
modifiedTileIndexes[ti]) {
|
||||
cmds->executeAndAdd(new cmd::RemoveTile(tileset, tj));
|
||||
// Map to nothing, so the map can be invertible
|
||||
remap.map(ti, doc::Remap::kNoMap);
|
||||
remap.notile(ti);
|
||||
}
|
||||
else {
|
||||
remap.map(ti, tj++);
|
||||
|
@ -423,17 +423,24 @@ void remap_image(Image* image, const Remap& remap)
|
||||
case IMAGE_INDEXED:
|
||||
transform_image<IndexedTraits>(
|
||||
image, [&remap](color_t c) -> color_t {
|
||||
return remap[c];
|
||||
});
|
||||
auto to = remap[c];
|
||||
if (to != Remap::kUnused)
|
||||
return to;
|
||||
else
|
||||
return c;
|
||||
});
|
||||
break;
|
||||
case IMAGE_TILEMAP:
|
||||
transform_image<TilemapTraits>(
|
||||
image, [&remap](color_t c) -> color_t {
|
||||
if (c == notile || remap[c] == Remap::kNoMap)
|
||||
return notile;
|
||||
else
|
||||
return remap[c];
|
||||
});
|
||||
auto to = remap[c];
|
||||
if (c == notile || to == Remap::kNoTile)
|
||||
return notile;
|
||||
else if (to != Remap::kUnused)
|
||||
return to;
|
||||
else
|
||||
return c;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -139,21 +139,19 @@ Remap Remap::invert() const
|
||||
Remap inv(size());
|
||||
|
||||
for (int i=0; i<size(); ++i)
|
||||
inv.m_map[i] = kNoMap;
|
||||
inv.unused(i);
|
||||
|
||||
for (int i=0; i<size(); ++i) {
|
||||
int j = m_map[i];
|
||||
if (j == kNoMap ||
|
||||
// Already mapped
|
||||
inv.m_map[j] != kNoMap)
|
||||
if (j == kUnused ||
|
||||
j == kNoTile ||
|
||||
inv.m_map[j] != kUnused) { // Already mapped (strange case, we
|
||||
// cannot invert this Remap)
|
||||
continue;
|
||||
}
|
||||
inv.map(j, i);
|
||||
}
|
||||
|
||||
for (int i=0; i<size(); ++i)
|
||||
if (inv.m_map[i] == kNoMap)
|
||||
inv.m_map[i] = i;
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
@ -178,8 +176,10 @@ bool Remap::isInvertible(const PalettePicks& usedEntries) const
|
||||
continue;
|
||||
|
||||
int j = m_map[i];
|
||||
if (j == kNoMap)
|
||||
if (j == kUnused ||
|
||||
j == kNoTile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (picks[j])
|
||||
return false;
|
||||
@ -192,8 +192,11 @@ bool Remap::isInvertible(const PalettePicks& usedEntries) const
|
||||
bool Remap::isIdentity() const
|
||||
{
|
||||
for (int i=0; i<size(); ++i) {
|
||||
if (m_map[i] != i)
|
||||
int j = m_map[i];
|
||||
if (j != i &&
|
||||
j != kUnused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -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.
|
||||
@ -19,7 +19,13 @@ namespace doc {
|
||||
|
||||
class Remap {
|
||||
public:
|
||||
static const int kNoMap = -1;
|
||||
// Unused is like a "no map" operation, we don't want to remap
|
||||
// this entry.
|
||||
constexpr static const int kUnused = -1;
|
||||
|
||||
// NoTile is to specify that we want to remap a tile to the
|
||||
// doc::notile value.
|
||||
constexpr static const int kNoTile = -2;
|
||||
|
||||
Remap(int entries = 1) : m_map(entries, 0) { }
|
||||
|
||||
@ -30,14 +36,20 @@ namespace doc {
|
||||
// Maps input "fromIndex" value, to "toIndex" output.
|
||||
void map(int fromIndex, int toIndex) {
|
||||
ASSERT(fromIndex >= 0 && fromIndex < size());
|
||||
// toIndex = kNoMap means (there is no remap for this value, useful
|
||||
// to ignore this entry when we invert the map)
|
||||
ASSERT((toIndex == kNoMap) ||
|
||||
(toIndex >= 0 && toIndex < size()));
|
||||
|
||||
ASSERT(toIndex >= 0 && toIndex < size());
|
||||
m_map[fromIndex] = toIndex;
|
||||
}
|
||||
|
||||
void unused(int i) {
|
||||
ASSERT(i >= 0 && i < size());
|
||||
m_map[i] = kUnused;
|
||||
}
|
||||
|
||||
void notile(int i) {
|
||||
ASSERT(i >= 0 && i < size());
|
||||
m_map[i] = kNoTile;
|
||||
}
|
||||
|
||||
int operator[](int index) const {
|
||||
//ASSERT(index >= 0 && index < size());
|
||||
if (index >= 0 && index < size())
|
||||
|
Loading…
x
Reference in New Issue
Block a user