Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_change_projection_color_command.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3
*
4
* SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
7
#include "
kis_change_projection_color_command.h
"
8
9
#include "
kis_image.h
"
10
#include "
kis_image_animation_interface.h
"
11
#include "
kis_command_ids.h
"
12
13
14
KisChangeProjectionColorCommand::KisChangeProjectionColorCommand
(
KisImageSP
image,
const
KoColor
&newColor,
KUndo2Command
*parent)
15
:
KUndo2Command
(
kundo2_noi18n
(
"CHANGE_PROJECTION_COLOR_COMMAND"
), parent),
16
m_image(image),
17
m_oldColor(image->defaultProjectionColor()),
18
m_newColor(newColor)
19
{
20
}
21
22
KisChangeProjectionColorCommand::~KisChangeProjectionColorCommand
()
23
{
24
}
25
26
int
KisChangeProjectionColorCommand::id
()
const
27
{
28
return
KisCommandUtils::ChangeProjectionColorCommand
;
29
}
30
31
bool
KisChangeProjectionColorCommand::mergeWith
(
const
KUndo2Command
* command)
32
{
33
const
KisChangeProjectionColorCommand
*other =
34
dynamic_cast<
const
KisChangeProjectionColorCommand
*
>
(command);
35
36
if
(!other) {
37
return
false
;
38
}
39
40
m_newColor
= other->
m_newColor
;
41
return
true
;
42
}
43
44
bool
KisChangeProjectionColorCommand::canMergeWith
(
const
KUndo2Command
*command)
const
45
{
46
const
KisChangeProjectionColorCommand
*other =
47
dynamic_cast<
const
KisChangeProjectionColorCommand
*
>
(command);
48
49
return
other;
50
}
51
52
void
KisChangeProjectionColorCommand::redo
()
53
{
54
KisImageSP
image =
m_image
.
toStrongRef
();
55
if
(!image) {
56
return
;
57
}
58
image->
setDefaultProjectionColor
(
m_newColor
);
59
image->
animationInterface
()->
setDefaultProjectionColor
(
m_newColor
);
60
}
61
62
void
KisChangeProjectionColorCommand::undo
()
63
{
64
KisImageSP
image =
m_image
.
toStrongRef
();
65
if
(!image) {
66
return
;
67
}
68
image->
setDefaultProjectionColor
(
m_oldColor
);
69
image->
animationInterface
()->
setDefaultProjectionColor
(
m_oldColor
);
70
}
KUndo2Command
Definition
kundo2stack.h:87
KisChangeProjectionColorCommand
Definition
kis_change_projection_color_command.h:20
KisChangeProjectionColorCommand::mergeWith
bool mergeWith(const KUndo2Command *command) override
Definition
kis_change_projection_color_command.cpp:31
KisChangeProjectionColorCommand::m_image
KisImageWSP m_image
Definition
kis_change_projection_color_command.h:33
KisChangeProjectionColorCommand::undo
void undo() override
Definition
kis_change_projection_color_command.cpp:62
KisChangeProjectionColorCommand::m_newColor
KoColor m_newColor
Definition
kis_change_projection_color_command.h:35
KisChangeProjectionColorCommand::id
int id() const override
Definition
kis_change_projection_color_command.cpp:26
KisChangeProjectionColorCommand::canMergeWith
bool canMergeWith(const KUndo2Command *command) const override
Definition
kis_change_projection_color_command.cpp:44
KisChangeProjectionColorCommand::m_oldColor
KoColor m_oldColor
Definition
kis_change_projection_color_command.h:34
KisChangeProjectionColorCommand::~KisChangeProjectionColorCommand
~KisChangeProjectionColorCommand() override
Definition
kis_change_projection_color_command.cpp:22
KisChangeProjectionColorCommand::redo
void redo() override
Definition
kis_change_projection_color_command.cpp:52
KisChangeProjectionColorCommand::KisChangeProjectionColorCommand
KisChangeProjectionColorCommand(KisImageSP image, const KoColor &newColor, KUndo2Command *parent=0)
Definition
kis_change_projection_color_command.cpp:14
KisImageAnimationInterface::setDefaultProjectionColor
void setDefaultProjectionColor(const KoColor &color)
Definition
kis_image_animation_interface.cpp:249
KisImage::animationInterface
KisImageAnimationInterface * animationInterface() const
Definition
kis_image.cc:2579
KisImage::setDefaultProjectionColor
void setDefaultProjectionColor(const KoColor &color)
Definition
kis_image.cc:1795
KisSharedPtr< KisImage >
KisWeakSharedPtr::toStrongRef
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
Definition
kis_shared_ptr.h:418
KoColor
Definition
KoColor.h:31
kis_change_projection_color_command.h
kis_command_ids.h
kis_image.h
kis_image_animation_interface.h
kundo2_noi18n
KUndo2MagicString kundo2_noi18n(const QString &text)
Definition
kundo2magicstring.h:146
KisCommandUtils::ChangeProjectionColorCommand
@ ChangeProjectionColorCommand
Definition
kis_command_ids.h:37
libs
image
commands_new
kis_change_projection_color_command.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52