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#ifdef HAVE_CONFIG_H
8#include "config.h"
9#endif
10
11#include "app/cmd/clear_cel.h"
12
13#include "app/cmd/clear_image.h"
14#include "app/cmd/remove_cel.h"
15#include "app/doc.h"
16#include "doc/cel.h"
17#include "doc/layer.h"
18
19namespace app {
20namespace cmd {
21
22using namespace doc;
23
24ClearCel::ClearCel(Cel* cel)
25 : WithCel(cel)
26{
27 Doc* doc = static_cast<Doc*>(cel->document());
28
29 if (cel->layer()->isBackground()) {
30 Image* image = cel->image();
31 ASSERT(image);
32 if (image)
33 m_seq.add(new cmd::ClearImage(image,
34 doc->bgColor(cel->layer())));
35 }
36 else {
37 m_seq.add(new cmd::RemoveCel(cel));
38 }
39}
40
41void ClearCel::onExecute()
42{
43 m_seq.execute(context());
44}
45
46void ClearCel::onUndo()
47{
48 m_seq.undo();
49}
50
51void ClearCel::onRedo()
52{
53 m_seq.redo();
54}
55
56} // namespace cmd
57} // namespace app
58