1 | // Aseprite |
---|---|
2 | // Copyright (C) 2016-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_bounds.h" |
12 | |
13 | #include "app/doc.h" |
14 | #include "app/doc_event.h" |
15 | #include "doc/cel.h" |
16 | |
17 | namespace app { |
18 | namespace cmd { |
19 | |
20 | using namespace doc; |
21 | |
22 | SetCelBoundsF::SetCelBoundsF(Cel* cel, const gfx::RectF& bounds) |
23 | : WithCel(cel) |
24 | , m_oldBounds(cel->boundsF()) |
25 | , m_newBounds(bounds) |
26 | { |
27 | } |
28 | |
29 | void SetCelBoundsF::onExecute() |
30 | { |
31 | cel()->setBoundsF(m_newBounds); |
32 | cel()->incrementVersion(); |
33 | } |
34 | |
35 | void SetCelBoundsF::onUndo() |
36 | { |
37 | cel()->setBoundsF(m_oldBounds); |
38 | cel()->incrementVersion(); |
39 | } |
40 | |
41 | void SetCelBoundsF::onFireNotifications() |
42 | { |
43 | Cel* cel = this->cel(); |
44 | Doc* doc = static_cast<Doc*>(cel->document()); |
45 | DocEvent ev(doc); |
46 | ev.sprite(cel->sprite()); |
47 | ev.cel(cel); |
48 | doc->notify_observers<DocEvent&>(&DocObserver::onCelPositionChanged, ev); |
49 | } |
50 | |
51 | } // namespace cmd |
52 | } // namespace app |
53 |