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_SET_CEL_DATA_H_INCLUDED
8#define APP_CMD_SET_CEL_DATA_H_INCLUDED
9#pragma once
10
11#include "app/cmd.h"
12#include "app/cmd/with_cel.h"
13#include "doc/cel_data.h"
14
15#include <sstream>
16
17namespace app {
18namespace cmd {
19 using namespace doc;
20
21 class SetCelData : public Cmd
22 , public WithCel {
23 public:
24 SetCelData(Cel* cel, const CelDataRef& newData);
25
26 protected:
27 void onExecute() override;
28 void onUndo() override;
29 void onRedo() override;
30 size_t onMemSize() const override {
31 return sizeof(*this) +
32 (m_dataCopy ? m_dataCopy->getMemSize(): 0);
33 }
34
35 private:
36 void createCopy();
37
38 ObjectId m_oldDataId;
39 ObjectId m_oldImageId;
40 ObjectId m_newDataId;
41 CelDataRef m_dataCopy;
42
43 // Reference used only to keep the copy of the new CelData from
44 // the SetCelData() ctor until the SetCelData::onExecute() call.
45 // Then the reference is not used anymore.
46 CelDataRef m_newData;
47 };
48
49} // namespace cmd
50} // namespace app
51
52#endif
53