1 | // Aseprite |
---|---|
2 | // Copyright (C) 2019-2020 Igara Studio S.A. |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifndef APP_CMD_ADD_TILE_H_INCLUDED |
8 | #define APP_CMD_ADD_TILE_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "app/cmd.h" |
12 | #include "app/cmd/with_image.h" |
13 | #include "app/cmd/with_tileset.h" |
14 | #include "doc/image_ref.h" |
15 | #include "doc/tile.h" |
16 | |
17 | #include <sstream> |
18 | |
19 | namespace doc { |
20 | class Tileset; |
21 | } |
22 | |
23 | namespace app { |
24 | namespace cmd { |
25 | |
26 | class AddTile : public Cmd |
27 | , public WithTileset |
28 | , public WithImage { |
29 | public: |
30 | AddTile(doc::Tileset* tileset, const doc::ImageRef& image); |
31 | AddTile(doc::Tileset* tileset, const doc::tile_index ti); |
32 | |
33 | doc::tile_index tileIndex() const { return m_tileIndex; } |
34 | |
35 | protected: |
36 | void onExecute() override; |
37 | void onUndo() override; |
38 | void onRedo() override; |
39 | void onFireNotifications() override; |
40 | size_t onMemSize() const override { |
41 | return sizeof(*this) + m_size; |
42 | } |
43 | |
44 | private: |
45 | void addTile(doc::Tileset* tileset, |
46 | const doc::ImageRef& image); |
47 | |
48 | size_t m_size; |
49 | std::stringstream m_stream; |
50 | doc::tile_index m_tileIndex; |
51 | doc::ImageRef m_imageRef; |
52 | }; |
53 | |
54 | } // namespace cmd |
55 | } // namespace app |
56 | |
57 | #endif |
58 |