| 1 | // Aseprite | 
|---|
| 2 | // Copyright (C) 2001-2015  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_COPY_RECT_H_INCLUDED | 
|---|
| 8 | #define APP_CMD_COPY_RECT_H_INCLUDED | 
|---|
| 9 | #pragma once | 
|---|
| 10 |  | 
|---|
| 11 | #include "app/cmd.h" | 
|---|
| 12 | #include "app/cmd/with_image.h" | 
|---|
| 13 | #include "gfx/clip.h" | 
|---|
| 14 |  | 
|---|
| 15 | #include <vector> | 
|---|
| 16 |  | 
|---|
| 17 | namespace doc { | 
|---|
| 18 | class Image; | 
|---|
| 19 | } | 
|---|
| 20 |  | 
|---|
| 21 | namespace app { | 
|---|
| 22 | namespace cmd { | 
|---|
| 23 | using namespace doc; | 
|---|
| 24 |  | 
|---|
| 25 | class CopyRect : public Cmd | 
|---|
| 26 | , public WithImage { | 
|---|
| 27 | public: | 
|---|
| 28 | CopyRect(Image* dst, const Image* src, const gfx::Clip& clip); | 
|---|
| 29 |  | 
|---|
| 30 | protected: | 
|---|
| 31 | void onExecute() override; | 
|---|
| 32 | void onUndo() override; | 
|---|
| 33 | void onRedo() override; | 
|---|
| 34 | size_t onMemSize() const override { | 
|---|
| 35 | return sizeof(*this) + m_data.size(); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | private: | 
|---|
| 39 | void swap(); | 
|---|
| 40 | int lineSize(); | 
|---|
| 41 |  | 
|---|
| 42 | gfx::Clip m_clip; | 
|---|
| 43 | std::vector<uint8_t> m_data; | 
|---|
| 44 | }; | 
|---|
| 45 |  | 
|---|
| 46 | } // namespace cmd | 
|---|
| 47 | } // namespace app | 
|---|
| 48 |  | 
|---|
| 49 | #endif | 
|---|
| 50 |  | 
|---|