Stage 3: operations layer (src/edit) and one undo entry point
- src/edit/ (in anm2ed_core): frame, track, animation, region, grid and change-all edits as plain functions of the model. Each returns the uids of what it created for the UI to select; copies get fresh uids. - Document::edit_apply snapshots, runs an operation and commits; edit_begin starts drag edits. window_edit, edit_command_push, snapshot_command_push, SnapshotKind and the tracks/frames/regions/textures snapshot kinds are gone; Snapshots has a single push(message, isTextures). - Timeline, animations, regions, shaders, items, wizards, taskbar and file merge call the edit layer; they keep only selection, scrolling and toasts. - Snapshots, Storage, Playback and ImGui core build into anm2ed_core, so undo is testable: tests/undo.cpp runs a seeded random walk of edits per fixture and checks every undo/redo state by hash, plus selection follow through undo. - types::edit renamed types::edit_state (clashed with the edit namespace). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
20bfbace7a
commit
700b613c62
63 files changed
+3223
-1775
No files matched your search
@@ -2,12 +2,16 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "edit/edit.hpp"
|
||||
#include "snapshots.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
@@ -117,6 +121,25 @@ namespace anm2ed
|
||||
void hash_set();
|
||||
void clean();
|
||||
void change(ChangeType);
|
||||
void edit_begin(StringType, bool = false);
|
||||
edit::Uids edit_run(StringType, ChangeType, const std::function<edit::Uids(Anm2&)>&);
|
||||
|
||||
// Snapshots for undo, runs the operation on the model, then commits; void operations select nothing.
|
||||
template <class Operation> edit::Uids edit_apply(StringType label, ChangeType type, Operation&& operation)
|
||||
{
|
||||
return edit_run(label, type,
|
||||
[&](Anm2& anm2) -> edit::Uids
|
||||
{
|
||||
if constexpr (std::is_void_v<std::invoke_result_t<Operation&, Anm2&>>)
|
||||
{
|
||||
operation(anm2);
|
||||
return {};
|
||||
}
|
||||
else
|
||||
return operation(anm2);
|
||||
});
|
||||
}
|
||||
std::vector<Reference> references_get(const edit::Uids&) const;
|
||||
bool is_dirty() const;
|
||||
bool is_autosave_dirty() const;
|
||||
std::filesystem::path directory_get() const;
|
||||
|
||||
Reference in new issue
Block a user