1 | // Aseprite |
---|---|
2 | // Copyright (C) 2001-2018 David Capello |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "app/cmd/set_cel_frame.h" |
12 | |
13 | #include "app/doc.h" |
14 | #include "app/doc_event.h" |
15 | #include "doc/cel.h" |
16 | #include "doc/layer.h" |
17 | #include "doc/sprite.h" |
18 | |
19 | namespace app { |
20 | namespace cmd { |
21 | |
22 | using namespace doc; |
23 | |
24 | SetCelFrame::SetCelFrame(Cel* cel, frame_t frame) |
25 | : WithCel(cel) |
26 | , m_oldFrame(cel->frame()) |
27 | , m_newFrame(frame) |
28 | { |
29 | } |
30 | |
31 | void SetCelFrame::onExecute() |
32 | { |
33 | Cel* cel = this->cel(); |
34 | cel->layer()->moveCel(cel, m_newFrame); |
35 | cel->incrementVersion(); |
36 | } |
37 | |
38 | void SetCelFrame::onUndo() |
39 | { |
40 | Cel* cel = this->cel(); |
41 | cel->layer()->moveCel(cel, m_oldFrame); |
42 | cel->incrementVersion(); |
43 | } |
44 | |
45 | void SetCelFrame::onFireNotifications() |
46 | { |
47 | Cel* cel = this->cel(); |
48 | Doc* doc = static_cast<Doc*>(cel->sprite()->document()); |
49 | DocEvent ev(doc); |
50 | ev.sprite(cel->layer()->sprite()); |
51 | ev.layer(cel->layer()); |
52 | ev.cel(cel); |
53 | ev.frame(cel->frame()); |
54 | doc->notify_observers<DocEvent&>(&DocObserver::onCelFrameChanged, ev); |
55 | } |
56 | |
57 | } // namespace cmd |
58 | } // namespace app |
59 |