1// Aseprite
2// Copyright (C) 2020 Igara Studio S.A.
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/set_tileset_name.h"
12
13#include "app/doc.h"
14#include "app/doc_event.h"
15#include "doc/tileset.h"
16
17namespace app {
18namespace cmd {
19
20SetTilesetName::SetTilesetName(Tileset* tileset, const std::string& name)
21 : WithTileset(tileset)
22 , m_oldName(tileset->name())
23 , m_newName(name)
24{
25}
26
27void SetTilesetName::onExecute()
28{
29 auto ts = tileset();
30 ts->setName(m_newName);
31 ts->incrementVersion();
32 ts->sprite()->incrementVersion();
33}
34
35void SetTilesetName::onUndo()
36{
37 auto ts = tileset();
38 ts->setName(m_oldName);
39 ts->incrementVersion();
40 ts->sprite()->incrementVersion();
41}
42
43} // namespace cmd
44} // namespace app
45