MayaFlux 1.0.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<EntrySpec> entrys {
20 EntrySpec {
21 .label = "token",
22 .reader = [ev] {
23 return std::string(Reflect::enum_to_string(ev->get_processing_token()));
24 },
25 },
26 EntrySpec {
27 .label = "active",
28 .reader = [ev] { return ev->is_active() ? "true" : "false"; },
29 },
30 };
31
32 auto hbuf = make_header_buffer(surface.window());
33 auto rbufs = make_row_buffers(surface.window(), entrys.size());
34
35 auto group = make_entry_group(entrys, header_label, std::move(hbuf), rbufs,
36 surface, cursor, x_min, x_max, row_h, false);
37
38 InspectResult result;
39 result.group = std::move(group);
40 return result;
41}
42
44 Surface& surface,
45 LayoutCursor& cursor,
46 float x_min, float x_max, float row_h)
47{
48 if (m_event_result) {
49 return *m_event_result;
50 }
51
52 const std::vector<EntrySpec> root_entrys {
53 EntrySpec {
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 auto hbuf = make_header_buffer(surface.window());
62 auto rbufs = make_row_buffers(surface.window(), root_entrys.size());
63
64 auto root_group = make_entry_group(root_entrys, "EventManager", std::move(hbuf), rbufs,
65 surface, cursor, x_min, x_max, row_h, true);
66
67 InspectResult& result = m_event_result.emplace();
68 result.group = std::move(root_group);
69
70 const auto names = m_event_mgr.get_event_names();
71
72 for (const auto& ev : m_event_mgr.get_all_events()) {
73 if (!ev)
74 continue;
75
76 std::string header_label = "(unnamed)";
77 for (const auto& n : names) {
78 if (m_event_mgr.get_event(n) == ev) {
79 header_label = n;
80 break;
81 }
82 }
83
84 std::vector<EntrySpec> entrys {
85 EntrySpec {
86 .label = "active",
87 .reader = [ev] { return ev->is_active() ? "true" : "false"; },
88 },
89 };
90
91 auto ev_hbuf = make_header_buffer(surface.window());
92 auto ev_rbufs = make_row_buffers(surface.window(), entrys.size());
93
94 auto ev_group = make_entry_group(entrys, header_label, std::move(ev_hbuf), ev_rbufs,
95 surface, cursor, x_min, x_max, row_h, false);
96
97 InspectResult ev_result;
98 ev_result.group = std::move(ev_group);
99
100 result.group.header.attach(surface.layer(), ev_result.group.header.header_id);
101 result.children.push_back(std::move(ev_result));
102 }
103
104 return result;
105}
106
107} // namespace MayaFlux::Portal::Forma
std::string name
Definition VKDevice.cpp:123
std::shared_ptr< Buffers::FormaBuffer > make_header_buffer(const std::shared_ptr< Core::Window > &window) const
A "text"-slotted buffer, registered with the BufferManager.
Definition Inspector.cpp:11
std::vector< EntryBuffer > make_row_buffers(const std::shared_ptr< Core::Window > &window, size_t count) const
count row targets, slices of one "text"-slotted buffer, for make_entry_group's rows.
Definition Inspector.cpp:24
Vruta::EventManager & m_event_mgr
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.
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.
std::optional< InspectResult > m_event_result
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:178
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:159
Named owner of a (Window, Layer, Context) triple: the Forma canvas.
Definition Surface.hpp:121
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.
EntryGroup make_entry_group(std::span< const EntrySpec > entrys, std::string_view header_label, FormaTarget header_buf, std::span< const EntryBuffer > 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 entry rows under it.
Definition Entry.cpp:104
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.
A single entry to display in a EntryGroup body row.
Definition Entry.hpp:29
std::vector< InspectResult > children
Result of an introspect call.