Unravel Engine C++ Reference
Loading...
Searching...
No Matches
composite_action.h
Go to the documentation of this file.
1#pragma once
2
3#include "editing_action.h"
4#include <functional>
5#include <memory>
6#include <vector>
7
8namespace unravel
9{
10
11// Composite action base class - contains multiple sub-actions
12struct composite_action_t : crtp_meta_type<composite_action_t, editing_action_t>
13{
14 std::vector<std::shared_ptr<editing_action_t>> sub_actions;
15
16 void add_sub_action(std::shared_ptr<editing_action_t> action);
17 void draw_in_inspector(rtti::context& ctx) override;
18 void do_action() override;
19 void undo_action() override;
20 auto is_valid() const -> bool override;
21 auto is_mergeable(const editing_action_t& previous) const -> bool override;
22 void merge_with(const editing_action_t& previous) override;
23
24
25};
26
45{
47 std::vector<std::function<std::shared_ptr<editing_action_t>()>> step_factories;
49 std::vector<std::shared_ptr<editing_action_t>> sub_actions;
50
51 bool first_run_done{false};
52
54 void add_step(std::function<std::shared_ptr<editing_action_t>()> factory);
55
56 void do_action() override;
57 void undo_action() override;
58 auto is_valid() const -> bool override;
59 auto is_mergeable(const editing_action_t& previous) const -> bool override;
60 void draw_in_inspector(rtti::context& ctx) override;
61};
62
63} // namespace unravel
void add_sub_action(std::shared_ptr< editing_action_t > action)
void draw_in_inspector(rtti::context &ctx) override
void merge_with(const editing_action_t &previous) override
auto is_valid() const -> bool override
auto is_mergeable(const editing_action_t &previous) const -> bool override
std::vector< std::shared_ptr< editing_action_t > > sub_actions
Single-undo container for a chain of DEPENDENT actions.
std::vector< std::shared_ptr< editing_action_t > > sub_actions
Captured sub-actions after first execution, replayed on redo and reversed on undo.
std::vector< std::function< std::shared_ptr< editing_action_t >()> > step_factories
Factories evaluated lazily on the first execution. Cleared once consumed.