Krita Source Code Documentation
Loading...
Searching...
No Matches
KisImageAnimSettingCommand Class Reference

#include <KisImageAnimSettingCommand.h>

+ Inheritance diagram for KisImageAnimSettingCommand:

Classes

struct  Settings
 

Public Member Functions

bool canMergeWith (const KUndo2Command *command) const override
 
int id () const override
 
 KisImageAnimSettingCommand ()=delete
 
 KisImageAnimSettingCommand (const KisImageAnimSettingCommand &)=delete
 
 KisImageAnimSettingCommand (KisImageAnimationInterface *const p_animInterface, Settings p_after, KUndo2Command *parent=nullptr)
 
bool mergeWith (const KUndo2Command *p_next) override
 
KisImageAnimSettingCommandoperator= (const KisImageAnimSettingCommand &)=delete
 
void redo () override
 
void undo () override
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () const
 
bool hasParent () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual void redoMergedCommands ()
 
void setEndTime ()
 
virtual void setEndTime (const QTime &time)
 
void setExtraData (KUndo2CommandExtraData *data)
 
void setText (const KUndo2MagicString &text)
 
void setTime ()
 
virtual void setTime (const QTime &time)
 
virtual void setTimedID (int timedID)
 
KUndo2MagicString text () const
 
virtual QTime time () const
 
virtual int timedId () const
 
virtual bool timedMergeWith (KUndo2Command *other)
 
virtual void undoMergedCommands ()
 
virtual ~KUndo2Command ()
 
- Public Member Functions inherited from KisAsynchronouslyMergeableCommandInterface
virtual ~KisAsynchronouslyMergeableCommandInterface ()
 

Private Attributes

Settings m_after
 
KisImageAnimationInterfacem_animInterface
 
Settings m_before
 

Detailed Description

Definition at line 18 of file KisImageAnimSettingCommand.h.

Constructor & Destructor Documentation

◆ KisImageAnimSettingCommand() [1/3]

KisImageAnimSettingCommand::KisImageAnimSettingCommand ( )
delete

◆ KisImageAnimSettingCommand() [2/3]

KisImageAnimSettingCommand::KisImageAnimSettingCommand ( const KisImageAnimSettingCommand & )
delete

◆ KisImageAnimSettingCommand() [3/3]

KisImageAnimSettingCommand::KisImageAnimSettingCommand ( KisImageAnimationInterface *const p_animInterface,
Settings p_after,
KUndo2Command * parent = nullptr )

Definition at line 12 of file KisImageAnimSettingCommand.cpp.

13 : KUndo2Command(kundo2_i18n("Update Animation Settings"), parent),
14 m_animInterface(p_animInterface),
15 m_after(p_after)
16{
17 m_before = {
18 p_animInterface->framerate(),
19 p_animInterface->documentPlaybackRange().start(),
20 p_animInterface->documentPlaybackRange().end()
21 };
22}
KUndo2Command(KUndo2Command *parent=0)
KisImageAnimationInterface * m_animInterface
const KisTimeSpan & documentPlaybackRange() const
documentPlaybackRange
int start() const
int end() const
KUndo2MagicString kundo2_i18n(const char *text)

References KisImageAnimationInterface::documentPlaybackRange(), KisTimeSpan::end(), KisImageAnimationInterface::framerate(), m_before, and KisTimeSpan::start().

Member Function Documentation

◆ canMergeWith()

bool KisImageAnimSettingCommand::canMergeWith ( const KUndo2Command * command) const
overridevirtual
Returns
true if command can be merged with (*this) command using KUndo2Command::mergeWith() call.

WARNING: if canMergeWith() returned true, then mergeWith() must also return true. Otherwise KisSavedMacroCommand will be able to enter inconsistent state and assert.

Implements KisAsynchronouslyMergeableCommandInterface.

Definition at line 51 of file KisImageAnimSettingCommand.cpp.

52{
53 const KisImageAnimSettingCommand *other = dynamic_cast<const KisImageAnimSettingCommand*>(p_other);
54
55 return other != nullptr;
56}

◆ id()

int KisImageAnimSettingCommand::id ( ) const
overridevirtual

Returns the ID of this command.

A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.

If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.

KUndo2QStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.

See also
mergeWith(), KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 46 of file KisImageAnimSettingCommand.cpp.

References KisCommandUtils::ImageAnimSettingCommandId.

◆ mergeWith()

bool KisImageAnimSettingCommand::mergeWith ( const KUndo2Command * command)
overridevirtual

Attempts to merge this command with command. Returns true on success; otherwise returns false.

If this function returns true, calling this command's redo() must have the same effect as redoing both this command and command. Similarly, calling this command's undo() must have the same effect as undoing command and this command.

KUndo2QStack will only try to merge two commands if they have the same id, and the id is not -1.

The default implementation returns false.

See also
id() KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 58 of file KisImageAnimSettingCommand.cpp.

59{
60 const KisImageAnimSettingCommand *next = dynamic_cast<const KisImageAnimSettingCommand*>(p_next);
61
62 if (!next) return false;
63
64 m_after = next->m_after;
65
66 return true;
67}
QAction * next(const QObject *recvr, const char *slot, QObject *parent)

References m_after.

◆ operator=()

KisImageAnimSettingCommand & KisImageAnimSettingCommand::operator= ( const KisImageAnimSettingCommand & )
delete

◆ redo()

void KisImageAnimSettingCommand::redo ( )
overridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KUndo2Command.

Definition at line 24 of file KisImageAnimSettingCommand.cpp.

References KisImageAnimSettingCommand::Settings::endFrame, KisImageAnimSettingCommand::Settings::FPS, KisTimeSpan::fromTimeToTime(), KIS_ASSERT, m_after, m_animInterface, KUndo2Command::redo(), KisImageAnimationInterface::setDocumentRange(), KisImageAnimationInterface::setFramerate(), and KisImageAnimSettingCommand::Settings::startFrame.

◆ undo()

void KisImageAnimSettingCommand::undo ( )
overridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KUndo2Command.

Definition at line 35 of file KisImageAnimSettingCommand.cpp.

36{
37 // RESET image animation settings back to before values..
39
41
44}
virtual void undo()

References KisImageAnimSettingCommand::Settings::endFrame, KisImageAnimSettingCommand::Settings::FPS, KisTimeSpan::fromTimeToTime(), KIS_ASSERT, m_animInterface, m_before, KisImageAnimationInterface::setDocumentRange(), KisImageAnimationInterface::setFramerate(), KisImageAnimSettingCommand::Settings::startFrame, and KUndo2Command::undo().

Member Data Documentation

◆ m_after

Settings KisImageAnimSettingCommand::m_after
private

Definition at line 44 of file KisImageAnimSettingCommand.h.

◆ m_animInterface

KisImageAnimationInterface* KisImageAnimSettingCommand::m_animInterface
private

Definition at line 41 of file KisImageAnimSettingCommand.h.

◆ m_before

Settings KisImageAnimSettingCommand::m_before
private

Definition at line 43 of file KisImageAnimSettingCommand.h.


The documentation for this class was generated from the following files: