1// Aseprite
2// Copyright (C) 2001-2016 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifndef APP_CMD_ADD_LAYER_H_INCLUDED
8#define APP_CMD_ADD_LAYER_H_INCLUDED
9#pragma once
10
11#include "app/cmd.h"
12#include "app/cmd/with_layer.h"
13
14#include <sstream>
15
16namespace doc {
17 class Layer;
18}
19
20namespace app {
21namespace cmd {
22 using namespace doc;
23
24 class AddLayer : public Cmd {
25 public:
26 AddLayer(Layer* group, Layer* newLayer, Layer* afterThis);
27
28 protected:
29 void onExecute() override;
30 void onUndo() override;
31 void onRedo() override;
32 size_t onMemSize() const override {
33 return sizeof(*this) + m_size;
34 }
35
36 private:
37 void addLayer(Layer* group, Layer* newLayer, Layer* afterThis);
38 void removeLayer(Layer* group, Layer* layer);
39
40 WithLayer m_group;
41 WithLayer m_newLayer;
42 WithLayer m_afterThis;
43 size_t m_size;
44 std::stringstream m_stream;
45 };
46
47} // namespace cmd
48} // namespace app
49
50#endif
51