| 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 | #ifndef APP_CMD_CLEAR_RECT_H_INCLUDED |
| 8 | #define APP_CMD_CLEAR_RECT_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "app/cmd.h" |
| 12 | #include "app/cmd/with_image.h" |
| 13 | #include "app/cmd_sequence.h" |
| 14 | #include "doc/image_ref.h" |
| 15 | #include "gfx/fwd.h" |
| 16 | |
| 17 | #include <memory> |
| 18 | |
| 19 | namespace doc { |
| 20 | class Cel; |
| 21 | } |
| 22 | |
| 23 | namespace app { |
| 24 | namespace cmd { |
| 25 | using namespace doc; |
| 26 | |
| 27 | class ClearRect : public Cmd { |
| 28 | public: |
| 29 | ClearRect(Cel* cel, const gfx::Rect& bounds); |
| 30 | |
| 31 | protected: |
| 32 | void onExecute() override; |
| 33 | void onUndo() override; |
| 34 | void onRedo() override; |
| 35 | size_t onMemSize() const override { |
| 36 | return sizeof(*this) + m_seq.memSize() + |
| 37 | (m_copy ? m_copy->getMemSize(): 0); |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | void clear(); |
| 42 | void restore(); |
| 43 | |
| 44 | CmdSequence m_seq; |
| 45 | std::unique_ptr<WithImage> m_dstImage; |
| 46 | ImageRef m_copy; |
| 47 | int m_offsetX, m_offsetY; |
| 48 | color_t m_bgcolor; |
| 49 | }; |
| 50 | |
| 51 | } // namespace cmd |
| 52 | } // namespace app |
| 53 | |
| 54 | #endif |
| 55 | |