MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ event_manager()

InspectResult & MayaFlux::Portal::Forma::Inspector::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.

Header shows total event count. Each event is a collapsible whose header is the event's registered name, or "(unnamed)" for events added without a name. Body rows expose active state.

Persistent: the first call builds the result against surface and cursor and stores it statically. Subsequent calls return the same result regardless of the supplied surface and cursor; the original window remains the render target. To display on a different surface, the process must be restarted.

Definition at line 47 of file EventQuery.cpp.

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}
Vruta::EventManager & m_event_mgr
static std::optional< InspectResult > s_event_result
RowBuffer make_row_buffer(const std::shared_ptr< Core::Window > &window, std::string_view text, glm::uvec2 pixel_dims) const
Definition Inspector.cpp:13
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.

References MayaFlux::Portal::Forma::Collapsible::attach(), MayaFlux::Portal::Forma::InspectResult::children, MayaFlux::Vruta::EventManager::get_all_events(), MayaFlux::Vruta::EventManager::get_event(), MayaFlux::Vruta::EventManager::get_event_names(), MayaFlux::Portal::Forma::InspectResult::group, MayaFlux::Portal::Forma::ValueGroup::header, MayaFlux::Portal::Forma::Collapsible::header_id, MayaFlux::Portal::Forma::ValueSpec::label, MayaFlux::Portal::Forma::Surface::layer(), m_event_mgr, make_row_buffer(), MayaFlux::Portal::Forma::make_value_group(), MayaFlux::Portal::Forma::row_pixel_dims(), s_event_result, and MayaFlux::Portal::Forma::Surface::window().

+ Here is the call graph for this function: