1// Aseprite
2// Copyright (C) 2018-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/assign_color_profile.h"
12
13#include "app/doc.h"
14#include "app/doc_event.h"
15#include "doc/sprite.h"
16
17namespace app {
18namespace cmd {
19
20AssignColorProfile::AssignColorProfile(doc::Sprite* sprite, const gfx::ColorSpaceRef& cs)
21 : WithSprite(sprite)
22 , m_oldCS(sprite->colorSpace())
23 , m_newCS(cs)
24{
25}
26
27void AssignColorProfile::onExecute()
28{
29 doc::Sprite* spr = sprite();
30 spr->setColorSpace(m_newCS);
31 spr->incrementVersion();
32}
33
34void AssignColorProfile::onUndo()
35{
36 doc::Sprite* spr = sprite();
37 spr->setColorSpace(m_oldCS);
38 spr->incrementVersion();
39}
40
41void AssignColorProfile::onFireNotifications()
42{
43 doc::Sprite* sprite = this->sprite();
44 Doc* doc = static_cast<Doc*>(sprite->document());
45 doc->notifyColorSpaceChanged();
46}
47
48} // namespace cmd
49} // namespace app
50