Unravel Engine C++ Reference
Loading...
Searching...
No Matches
editing_action.h
Go to the documentation of this file.
1#pragma once
2
5#include <string>
6
7namespace unravel
8{
9
10// Base class for all editing actions
11struct editing_action_t : crtp_meta_type<editing_action_t>
12{
13 virtual ~editing_action_t() = default;
14 uint64_t merge_key{0};
15 bool undoable{false};
16 std::string name{};
17 uint64_t execution_count{0};
18
19 virtual auto get_name() const -> const std::string& { return name; }
20 virtual void do_action() = 0;
21 virtual auto get_execution_count() const -> uint64_t { return execution_count; }
22 virtual void undo_action() = 0;
23 virtual auto is_undoable() const -> bool { return undoable; } // Default: actions are undoable
24 virtual auto is_mergeable(const editing_action_t& previous) const -> bool { return false; } // Default: actions are not mergeable
25 virtual void merge_with(const editing_action_t& previous) {} // Default: no merge implementation
26 virtual auto is_valid() const -> bool { return true; } // Default: actions are valid
27 virtual void draw_in_inspector(rtti::context& ctx) {} // Default: no inspector drawing
28
29 // Note: Common merge checks (type equality, operation_id validation) are handled by undo_redo_stack.
30 // Individual is_mergeable() implementations only need to check action-specific criteria.
31
32protected:
33 void draw_in_inspector_impl(rtti::context& ctx, const entt::meta_any& old_value, const entt::meta_any& new_value, const entt::meta_custom& custom);
34};
35
36} // namespace unravel
virtual auto get_name() const -> const std::string &
virtual ~editing_action_t()=default
virtual auto is_valid() const -> bool
virtual void merge_with(const editing_action_t &previous)
virtual auto is_mergeable(const editing_action_t &previous) const -> bool
virtual void undo_action()=0
virtual auto get_execution_count() const -> uint64_t
virtual void draw_in_inspector(rtti::context &ctx)
virtual void do_action()=0
void draw_in_inspector_impl(rtti::context &ctx, const entt::meta_any &old_value, const entt::meta_any &new_value, const entt::meta_custom &custom)
virtual auto is_undoable() const -> bool