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 | #ifdef HAVE_CONFIG_H |
9 | #include "config.h" |
10 | #endif |
11 | |
12 | #include "app/cmd/reselect_mask.h" |
13 | |
14 | #include "app/cmd/set_mask.h" |
15 | #include "app/doc.h" |
16 | #include "doc/mask.h" |
17 | |
18 | namespace app { |
19 | namespace cmd { |
20 | |
21 | ReselectMask::ReselectMask(Doc* doc) |
22 | : WithDocument(doc) |
23 | { |
24 | } |
25 | |
26 | void ReselectMask::onExecute() |
27 | { |
28 | Doc* doc = document(); |
29 | |
30 | if (m_oldMask) { |
31 | doc->setMask(m_oldMask.get()); |
32 | m_oldMask.reset(); |
33 | } |
34 | |
35 | doc->setMaskVisible(true); |
36 | doc->notifySelectionChanged(); |
37 | } |
38 | |
39 | void ReselectMask::onUndo() |
40 | { |
41 | Doc* doc = document(); |
42 | |
43 | m_oldMask.reset(doc->isMaskVisible() ? new Mask(*doc->mask()): nullptr); |
44 | |
45 | doc->setMaskVisible(false); |
46 | doc->notifySelectionChanged(); |
47 | } |
48 | |
49 | size_t ReselectMask::onMemSize() const |
50 | { |
51 | return sizeof(*this) + (m_oldMask ? m_oldMask->getMemSize(): 0); |
52 | } |
53 | |
54 | } // namespace cmd |
55 | } // namespace app |
56 |