MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
EventQuery.cpp
Go to the documentation of this file.
1#include "Inspector.hpp"
2
5
7
9
11 const std::shared_ptr<Vruta::Event>& ev,
12 std::string_view name,
13 Surface& surface,
14 LayoutCursor& cursor,
15 float x_min, float x_max, float row_h)
16{
17 const std::string header_label = name.empty() ? "(unnamed)" : std::string(name);
18
19 std::vector<ValueSpec> values {
20 ValueSpec {
21 .label = "token",
22 .reader = [ev] {
23 return std::string(Reflect::enum_to_string(ev->get_processing_token()));
24 },
25 },
26 ValueSpec {
27 .label = "active",
28 .reader = [ev] { return ev->is_active() ? "true" : "false"; },
29 },
30 };
31
32 const auto dims = row_pixel_dims(surface.window(), x_min, x_max, row_h);
33 auto hbuf = make_row_buffer(surface.window(), header_label, dims);
34 std::vector<RowBuffer> rbufs;
35 rbufs.reserve(values.size());
36 for (const auto& spec : values)
37 rbufs.push_back(make_row_buffer(surface.window(), spec.label, dims));
38
39 auto group = make_value_group(values, std::move(hbuf), rbufs,
40 surface, cursor, x_min, x_max, row_h, false);
41
42 InspectResult result;
43 result.group = std::move(group);
44 return result;
45}
46
48 Surface& surface,
49 LayoutCursor& cursor,
50 float x_min, float x_max, float row_h)
51{
52 const std::vector<ValueSpec> root_values {
53 ValueSpec {
54 .label = "events",
55 .reader = [&m_event_mgr = m_event_mgr] {
56 return std::to_string(m_event_mgr.get_all_events().size());
57 },
58 },
59 };
60
61 const auto dims = row_pixel_dims(surface.window(), x_min, x_max, row_h);
62 auto hbuf = make_row_buffer(surface.window(), "EventManager", dims);
63 std::vector<RowBuffer> rbufs;
64 rbufs.reserve(root_values.size());
65 for (const auto& spec : root_values)
66 rbufs.push_back(make_row_buffer(surface.window(), spec.label, dims));
67
68 auto root_group = make_value_group(root_values, std::move(hbuf), rbufs,
69 surface, cursor, x_min, x_max, row_h, true);
70
71 InspectResult& result = s_event_result.emplace();
72 result.group = std::move(root_group);
73
74 const auto names = m_event_mgr.get_event_names();
75
76 for (const auto& ev : m_event_mgr.get_all_events()) {
77 if (!ev)
78 continue;
79
80 std::string header_label = "(unnamed)";
81 for (const auto& n : names) {
82 if (m_event_mgr.get_event(n) == ev) {
83 header_label = n;
84 break;
85 }
86 }
87
88 std::vector<ValueSpec> values {
89 ValueSpec {
90 .label = "active",
91 .reader = [ev] { return ev->is_active() ? "true" : "false"; },
92 },
93 };
94
95 const auto ev_dims = row_pixel_dims(surface.window(), x_min, x_max, row_h);
96 auto ev_hbuf = make_row_buffer(surface.window(), header_label, ev_dims);
97 std::vector<RowBuffer> ev_rbufs;
98 ev_rbufs.reserve(values.size());
99 for (const auto& spec : values)
100 ev_rbufs.push_back(make_row_buffer(surface.window(), spec.label, ev_dims));
101
102 auto ev_group = make_value_group(values, std::move(ev_hbuf), ev_rbufs,
103 surface, cursor, x_min, x_max, row_h, false);
104
105 InspectResult ev_result;
106 ev_result.group = std::move(ev_group);
107
108 result.group.header.attach(surface.layer(), ev_result.group.header.header_id);
109 result.children.push_back(std::move(ev_result));
110 }
111
112 return result;
113}
114
115} // namespace MayaFlux::Portal::Forma
Vruta::EventManager & m_event_mgr
static std::optional< InspectResult > s_event_result
InspectResult event(const std::shared_ptr< Vruta::Event > &ev, std::string_view name, Surface &surface, LayoutCursor &cursor, float x_min=-0.95F, float x_max=0.95F, float row_h=0.05F)
Inspect a single Event by name and pointer.
RowBuffer make_row_buffer(const std::shared_ptr< Core::Window > &window, std::string_view text, glm::uvec2 pixel_dims) const
Definition Inspector.cpp:13
InspectResult & event_manager(Surface &surface, LayoutCursor &cursor, float x_min=-0.95F, float x_max=0.95F, float row_h=0.05F)
Inspect the full EventManager state.
Reactive Y-position accumulator for vertical primitive stacking.
const std::shared_ptr< Core::Window > & window() const noexcept
Access the rendering target window.
Definition Surface.hpp:126
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:107
Named owner of a (Window, Layer, Context) triple - the Forma canvas.
Definition Surface.hpp:58
std::vector< std::string > get_event_names() const
Get all event names for debugging/inspection.
std::vector< std::shared_ptr< Event > > get_all_events() const
Get all managed events.
std::shared_ptr< Event > get_event(const std::string &name) const
Get a named event.
ValueGroup make_value_group(std::span< const ValueSpec > values, RowBuffer header_buf, std::span< const RowBuffer > row_bufs, Surface &surface, LayoutCursor &cursor, float x_min, float x_max, float row_h, bool initially_open)
Construct a collapsible header followed by N value rows under it.
glm::uvec2 row_pixel_dims(const std::shared_ptr< Core::Window > &window, float x_min, float x_max, float row_h)
Convert an NDC row rect into integer pixel dimensions.
constexpr std::string_view enum_to_string(EnumType value) noexcept
Universal enum to string converter using magic_enum (original case)
uint32_t header_id
Element id of the header strip. Valid after place().
MAYAFLUX_API void attach(Layer &layer, uint32_t body_id) const
Relate a body element to this collapsible and sync its visibility to the current open state.
std::vector< InspectResult > children
Result of an introspect call.
A single value to display in a ValueGroup body row.