1// Aseprite
2// Copyright (C) 2019 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_TILESET_H_INCLUDED
8#define APP_CMD_ADD_TILESET_H_INCLUDED
9#pragma once
10
11#include "app/cmd.h"
12#include "app/cmd/with_sprite.h"
13#include "app/cmd/with_tileset.h"
14#include "doc/tile.h"
15
16#include <sstream>
17
18namespace doc {
19 class Tileset;
20}
21
22namespace app {
23namespace cmd {
24
25 class AddTileset : public Cmd
26 , public WithSprite
27 , public WithTileset {
28 public:
29 AddTileset(doc::Sprite* sprite, doc::Tileset* tileset);
30 AddTileset(doc::Sprite* sprite, const doc::tileset_index tsi);
31
32 doc::tileset_index tilesetIndex() const { return m_tilesetIndex; }
33
34 protected:
35 void onExecute() override;
36 void onUndo() override;
37 void onRedo() override;
38 size_t onMemSize() const override {
39 return sizeof(*this) + m_size;
40 }
41
42 private:
43 void addTileset(doc::Tileset* tileset);
44
45 size_t m_size;
46 std::stringstream m_stream;
47 doc::tileset_index m_tilesetIndex;
48 };
49
50} // namespace cmd
51} // namespace app
52
53#endif
54