mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 01:20:17 +00:00
Refactor undo_can_undo/redo to Undo::canUndo/Redo.
This commit is contained in:
parent
12ce788d11
commit
b3546cda94
@ -49,7 +49,7 @@ bool RedoCommand::onEnabled(Context* context)
|
||||
const CurrentSpriteReader sprite(context);
|
||||
return
|
||||
sprite != NULL &&
|
||||
undo_can_redo(sprite->getUndo());
|
||||
sprite->getUndo()->canRedo();
|
||||
}
|
||||
|
||||
void RedoCommand::onExecute(Context* context)
|
||||
|
@ -49,7 +49,7 @@ bool UndoCommand::onEnabled(Context* context)
|
||||
const CurrentSpriteReader sprite(context);
|
||||
return
|
||||
sprite != NULL &&
|
||||
undo_can_undo(sprite->getUndo());
|
||||
sprite->getUndo()->canUndo();
|
||||
}
|
||||
|
||||
void UndoCommand::onExecute(Context* context)
|
||||
|
@ -700,7 +700,7 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
||||
/* undo */
|
||||
if (command && strcmp(command->short_name(), CommandId::undo) == 0) {
|
||||
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
||||
if (undo_can_undo(sprite->getUndo())) {
|
||||
if (sprite->getUndo()->canUndo()) {
|
||||
SpriteWriter sprite_writer(sprite);
|
||||
undo_do_undo(sprite_writer->getUndo());
|
||||
|
||||
@ -715,7 +715,7 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
||||
/* redo */
|
||||
if (command && strcmp(command->short_name(), CommandId::redo) == 0) {
|
||||
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
||||
if (undo_can_redo(sprite->getUndo())) {
|
||||
if (sprite->getUndo()->canRedo()) {
|
||||
SpriteWriter sprite_writer(sprite);
|
||||
undo_do_redo(sprite_writer->getUndo());
|
||||
|
||||
|
@ -314,29 +314,19 @@ void Undo::setEnabled(bool state)
|
||||
this->enabled = state;
|
||||
}
|
||||
|
||||
bool Undo::canUndo() const
|
||||
{
|
||||
return !jlist_empty(this->undo_stream->chunks);
|
||||
}
|
||||
|
||||
bool Undo::canRedo() const
|
||||
{
|
||||
return !jlist_empty(this->redo_stream->chunks);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// General undo routines
|
||||
|
||||
int undo_get_memsize(const Undo* undo)
|
||||
{
|
||||
ASSERT(undo);
|
||||
return
|
||||
undo->undo_stream->size +
|
||||
undo->redo_stream->size;
|
||||
}
|
||||
|
||||
bool undo_can_undo(const Undo* undo)
|
||||
{
|
||||
ASSERT(undo);
|
||||
return !jlist_empty(undo->undo_stream->chunks);
|
||||
}
|
||||
|
||||
bool undo_can_redo(const Undo* undo)
|
||||
{
|
||||
ASSERT(undo);
|
||||
return !jlist_empty(undo->redo_stream->chunks);
|
||||
}
|
||||
|
||||
void undo_do_undo(Undo* undo)
|
||||
{
|
||||
ASSERT(undo);
|
||||
@ -367,7 +357,7 @@ const char *undo_get_next_undo_label(const Undo* undo)
|
||||
{
|
||||
UndoChunk* chunk;
|
||||
|
||||
ASSERT(undo_can_undo(undo));
|
||||
ASSERT(undo->canUndo());
|
||||
|
||||
chunk = reinterpret_cast<UndoChunk*>(jlist_first_data(undo->undo_stream->chunks));
|
||||
return chunk->label;
|
||||
@ -377,7 +367,7 @@ const char *undo_get_next_redo_label(const Undo* undo)
|
||||
{
|
||||
UndoChunk* chunk;
|
||||
|
||||
ASSERT(undo_can_redo(undo));
|
||||
ASSERT(undo->canRedo());
|
||||
|
||||
chunk = reinterpret_cast<UndoChunk*>(jlist_first_data(undo->redo_stream->chunks));
|
||||
return chunk->label;
|
||||
|
@ -60,13 +60,11 @@ public:
|
||||
bool isEnabled() const;
|
||||
void setEnabled(bool state);
|
||||
|
||||
bool canUndo() const;
|
||||
bool canRedo() const;
|
||||
|
||||
};
|
||||
|
||||
int undo_get_memsize(const Undo* undo);
|
||||
|
||||
bool undo_can_undo(const Undo* undo);
|
||||
bool undo_can_redo(const Undo* undo);
|
||||
|
||||
void undo_do_undo(Undo* undo);
|
||||
void undo_do_redo(Undo* undo);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user