MayaFlux 1.0.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 keeps it on this Inspector. Subsequent calls return the same result regardless of the supplied surface and cursor; the original window remains the render target. destroy() releases it, and the next call builds afresh.

Definition at line 43 of file EventQuery.cpp.

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}
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
std::optional< InspectResult > m_event_result
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

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::EntryGroup::header, MayaFlux::Portal::Forma::Collapsible::header_id, MayaFlux::Portal::Forma::EntrySpec::label, MayaFlux::Portal::Forma::Surface::layer(), m_event_mgr, m_event_result, MayaFlux::Portal::Forma::make_entry_group(), make_header_buffer(), make_row_buffers(), and MayaFlux::Portal::Forma::Surface::window().

Referenced by MayaFlux::Portal::Forma::inspect_events().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: