add shared test

This commit is contained in:
2025-03-06 08:31:22 +03:00
parent 42e9d6c45c
commit a3a6a3a07f
4 changed files with 25 additions and 4 deletions

View File

@@ -6,6 +6,14 @@ namespace sandbox
{ {
class local_panel : public VE::layer class local_panel : public VE::layer
{ {
public:
local_panel() = default;
local_panel(const local_panel& lp)
{
m_size = lp.m_size;
m_pos = lp.m_pos;
}
VE_FN_OVERIDE(); VE_FN_OVERIDE();
ImVec2 m_size = ImVec2{ 800.f, 400.f }; ImVec2 m_size = ImVec2{ 800.f, 400.f };

View File

@@ -9,6 +9,14 @@ namespace sandbox
// ATTENTION: активировать сигнальную систему в детях-компонентах // ATTENTION: активировать сигнальную систему в детях-компонентах
m_local_panel.on_attach(); m_local_panel.on_attach();
for (int i = 0; i < 200; ++i)
{
auto lp = std::make_shared<local_panel>();
lp->on_attach();
m_local_panel_hub.push_back(lp);
}
hack::log()("on_attach"); hack::log()("on_attach");
} }
@@ -21,6 +29,8 @@ namespace sandbox
m_local_panel.render(); m_local_panel.render();
for(auto& lp : m_local_panel_hub) lp->render();
ImGui::End(); ImGui::End();
} }

View File

@@ -14,6 +14,8 @@ namespace sandbox
ImVec2 m_pos = ImVec2{ 400.f, 400.f }; ImVec2 m_pos = ImVec2{ 400.f, 400.f };
local_panel m_local_panel; local_panel m_local_panel;
std::vector<std::shared_ptr<local_panel>> m_local_panel_hub;
}; };
} }

View File

@@ -38,11 +38,11 @@ namespace VE
struct event_manager : public hack::patterns::singleton<event_manager> struct event_manager : public hack::patterns::singleton<event_manager>
{ {
std::vector<VE::event_fn<VE::event>> funcs; std::vector<VE::event_fn<VE::event>> m_funcs;
void connect(event_fn<event> fn) { funcs.push_back(fn); }; void connect(event_fn<event> fn) { m_funcs.push_back(fn); };
void emit(event e) void emit(event e)
{ {
for(auto& f : funcs) for(auto& f : m_funcs)
{ {
try try
{ {
@@ -51,10 +51,11 @@ namespace VE
catch(std::exception& e) catch(std::exception& e)
{ {
hack::error()(e.what()); hack::error()(e.what());
hack::log()("size funcs", m_funcs.size());
} }
catch(...) catch(...)
{ {
hack::error()("ooops"); hack::error()("ooops...");
} }
} }
} }