Unravel Engine C++ Reference
Loading...
Searching...
No Matches
property_actions.cpp
Go to the documentation of this file.
1#include "property_actions.h"
2
3namespace unravel
4{
5
6
7// Property Action Implementation
8property_action_t::property_action_t(meta_any_proxy inst, const entt::meta_any& old_val, const entt::meta_any& new_val, const entt::meta_custom& custom, const std::function<void()>& on_success)
9 : instance(inst), old_value(old_val), new_value(new_val), custom(custom), on_success(on_success)
10{
11
12 if(inst.impl->get_name)
13 {
14 name = inst.impl->get_name();
15 }
16 else
17 {
18 name = "Property Edit";
19 }
20}
21
23{
24 if(instance.impl->setter(instance, new_value, execution_count))
25 {
26 if(on_success)
27 {
28 on_success();
29 }
30 }
31}
32
34{
35 if(instance.impl->setter(instance, old_value, execution_count))
36 {
37 if(on_success)
38 {
39 on_success();
40 }
41 }
42}
43
44auto property_action_t::is_mergeable(const editing_action_t& previous) const -> bool
45{
46 const auto& prev = static_cast<const property_action_t&>(previous);
47 entt::meta_any inst;
48 instance.impl->getter(inst);
49 entt::meta_any prev_inst;
50 prev.instance.impl->getter(prev_inst);
51 return inst == prev_inst;
52}
53
55{
56 const auto& prev = static_cast<const property_action_t&>(previous);
57 old_value.assign(prev.old_value);
58}
59
60auto property_action_t::is_valid() const -> bool
61{
62 entt::meta_any inst;
63 instance.impl->getter(inst);
64
65 return !!inst;
66}
67
69{
70 draw_in_inspector_impl(ctx, old_value, new_value, custom);
71}
72
73} // namespace unravel
Safe deferred property access proxy for arbitrary object properties.
Definition inspector.h:198
std::shared_ptr< meta_any_proxy_impl > impl
Definition inspector.h:221
auto is_mergeable(const editing_action_t &previous) const -> bool override
void draw_in_inspector(rtti::context &ctx) override
property_action_t(meta_any_proxy inst, const entt::meta_any &old_val, const entt::meta_any &new_val, const entt::meta_custom &custom={}, const std::function< void()> &on_success={})
void merge_with(const editing_action_t &previous) override
std::function< void()> on_success
auto is_valid() const -> bool override