1 | // Aseprite |
---|---|
2 | // Copyright (C) 2019-2020 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/deselect_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 | DeselectMask::DeselectMask(Doc* doc) |
22 | : WithDocument(doc) |
23 | { |
24 | } |
25 | |
26 | void DeselectMask::onExecute() |
27 | { |
28 | Doc* doc = document(); |
29 | m_oldMask.reset(doc->isMaskVisible() ? new Mask(*doc->mask()): nullptr); |
30 | doc->setMaskVisible(false); |
31 | doc->notifySelectionChanged(); |
32 | } |
33 | |
34 | void DeselectMask::onUndo() |
35 | { |
36 | Doc* doc = document(); |
37 | |
38 | if (m_oldMask) { |
39 | doc->setMask(m_oldMask.get()); |
40 | doc->setMaskVisible(true); |
41 | m_oldMask.reset(); |
42 | } |
43 | |
44 | doc->notifySelectionChanged(); |
45 | } |
46 | |
47 | size_t DeselectMask::onMemSize() const |
48 | { |
49 | return sizeof(*this) + (m_oldMask ? m_oldMask->getMemSize(): 0); |
50 | } |
51 | |
52 | } // namespace cmd |
53 | } // namespace app |
54 |