| 1 | // Aseprite |
| 2 | // Copyright (C) 2019-2021 Igara Studio S.A. |
| 3 | // Copyright (C) 2001-2015 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifndef APP_CMD_SET_PALETTE_H_INCLUDED |
| 9 | #define APP_CMD_SET_PALETTE_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "app/cmd.h" |
| 13 | #include "app/cmd/with_sprite.h" |
| 14 | #include "doc/color.h" |
| 15 | #include "doc/frame.h" |
| 16 | |
| 17 | #include <vector> |
| 18 | |
| 19 | namespace doc { |
| 20 | class Palette; |
| 21 | class Sprite; |
| 22 | } |
| 23 | |
| 24 | namespace app { |
| 25 | namespace cmd { |
| 26 | using namespace doc; |
| 27 | |
| 28 | class SetPalette : public Cmd |
| 29 | , public WithSprite { |
| 30 | public: |
| 31 | SetPalette(Sprite* sprite, frame_t frame, const Palette* newPalette); |
| 32 | |
| 33 | protected: |
| 34 | void onExecute() override; |
| 35 | void onUndo() override; |
| 36 | void onFireNotifications() override; |
| 37 | size_t onMemSize() const override { |
| 38 | return sizeof(*this) + |
| 39 | sizeof(doc::color_t) * (m_oldColors.size() + |
| 40 | m_newColors.size()); |
| 41 | } |
| 42 | |
| 43 | private: |
| 44 | frame_t m_frame; |
| 45 | int m_from, m_to; |
| 46 | int m_oldNColors; |
| 47 | int m_newNColors; |
| 48 | int m_oldTransparentIndex; |
| 49 | int m_newTransparentIndex; |
| 50 | std::vector<color_t> m_oldColors; |
| 51 | std::vector<color_t> m_newColors; |
| 52 | }; |
| 53 | |
| 54 | } // namespace cmd |
| 55 | } // namespace app |
| 56 | |
| 57 | #endif |
| 58 | |