2015-03-23 15:25:32 +00:00
|
|
|
// Aseprite Document Library
|
|
|
|
// Copyright (c) 2001-2015 David Capello
|
|
|
|
//
|
|
|
|
// This file is released under the terms of the MIT license.
|
|
|
|
// Read LICENSE.txt for more information.
|
|
|
|
|
|
|
|
#ifndef DOC_REMAP_H_INCLUDED
|
|
|
|
#define DOC_REMAP_H_INCLUDED
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace doc {
|
|
|
|
|
2015-05-09 15:20:58 +00:00
|
|
|
class PalettePicks;
|
|
|
|
|
2015-03-23 15:25:32 +00:00
|
|
|
class Remap {
|
|
|
|
public:
|
|
|
|
Remap(int entries) : m_map(entries, 0) { }
|
|
|
|
|
|
|
|
int size() const {
|
|
|
|
return (int)m_map.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void map(int fromIndex, int toIndex) {
|
|
|
|
ASSERT(fromIndex >= 0 && fromIndex < size());
|
|
|
|
ASSERT(toIndex >= 0 && toIndex < size());
|
|
|
|
|
|
|
|
m_map[fromIndex] = toIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
int operator[](int index) const {
|
2015-06-18 19:20:42 +00:00
|
|
|
//ASSERT(index >= 0 && index < size());
|
|
|
|
if (index >= 0 && index < size())
|
|
|
|
return m_map[index];
|
|
|
|
else
|
|
|
|
return index; // No remap
|
2015-03-23 15:25:32 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 15:57:59 +00:00
|
|
|
void merge(const Remap& other);
|
|
|
|
Remap invert() const;
|
|
|
|
|
|
|
|
int getMemSize() const {
|
|
|
|
return sizeof(*this) + sizeof(int)*size();
|
|
|
|
}
|
|
|
|
|
2015-03-23 15:25:32 +00:00
|
|
|
private:
|
|
|
|
std::vector<int> m_map;
|
|
|
|
};
|
|
|
|
|
2015-05-09 18:57:46 +00:00
|
|
|
// Creates a map to move a set of selected entries before the given
|
|
|
|
// index "beforeIndex".
|
|
|
|
Remap create_remap_to_move_picks(const PalettePicks& picks, int beforeIndex);
|
|
|
|
|
|
|
|
Remap create_remap_to_expand_palette(int size, int count, int beforeIndex);
|
|
|
|
|
2015-03-23 15:25:32 +00:00
|
|
|
} // namespace doc
|
|
|
|
|
|
|
|
#endif
|