1// Aseprite
2// Copyright (C) 2019 Igara Studio S.A.
3// Copyright (C) 2001-2016 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/copy_frame.h"
13
14#include "app/cmd/add_frame.h"
15#include "app/cmd/copy_cel.h"
16#include "app/cmd/set_frame_duration.h"
17#include "doc/sprite.h"
18#include "doc/layer.h"
19
20namespace app {
21namespace cmd {
22
23using namespace doc;
24
25CopyFrame::CopyFrame(Sprite* sprite, frame_t fromFrame, frame_t newFrame)
26 : WithSprite(sprite)
27 , m_fromFrame(fromFrame)
28 , m_newFrame(newFrame)
29{
30}
31
32void CopyFrame::onExecute()
33{
34 Sprite* sprite = this->sprite();
35 frame_t fromFrame = m_fromFrame;
36 int msecs = sprite->frameDuration(fromFrame);
37
38 executeAndAdd(new cmd::AddFrame(sprite, m_newFrame));
39 executeAndAdd(new cmd::SetFrameDuration(sprite, m_newFrame, msecs));
40
41 // Do not copy cels (cmd::CopyCel must be called from outside)
42}
43
44} // namespace cmd
45} // namespace app
46