Rename DocumentUndo -> DocUndo

This commit is contained in:
David Capello 2018-07-07 02:55:27 -03:00
parent 457a9999b5
commit ac7e48d92d
20 changed files with 83 additions and 83 deletions

View File

@ -496,13 +496,13 @@ add_library(app-lib
console.cpp
context.cpp
context_flags.cpp
doc_undo.cpp
document.cpp
document_api.cpp
document_diff.cpp
document_exporter.cpp
document_range.cpp
document_range_ops.cpp
document_undo.cpp
documents.cpp
extensions.cpp
extra_cel.cpp

View File

@ -16,9 +16,9 @@
#include "app/commands/commands.h"
#include "app/commands/params.h"
#include "app/console.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_exporter.h"
#include "app/document_undo.h"
#include "app/file/file.h"
#include "app/filename_formatter.h"
#include "app/restore_visible_layers.h"

View File

@ -18,7 +18,7 @@
namespace app {
// Cmds created on each Transaction.
// The whole DocumentUndo contains a list of these CmdTransaction.
// The whole DocUndo contains a list of these CmdTransaction.
class CmdTransaction : public CmdSequence {
public:
CmdTransaction(const std::string& label,

View File

@ -12,8 +12,8 @@
#include "app/commands/command.h"
#include "app/console.h"
#include "app/context_access.h"
#include "app/doc_undo.h"
#include "app/document_api.h"
#include "app/document_undo.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/transaction.h"

View File

@ -16,8 +16,8 @@
#include "app/commands/params.h"
#include "app/console.h"
#include "app/context_access.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_undo.h"
#include "app/file/file.h"
#include "app/file/gif_format.h"
#include "app/file/png_format.h"

View File

@ -11,7 +11,7 @@
#include "app/app.h"
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/document_undo.h"
#include "app/doc_undo.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
@ -66,7 +66,7 @@ void UndoCommand::onExecute(Context* context)
{
ContextWriter writer(context);
Document* document(writer.document());
DocumentUndo* undo = document->undoHistory();
DocUndo* undo = document->undoHistory();
#ifdef ENABLE_UI
Sprite* sprite = document->sprite();

View File

@ -13,10 +13,10 @@
#include "app/console.h"
#include "app/context.h"
#include "app/context_observer.h"
#include "app/doc_undo.h"
#include "app/doc_undo_observer.h"
#include "app/document.h"
#include "app/document_access.h"
#include "app/document_undo.h"
#include "app/document_undo_observer.h"
#include "app/documents_observer.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
@ -34,7 +34,7 @@ namespace app {
class UndoHistoryWindow : public app::gen::UndoHistory,
public ContextObserver,
public DocumentsObserver,
public DocumentUndoObserver {
public DocUndoObserver {
public:
class Item : public ui::ListItem {
public:
@ -132,8 +132,8 @@ private:
detachDocument();
}
// DocumentUndoObserver
void onAddUndoState(DocumentUndo* history) override {
// DocUndoObserver
void onAddUndoState(DocUndo* history) override {
ASSERT(history->currentState());
Item* item = new Item(history->currentState());
actions()->addChild(item);
@ -142,7 +142,7 @@ private:
actions()->selectChild(item);
}
void onDeleteUndoState(DocumentUndo* history,
void onDeleteUndoState(DocUndo* history,
undo::UndoState* state) override {
for (auto child : actions()->children()) {
Item* item = static_cast<Item*>(child);
@ -157,15 +157,15 @@ private:
view()->updateView();
}
void onCurrentUndoStateChange(DocumentUndo* history) override {
void onCurrentUndoStateChange(DocUndo* history) override {
selectState(history->currentState());
}
void onClearRedo(DocumentUndo* history) override {
void onClearRedo(DocUndo* history) override {
refillList(history);
}
void onTotalUndoSizeChange(DocumentUndo* history) override {
void onTotalUndoSizeChange(DocUndo* history) override {
updateTitle();
}
@ -176,7 +176,7 @@ private:
if (!document)
return;
DocumentUndo* history = m_document->undoHistory();
DocUndo* history = m_document->undoHistory();
history->add_observer(this);
refillList(history);
@ -202,7 +202,7 @@ private:
view()->updateView();
}
void refillList(DocumentUndo* history) {
void refillList(DocUndo* history) {
clearList();
// Create an item to reference the initial state (undo state == nullptr)

View File

@ -8,13 +8,13 @@
#include "config.h"
#endif
#include "app/document_undo.h"
#include "app/doc_undo.h"
#include "app/app.h"
#include "app/cmd.h"
#include "app/cmd_transaction.h"
#include "app/context.h"
#include "app/document_undo_observer.h"
#include "app/doc_undo_observer.h"
#include "app/pref/preferences.h"
#include "base/mem_utils.h"
#include "undo/undo_history.h"
@ -28,7 +28,7 @@
namespace app {
DocumentUndo::DocumentUndo()
DocUndo::DocUndo()
: m_undoHistory(this)
, m_ctx(nullptr)
, m_totalUndoSize(0)
@ -37,12 +37,12 @@ DocumentUndo::DocumentUndo()
{
}
void DocumentUndo::setContext(Context* ctx)
void DocUndo::setContext(Context* ctx)
{
m_ctx = ctx;
}
void DocumentUndo::add(CmdTransaction* cmd)
void DocUndo::add(CmdTransaction* cmd)
{
ASSERT(cmd);
UNDO_TRACE("UNDO: Add state <%s> of %s to %s\n",
@ -59,8 +59,8 @@ void DocumentUndo::add(CmdTransaction* cmd)
m_undoHistory.add(cmd);
m_totalUndoSize += cmd->memSize();
notify_observers(&DocumentUndoObserver::onAddUndoState, this);
notify_observers(&DocumentUndoObserver::onTotalUndoSizeChange, this);
notify_observers(&DocUndoObserver::onAddUndoState, this);
notify_observers(&DocUndoObserver::onTotalUndoSizeChange, this);
if (App::instance()) {
const size_t undoLimitSize =
@ -87,17 +87,17 @@ void DocumentUndo::add(CmdTransaction* cmd)
base::get_pretty_memory_size(m_totalUndoSize).c_str());
}
bool DocumentUndo::canUndo() const
bool DocUndo::canUndo() const
{
return m_undoHistory.canUndo();
}
bool DocumentUndo::canRedo() const
bool DocUndo::canRedo() const
{
return m_undoHistory.canRedo();
}
void DocumentUndo::undo()
void DocUndo::undo()
{
const undo::UndoState* state = nextUndo();
ASSERT(state);
@ -106,14 +106,14 @@ void DocumentUndo::undo()
m_totalUndoSize -= cmd->memSize();
{
m_undoHistory.undo();
notify_observers(&DocumentUndoObserver::onCurrentUndoStateChange, this);
notify_observers(&DocUndoObserver::onCurrentUndoStateChange, this);
}
m_totalUndoSize += cmd->memSize();
if (m_totalUndoSize != oldSize)
notify_observers(&DocumentUndoObserver::onTotalUndoSizeChange, this);
notify_observers(&DocUndoObserver::onTotalUndoSizeChange, this);
}
void DocumentUndo::redo()
void DocUndo::redo()
{
const undo::UndoState* state = nextRedo();
ASSERT(state);
@ -122,36 +122,36 @@ void DocumentUndo::redo()
m_totalUndoSize -= cmd->memSize();
{
m_undoHistory.redo();
notify_observers(&DocumentUndoObserver::onCurrentUndoStateChange, this);
notify_observers(&DocUndoObserver::onCurrentUndoStateChange, this);
}
m_totalUndoSize += cmd->memSize();
if (m_totalUndoSize != oldSize)
notify_observers(&DocumentUndoObserver::onTotalUndoSizeChange, this);
notify_observers(&DocUndoObserver::onTotalUndoSizeChange, this);
}
void DocumentUndo::clearRedo()
void DocUndo::clearRedo()
{
m_undoHistory.clearRedo();
notify_observers(&DocumentUndoObserver::onClearRedo, this);
notify_observers(&DocUndoObserver::onClearRedo, this);
}
bool DocumentUndo::isSavedState() const
bool DocUndo::isSavedState() const
{
return (!m_savedStateIsLost && m_savedCounter == 0);
}
void DocumentUndo::markSavedState()
void DocUndo::markSavedState()
{
m_savedCounter = 0;
m_savedStateIsLost = false;
}
void DocumentUndo::impossibleToBackToSavedState()
void DocUndo::impossibleToBackToSavedState()
{
m_savedStateIsLost = true;
}
std::string DocumentUndo::nextUndoLabel() const
std::string DocUndo::nextUndoLabel() const
{
const undo::UndoState* state = nextUndo();
if (state)
@ -160,7 +160,7 @@ std::string DocumentUndo::nextUndoLabel() const
return "";
}
std::string DocumentUndo::nextRedoLabel() const
std::string DocUndo::nextRedoLabel() const
{
const undo::UndoState* state = nextRedo();
if (state)
@ -169,7 +169,7 @@ std::string DocumentUndo::nextRedoLabel() const
return "";
}
SpritePosition DocumentUndo::nextUndoSpritePosition() const
SpritePosition DocUndo::nextUndoSpritePosition() const
{
const undo::UndoState* state = nextUndo();
if (state)
@ -178,7 +178,7 @@ SpritePosition DocumentUndo::nextUndoSpritePosition() const
return SpritePosition();
}
SpritePosition DocumentUndo::nextRedoSpritePosition() const
SpritePosition DocUndo::nextRedoSpritePosition() const
{
const undo::UndoState* state = nextRedo();
if (state)
@ -187,7 +187,7 @@ SpritePosition DocumentUndo::nextRedoSpritePosition() const
return SpritePosition();
}
std::istream* DocumentUndo::nextUndoDocumentRange() const
std::istream* DocUndo::nextUndoDocumentRange() const
{
const undo::UndoState* state = nextUndo();
if (state)
@ -196,7 +196,7 @@ std::istream* DocumentUndo::nextUndoDocumentRange() const
return nullptr;
}
std::istream* DocumentUndo::nextRedoDocumentRange() const
std::istream* DocUndo::nextRedoDocumentRange() const
{
const undo::UndoState* state = nextRedo();
if (state)
@ -205,7 +205,7 @@ std::istream* DocumentUndo::nextRedoDocumentRange() const
return nullptr;
}
Cmd* DocumentUndo::lastExecutedCmd() const
Cmd* DocUndo::lastExecutedCmd() const
{
const undo::UndoState* state = m_undoHistory.currentState();
if (state)
@ -214,10 +214,10 @@ Cmd* DocumentUndo::lastExecutedCmd() const
return NULL;
}
void DocumentUndo::moveToState(const undo::UndoState* state)
void DocUndo::moveToState(const undo::UndoState* state)
{
m_undoHistory.moveTo(state);
notify_observers(&DocumentUndoObserver::onCurrentUndoStateChange, this);
notify_observers(&DocUndoObserver::onCurrentUndoStateChange, this);
// Recalculate the total undo size
size_t oldSize = m_totalUndoSize;
@ -228,15 +228,15 @@ void DocumentUndo::moveToState(const undo::UndoState* state)
s = s->next();
}
if (m_totalUndoSize != oldSize)
notify_observers(&DocumentUndoObserver::onTotalUndoSizeChange, this);
notify_observers(&DocUndoObserver::onTotalUndoSizeChange, this);
}
const undo::UndoState* DocumentUndo::nextUndo() const
const undo::UndoState* DocUndo::nextUndo() const
{
return m_undoHistory.currentState();
}
const undo::UndoState* DocumentUndo::nextRedo() const
const undo::UndoState* DocUndo::nextRedo() const
{
const undo::UndoState* state = m_undoHistory.currentState();
if (state)
@ -245,7 +245,7 @@ const undo::UndoState* DocumentUndo::nextRedo() const
return m_undoHistory.firstState();
}
void DocumentUndo::onDeleteUndoState(undo::UndoState* state)
void DocUndo::onDeleteUndoState(undo::UndoState* state)
{
ASSERT(state);
Cmd* cmd = STATE_CMD(state);
@ -256,7 +256,7 @@ void DocumentUndo::onDeleteUndoState(undo::UndoState* state)
base::get_pretty_memory_size(m_totalUndoSize).c_str());
m_totalUndoSize -= cmd->memSize();
notify_observers(&DocumentUndoObserver::onDeleteUndoState, this, state);
notify_observers(&DocUndoObserver::onDeleteUndoState, this, state);
}
} // namespace app

View File

@ -24,12 +24,12 @@ namespace app {
class Cmd;
class CmdTransaction;
class Context;
class DocumentUndoObserver;
class DocUndoObserver;
class DocumentUndo : public obs::observable<DocumentUndoObserver>,
public undo::UndoHistoryDelegate {
class DocUndo : public obs::observable<DocUndoObserver>,
public undo::UndoHistoryDelegate {
public:
DocumentUndo();
DocUndo();
size_t totalUndoSize() const { return m_totalUndoSize; }
@ -87,7 +87,7 @@ namespace app {
// way. E.g. If the save process fails.
bool m_savedStateIsLost;
DISABLE_COPYING(DocumentUndo);
DISABLE_COPYING(DocUndo);
};
} // namespace app

View File

@ -14,17 +14,17 @@ namespace undo {
namespace app {
class DocumentUndo;
class DocUndo;
class DocumentUndoObserver {
class DocUndoObserver {
public:
virtual ~DocumentUndoObserver() { }
virtual void onAddUndoState(DocumentUndo* history) = 0;
virtual void onDeleteUndoState(DocumentUndo* history,
virtual ~DocUndoObserver() { }
virtual void onAddUndoState(DocUndo* history) = 0;
virtual void onDeleteUndoState(DocUndo* history,
undo::UndoState* state) = 0;
virtual void onCurrentUndoStateChange(DocumentUndo* history) = 0;
virtual void onClearRedo(DocumentUndo* history) = 0;
virtual void onTotalUndoSizeChange(DocumentUndo* history) = 0;
virtual void onCurrentUndoStateChange(DocUndo* history) = 0;
virtual void onClearRedo(DocUndo* history) = 0;
virtual void onTotalUndoSizeChange(DocUndo* history) = 0;
};
} // namespace app

View File

@ -17,8 +17,8 @@
#include "app/context.h"
#include "app/doc_event.h"
#include "app/doc_observer.h"
#include "app/doc_undo.h"
#include "app/document_api.h"
#include "app/document_undo.h"
#include "app/file/format_options.h"
#include "app/flatten.h"
#include "app/pref/preferences.h"
@ -44,7 +44,7 @@ using namespace doc;
Document::Document(Sprite* sprite)
: m_ctx(nullptr)
, m_flags(kMaskVisible)
, m_undo(new DocumentUndo)
, m_undo(new DocUndo)
// Information about the file format used to load/save this document
, m_format_options(nullptr)
// Mask

View File

@ -43,7 +43,7 @@ namespace app {
class Context;
class DocumentApi;
class DocumentUndo;
class DocUndo;
class Transaction;
using namespace doc;
@ -76,8 +76,8 @@ namespace app {
//////////////////////////////////////////////////////////////////////
// Main properties
const DocumentUndo* undoHistory() const { return m_undo; }
DocumentUndo* undoHistory() { return m_undo; }
const DocUndo* undoHistory() const { return m_undo; }
DocUndo* undoHistory() { return m_undo; }
color_t bgColor() const;
color_t bgColor(Layer* layer) const;
@ -194,7 +194,7 @@ namespace app {
int m_flags;
// Undo and redo information about the document.
base::UniquePtr<DocumentUndo> m_undo;
base::UniquePtr<DocUndo> m_undo;
// Selected mask region boundaries
base::UniquePtr<doc::MaskBoundaries> m_maskBoundaries;

View File

@ -43,8 +43,8 @@
#include "app/color_target.h"
#include "app/color_utils.h"
#include "app/context.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_undo.h"
#include "app/transaction.h"
#include "base/unique_ptr.h"
#include "doc/algorithm/flip_image.h"

View File

@ -7,11 +7,11 @@
#include "tests/test.h"
#include "app/context.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_api.h"
#include "app/document_range.h"
#include "app/document_range_ops.h"
#include "app/document_undo.h"
#include "app/test_context.h"
#include "app/transaction.h"
#include "base/unique_ptr.h"

View File

@ -9,8 +9,8 @@
#include "app/app.h" // TODO avoid to include this file
#include "app/color_utils.h"
#include "app/context.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_undo.h"
#include "app/tools/pick_ink.h"
#include "doc/mask.h"
#include "doc/slice.h"

View File

@ -12,8 +12,8 @@
#include "app/cmd_transaction.h"
#include "app/context_access.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_undo.h"
#include "doc/sprite.h"
#define TX_TRACE(...)

View File

@ -16,7 +16,7 @@ namespace app {
class CmdTransaction;
class Context;
class DocumentRange;
class DocumentUndo;
class DocUndo;
enum Modification {
ModifyDocument, // This item changes the "saved status" of the document.
@ -59,8 +59,8 @@ namespace app {
// created).
//
// WARNING: This must be called from the main UI thread, because
// it will generate a DocumentUndo::add() which triggers a
// DocumentUndoObserver::onAddUndoState() notification, which
// it will generate a DocUndo::add() which triggers a
// DocUndoObserver::onAddUndoState() notification, which
// updates the Undo History window UI.
void commit();
@ -70,7 +70,7 @@ namespace app {
void rollback();
Context* m_ctx;
DocumentUndo* m_undo;
DocUndo* m_undo;
CmdTransaction* m_cmds;
};

View File

@ -26,8 +26,8 @@
#include "app/commands/quick_command.h"
#include "app/console.h"
#include "app/context_access.h"
#include "app/doc_undo.h"
#include "app/document_api.h"
#include "app/document_undo.h"
#include "app/i18n/strings.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
@ -1166,7 +1166,7 @@ void ColorBar::updateCurrentSpritePalette(const char* operationName)
currentSpritePalette->countDiff(newPalette, &from, &to);
if (from >= 0 && to >= from) {
DocumentUndo* undo = document->undoHistory();
DocUndo* undo = document->undoHistory();
Cmd* cmd = new cmd::SetPalette(sprite, frame, newPalette);
// Add undo information to save the range of pal entries that will be modified.

View File

@ -19,7 +19,7 @@
#include "app/console.h"
#include "app/context.h"
#include "app/context_access.h"
#include "app/document_undo.h"
#include "app/doc_undo.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"

View File

@ -19,10 +19,10 @@
#include "app/console.h"
#include "app/context_access.h"
#include "app/doc_event.h"
#include "app/doc_undo.h"
#include "app/document.h"
#include "app/document_api.h"
#include "app/document_range_ops.h"
#include "app/document_undo.h"
#include "app/loop_tag.h"
#include "app/modules/editors.h"
#include "app/modules/gfx.h"