mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Rename undo2 to undo library
Now that the old undo library doesn't exist, we can use "undo" namespace again.
This commit is contained in:
parent
348007b123
commit
0cff720ef3
1
TODO.md
1
TODO.md
@ -45,7 +45,6 @@
|
||||
|
||||
* Remove unused skin parts
|
||||
* Make one level of layers (folders should modify only timeline/UI)
|
||||
* rename undo2 to undo
|
||||
* Convert doc::PixelFormat to a enum class
|
||||
* Add doc::Spec with width/height/channels/ColorMode/ncolors
|
||||
* Convert doc::LayerIndex -> typedef int doc::layer_t;
|
||||
|
@ -30,7 +30,7 @@ set(aseprite_libraries
|
||||
doc-lib
|
||||
render-lib
|
||||
scripting-lib
|
||||
undo2-lib
|
||||
undo-lib
|
||||
filters-lib
|
||||
ui-lib
|
||||
she
|
||||
@ -219,7 +219,7 @@ add_subdirectory(gfx)
|
||||
add_subdirectory(scripting)
|
||||
add_subdirectory(she)
|
||||
add_subdirectory(ui)
|
||||
add_subdirectory(undo2)
|
||||
add_subdirectory(undo)
|
||||
|
||||
add_subdirectory(app)
|
||||
|
||||
@ -328,7 +328,7 @@ function(find_tests dir dependencies)
|
||||
endfunction()
|
||||
|
||||
find_tests(base base-lib ${sys_libs})
|
||||
find_tests(undo2 undo2-lib ${sys_libs})
|
||||
find_tests(undo undo-lib ${sys_libs})
|
||||
find_tests(gfx gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
||||
find_tests(doc doc-lib gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
||||
find_tests(render render-lib doc-lib gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
||||
|
@ -18,7 +18,7 @@ because they don't depend on any other component.
|
||||
* [css](css/): Pseudo-style sheet library.
|
||||
* [gfx](gfx/): Abstract graphics structures like point, size, rectangle, region, color, etc.
|
||||
* [scripting](scripting/): JavaScript engine ([V8](https://code.google.com/p/v8/)).
|
||||
* [undo2](undo2/): Generic library to manage a history of undoable commands.
|
||||
* [undo](undo/): Generic library to manage a history of undoable commands.
|
||||
|
||||
## Level 1
|
||||
|
||||
|
@ -21,14 +21,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "doc/sprite_position.h"
|
||||
#include "undo2/undo_command.h"
|
||||
#include "undo/undo_command.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace app {
|
||||
class Context;
|
||||
|
||||
class Cmd : public undo2::UndoCommand {
|
||||
class Cmd : public undo::UndoCommand {
|
||||
public:
|
||||
Cmd();
|
||||
virtual ~Cmd();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Do not keep `ImageRef` or any kind of smart pointer to `doc::`
|
||||
entities. As several `cmd` can persist in parallel with other `cmd`
|
||||
(due the tree structure of the [undo history](../../undo2/undo_history.h))
|
||||
(due the tree structure of the [undo history](../../undo/undo_history.h))
|
||||
these smart pointers can generate conflicts in the logic layer.
|
||||
E.g. If we keep an `ImageRef` inside a `cmd`, the image is
|
||||
not removed from the [objects hash table](../../doc/object.cpp),
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "app/cmd_transaction.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "doc/context.h"
|
||||
#include "undo2/undo_history.h"
|
||||
#include "undo2/undo_state.h"
|
||||
#include "undo/undo_history.h"
|
||||
#include "undo/undo_state.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
@ -103,7 +103,7 @@ void DocumentUndo::impossibleToBackToSavedState()
|
||||
|
||||
std::string DocumentUndo::nextUndoLabel() const
|
||||
{
|
||||
const undo2::UndoState* state = nextUndo();
|
||||
const undo::UndoState* state = nextUndo();
|
||||
if (state)
|
||||
return static_cast<Cmd*>(state->cmd())->label();
|
||||
else
|
||||
@ -112,7 +112,7 @@ std::string DocumentUndo::nextUndoLabel() const
|
||||
|
||||
std::string DocumentUndo::nextRedoLabel() const
|
||||
{
|
||||
const undo2::UndoState* state = nextRedo();
|
||||
const undo::UndoState* state = nextRedo();
|
||||
if (state)
|
||||
return static_cast<const Cmd*>(state->cmd())->label();
|
||||
else
|
||||
@ -121,7 +121,7 @@ std::string DocumentUndo::nextRedoLabel() const
|
||||
|
||||
SpritePosition DocumentUndo::nextUndoSpritePosition() const
|
||||
{
|
||||
const undo2::UndoState* state = nextUndo();
|
||||
const undo::UndoState* state = nextUndo();
|
||||
if (state)
|
||||
return static_cast<const CmdTransaction*>(state->cmd())
|
||||
->spritePositionBeforeExecute();
|
||||
@ -131,7 +131,7 @@ SpritePosition DocumentUndo::nextUndoSpritePosition() const
|
||||
|
||||
SpritePosition DocumentUndo::nextRedoSpritePosition() const
|
||||
{
|
||||
const undo2::UndoState* state = nextRedo();
|
||||
const undo::UndoState* state = nextRedo();
|
||||
if (state)
|
||||
return static_cast<const CmdTransaction*>(state->cmd())
|
||||
->spritePositionAfterExecute();
|
||||
@ -141,21 +141,21 @@ SpritePosition DocumentUndo::nextRedoSpritePosition() const
|
||||
|
||||
Cmd* DocumentUndo::lastExecutedCmd() const
|
||||
{
|
||||
const undo2::UndoState* state = m_undoHistory.currentState();
|
||||
const undo::UndoState* state = m_undoHistory.currentState();
|
||||
if (state)
|
||||
return static_cast<Cmd*>(state->cmd());
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const undo2::UndoState* DocumentUndo::nextUndo() const
|
||||
const undo::UndoState* DocumentUndo::nextUndo() const
|
||||
{
|
||||
return m_undoHistory.currentState();
|
||||
}
|
||||
|
||||
const undo2::UndoState* DocumentUndo::nextRedo() const
|
||||
const undo::UndoState* DocumentUndo::nextRedo() const
|
||||
{
|
||||
const undo2::UndoState* state = m_undoHistory.currentState();
|
||||
const undo::UndoState* state = m_undoHistory.currentState();
|
||||
if (state)
|
||||
return state->next();
|
||||
else
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "base/disable_copying.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/sprite_position.h"
|
||||
#include "undo2/undo_history.h"
|
||||
#include "undo/undo_history.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -67,10 +67,10 @@ namespace app {
|
||||
int* savedCounter() { return &m_savedCounter; }
|
||||
|
||||
private:
|
||||
const undo2::UndoState* nextUndo() const;
|
||||
const undo2::UndoState* nextRedo() const;
|
||||
const undo::UndoState* nextUndo() const;
|
||||
const undo::UndoState* nextRedo() const;
|
||||
|
||||
undo2::UndoHistory m_undoHistory;
|
||||
undo::UndoHistory m_undoHistory;
|
||||
doc::Context* m_ctx;
|
||||
|
||||
// This counter is equal to 0 if we are in the "saved state", i.e.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Aseprite Undo2 Library
|
||||
# Aseprite Undo Library
|
||||
# Copyright (C) 2015 David Capello
|
||||
|
||||
add_library(undo2-lib
|
||||
add_library(undo-lib
|
||||
undo_history.cpp)
|
@ -1,4 +1,4 @@
|
||||
# Aseprite Undo2 Library
|
||||
# Aseprite Undo Library
|
||||
*Copyright (C) 2015 David Capello*
|
||||
|
||||
> Distributed under [MIT license](LICENSE.txt)
|
@ -1,14 +1,14 @@
|
||||
// Aseprite Undo2 Library
|
||||
// Aseprite Undo Library
|
||||
// Copyright (C) 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef UNDO2_UNDO_COMMAND_H_INCLUDED
|
||||
#define UNDO2_UNDO_COMMAND_H_INCLUDED
|
||||
#ifndef UNDO_UNDO_COMMAND_H_INCLUDED
|
||||
#define UNDO_UNDO_COMMAND_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace undo2 {
|
||||
namespace undo {
|
||||
|
||||
class UndoCommand {
|
||||
public:
|
||||
@ -17,6 +17,6 @@ namespace undo2 {
|
||||
virtual void redo() = 0;
|
||||
};
|
||||
|
||||
} // namespace undo2
|
||||
} // namespace undo
|
||||
|
||||
#endif // UNDO2_UNDO_COMMAND_H_INCLUDED
|
||||
#endif // UNDO_UNDO_COMMAND_H_INCLUDED
|
@ -1,4 +1,4 @@
|
||||
// Aseprite Undo2 Library
|
||||
// Aseprite Undo Library
|
||||
// Copyright (C) 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -8,15 +8,15 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "undo2/undo_history.h"
|
||||
#include "undo/undo_history.h"
|
||||
|
||||
#include "undo2/undo_command.h"
|
||||
#include "undo2/undo_state.h"
|
||||
#include "undo/undo_command.h"
|
||||
#include "undo/undo_state.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <stack>
|
||||
|
||||
namespace undo2 {
|
||||
namespace undo {
|
||||
|
||||
UndoHistory::UndoHistory()
|
||||
: m_first(nullptr)
|
@ -1,14 +1,14 @@
|
||||
// Aseprite Undo2 Library
|
||||
// Aseprite Undo Library
|
||||
// Copyright (C) 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef UNDO2_UNDO_HISTORY_H_INCLUDED
|
||||
#define UNDO2_UNDO_HISTORY_H_INCLUDED
|
||||
#ifndef UNDO_UNDO_HISTORY_H_INCLUDED
|
||||
#define UNDO_UNDO_HISTORY_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace undo2 {
|
||||
namespace undo {
|
||||
|
||||
class UndoCommand;
|
||||
class UndoState;
|
||||
@ -39,6 +39,6 @@ namespace undo2 {
|
||||
UndoState* m_cur; // Current action that can be undone
|
||||
};
|
||||
|
||||
} // namespace undo2
|
||||
} // namespace undo
|
||||
|
||||
#endif // UNDO2_UNDO_HISTORY_H_INCLUDED
|
||||
#endif // UNDO_UNDO_HISTORY_H_INCLUDED
|
@ -1,14 +1,14 @@
|
||||
// Aseprite Undo2 Library
|
||||
// Aseprite Undo Library
|
||||
// Copyright (C) 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef UNDO2_UNDO_STATE_H_INCLUDED
|
||||
#define UNDO2_UNDO_STATE_H_INCLUDED
|
||||
#ifndef UNDO_UNDO_STATE_H_INCLUDED
|
||||
#define UNDO_UNDO_STATE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace undo2 {
|
||||
namespace undo {
|
||||
|
||||
class UndoCommand;
|
||||
class UndoHistory;
|
||||
@ -28,6 +28,6 @@ namespace undo2 {
|
||||
UndoCommand* m_cmd;
|
||||
};
|
||||
|
||||
} // namespace undo2
|
||||
} // namespace undo
|
||||
|
||||
#endif // UNDO2_UNDO_STATE_H_INCLUDED
|
||||
#endif // UNDO_UNDO_STATE_H_INCLUDED
|
@ -1,4 +1,4 @@
|
||||
// Aseprite Undo2 Library
|
||||
// Aseprite Undo Library
|
||||
// Copyright (C) 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,10 +11,10 @@
|
||||
#include <functional>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "undo2/undo_command.h"
|
||||
#include "undo2/undo_history.h"
|
||||
#include "undo/undo_command.h"
|
||||
#include "undo/undo_history.h"
|
||||
|
||||
using namespace undo2;
|
||||
using namespace undo;
|
||||
|
||||
class Cmd : public UndoCommand {
|
||||
public:
|
Loading…
x
Reference in New Issue
Block a user