Unravel Engine C++ Reference
Loading...
Searching...
No Matches
property_actions.cpp
Go to the documentation of this file.
1
#include "
property_actions.h
"
2
3
namespace
unravel
4
{
5
6
7
// Property Action Implementation
8
property_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
22
void
property_action_t::do_action
()
23
{
24
if
(
instance
.
impl
->setter(
instance
,
new_value
, execution_count))
25
{
26
if
(
on_success
)
27
{
28
on_success
();
29
}
30
}
31
}
32
33
void
property_action_t::undo_action
()
34
{
35
if
(
instance
.
impl
->setter(
instance
,
old_value
, execution_count))
36
{
37
if
(
on_success
)
38
{
39
on_success
();
40
}
41
}
42
}
43
44
auto
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
54
void
property_action_t::merge_with
(
const
editing_action_t
& previous)
55
{
56
const
auto
& prev =
static_cast<
const
property_action_t
&
>
(previous);
57
old_value
.assign(prev.old_value);
58
}
59
60
auto
property_action_t::is_valid
() const ->
bool
61
{
62
entt::meta_any inst;
63
instance
.
impl
->getter(inst);
64
65
return
!!inst;
66
}
67
68
void
property_action_t::draw_in_inspector
(
rtti::context
& ctx)
69
{
70
draw_in_inspector_impl(ctx,
old_value
,
new_value
,
custom
);
71
}
72
73
}
// namespace unravel
unravel
Definition
crash.cpp:21
property_actions.h
rtti::context
Definition
context.hpp:14
unravel::editing_action_t
Definition
editing_action.h:12
unravel::meta_any_proxy
Safe deferred property access proxy for arbitrary object properties.
Definition
inspector.h:198
unravel::meta_any_proxy::impl
std::shared_ptr< meta_any_proxy_impl > impl
Definition
inspector.h:221
unravel::property_action_t
Definition
property_actions.h:15
unravel::property_action_t::custom
entt::meta_custom custom
Definition
property_actions.h:19
unravel::property_action_t::is_mergeable
auto is_mergeable(const editing_action_t &previous) const -> bool override
Definition
property_actions.cpp:44
unravel::property_action_t::new_value
entt::meta_any new_value
Definition
property_actions.h:18
unravel::property_action_t::draw_in_inspector
void draw_in_inspector(rtti::context &ctx) override
Definition
property_actions.cpp:68
unravel::property_action_t::property_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={})
Definition
property_actions.cpp:8
unravel::property_action_t::old_value
entt::meta_any old_value
Definition
property_actions.h:17
unravel::property_action_t::merge_with
void merge_with(const editing_action_t &previous) override
Definition
property_actions.cpp:54
unravel::property_action_t::undo_action
void undo_action() override
Definition
property_actions.cpp:33
unravel::property_action_t::on_success
std::function< void()> on_success
Definition
property_actions.h:20
unravel::property_action_t::is_valid
auto is_valid() const -> bool override
Definition
property_actions.cpp:60
unravel::property_action_t::instance
meta_any_proxy instance
Definition
property_actions.h:16
unravel::property_action_t::do_action
void do_action() override
Definition
property_actions.cpp:22
UnravelEngine
UnravelEngine
editor
editor
editing
actions
property_actions.cpp
Generated by
1.12.0