1 | // Aseprite |
---|---|
2 | // Copyright (C) 2019 Igara Studio S.A. |
3 | // Copyright (C) 2001-2015 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifdef HAVE_CONFIG_H |
9 | #include "config.h" |
10 | #endif |
11 | |
12 | #include "app/cmd/set_mask_position.h" |
13 | |
14 | #include "app/doc.h" |
15 | #include "doc/mask.h" |
16 | |
17 | namespace app { |
18 | namespace cmd { |
19 | |
20 | SetMaskPosition::SetMaskPosition(Doc* doc, const gfx::Point& pos) |
21 | : WithDocument(doc) |
22 | , m_oldPosition(doc->mask()->bounds().origin()) |
23 | , m_newPosition(pos) |
24 | { |
25 | } |
26 | |
27 | void SetMaskPosition::onExecute() |
28 | { |
29 | setMaskPosition(m_newPosition); |
30 | } |
31 | |
32 | void SetMaskPosition::onUndo() |
33 | { |
34 | setMaskPosition(m_oldPosition); |
35 | } |
36 | |
37 | void SetMaskPosition::setMaskPosition(const gfx::Point& pos) |
38 | { |
39 | Doc* doc = document(); |
40 | doc->mask()->setOrigin(pos.x, pos.y); |
41 | doc->resetTransformation(); |
42 | |
43 | doc->notifySelectionChanged(); |
44 | } |
45 | |
46 | } // namespace cmd |
47 | } // namespace app |
48 |