1// Aseprite
2// Copyright (C) 2019 Igara Studio S.A.
3// Copyright (C) 2001-2018 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_DOC_EVENT_H_INCLUDED
9#define APP_DOC_EVENT_H_INCLUDED
10#pragma once
11
12#include "gfx/region.h"
13#include "doc/frame.h"
14
15namespace doc {
16 class Cel;
17 class Image;
18 class Layer;
19 class LayerImage;
20 class Slice;
21 class Sprite;
22 class Tag;
23 class Tileset;
24}
25
26namespace app {
27 class Doc;
28
29 class DocEvent {
30 public:
31 DocEvent(Doc* doc)
32 : m_doc(doc)
33 , m_sprite(nullptr)
34 , m_layer(nullptr)
35 , m_cel(nullptr)
36 , m_image(nullptr)
37 , m_imageIndex(-1)
38 , m_frame(0)
39 , m_tag(nullptr)
40 , m_slice(nullptr)
41 , m_tileset(nullptr)
42 , m_withUserData(nullptr)
43 , m_targetLayer(nullptr)
44 , m_targetFrame(0) {
45 }
46
47 // Source of the event.
48 Doc* document() const { return m_doc; }
49 doc::Sprite* sprite() const { return m_sprite; }
50 doc::Layer* layer() const { return m_layer; }
51 doc::Cel* cel() const { return m_cel; }
52 doc::Image* image() const { return m_image; }
53 int imageIndex() const { return m_imageIndex; }
54 doc::frame_t frame() const { return m_frame; }
55 doc::Tag* tag() const { return m_tag; }
56 doc::Slice* slice() const { return m_slice; }
57 doc::Tileset* tileset() const { return m_tileset; }
58 const gfx::Region& region() const { return m_region; }
59 doc::WithUserData* withUserData() const { return m_withUserData; }
60
61 void sprite(doc::Sprite* sprite) { m_sprite = sprite; }
62 void layer(doc::Layer* layer) { m_layer = layer; }
63 void cel(doc::Cel* cel) { m_cel = cel; }
64 void image(doc::Image* image) { m_image = image; }
65 void imageIndex(int imageIndex) { m_imageIndex = imageIndex; }
66 void frame(doc::frame_t frame) { m_frame = frame; }
67 void tag(doc::Tag* tag) { m_tag = tag; }
68 void slice(doc::Slice* slice) { m_slice = slice; }
69 void tileset(doc::Tileset* tileset) { m_tileset = tileset; }
70 void region(const gfx::Region& rgn) { m_region = rgn; }
71 void withUserData(doc::WithUserData* withUserData) { m_withUserData = withUserData; }
72
73 // Destination of the operation.
74 doc::Layer* targetLayer() const { return m_targetLayer; }
75 doc::frame_t targetFrame() const { return m_targetFrame; }
76
77 void targetLayer(doc::Layer* layer) { m_targetLayer = layer; }
78 void targetFrame(doc::frame_t frame) { m_targetFrame = frame; }
79
80 private:
81 Doc* m_doc;
82 doc::Sprite* m_sprite;
83 doc::Layer* m_layer;
84 doc::Cel* m_cel;
85 doc::Image* m_image;
86 int m_imageIndex;
87 doc::frame_t m_frame;
88 doc::Tag* m_tag;
89 doc::Slice* m_slice;
90 doc::Tileset* m_tileset;
91 gfx::Region m_region;
92 doc::WithUserData* m_withUserData;
93
94 // For copy/move commands, the m_layer/m_frame are source of the
95 // operation, and these are the destination of the operation.
96 doc::Layer* m_targetLayer;
97 doc::frame_t m_targetFrame;
98 };
99
100} // namespace app
101
102#endif
103