add on attach for emit signal
This commit is contained in:
@@ -12,7 +12,7 @@ namespace sandbox
|
|||||||
void local_panel::render()
|
void local_panel::render()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ImGui::Button("RUN thread", ImVec2(28, 30)))
|
if (ImGui::Button("RUN thread", ImVec2(128, 130)))
|
||||||
{
|
{
|
||||||
auto f = []()
|
auto f = []()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace sandbox
|
|||||||
{
|
{
|
||||||
VE_FN_OVERIDE();
|
VE_FN_OVERIDE();
|
||||||
|
|
||||||
ImVec2 m_size = ImVec2{ 400.f, 400.f };
|
ImVec2 m_size = ImVec2{ 800.f, 400.f };
|
||||||
ImVec2 m_pos = ImVec2{ 400.f, 400.f };
|
ImVec2 m_pos = ImVec2{ 400.f, 400.f };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ namespace sandbox
|
|||||||
|
|
||||||
if (!ImGui::Begin("#test_panel_1", &m_p_open, m_window_flags)) ImGui::End();
|
if (!ImGui::Begin("#test_panel_1", &m_p_open, m_window_flags)) ImGui::End();
|
||||||
|
|
||||||
if (ImGui::Button("RUN", ImVec2(28, 30)))
|
if (ImGui::Button("RUN test_panel_1", ImVec2(128, 130)))
|
||||||
{
|
{
|
||||||
VE::event e { test_event::TEST_EVEN , std::string("test event message") };
|
VE::event e { test_event::TEST_EVEN , std::string("test event message tp 1") };
|
||||||
VE_EMIT(e);
|
VE_EMIT(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +33,13 @@ namespace sandbox
|
|||||||
if (t == VE::event_type::MOUSE_BUTTON_DOUBLE_PRESSED) hack::log()("double");
|
if (t == VE::event_type::MOUSE_BUTTON_DOUBLE_PRESSED) hack::log()("double");
|
||||||
if (t == VE::event_type::MOUSE_BUTTON_PRESSED) hack::log()("once");
|
if (t == VE::event_type::MOUSE_BUTTON_PRESSED) hack::log()("once");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.m_type.type() == typeid(test_event))
|
||||||
|
{
|
||||||
|
auto t = std::any_cast<test_event>(e.m_type);
|
||||||
|
if (t == test_event::TEST_EVEN)
|
||||||
|
hack::log()(std::any_cast<std::string>(e.m_data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_panel::update()
|
void test_panel::update()
|
||||||
|
|||||||
15
bin/main.cpp
15
bin/main.cpp
@@ -1,6 +1,7 @@
|
|||||||
#include "layers/test_panel/test_panel.hpp"
|
#include "layers/test_panel/test_panel.hpp"
|
||||||
#include "layers/test_panel_2/test_panel_2.hpp"
|
#include "layers/test_panel_2/test_panel_2.hpp"
|
||||||
#include "layers/opengl_panel/opengl_panel.hpp"
|
#include "layers/opengl_panel/opengl_panel.hpp"
|
||||||
|
#include "layers/local_panel/local_panel.hpp"
|
||||||
|
|
||||||
namespace sandbox
|
namespace sandbox
|
||||||
{
|
{
|
||||||
@@ -9,13 +10,6 @@ namespace sandbox
|
|||||||
public:
|
public:
|
||||||
test_app(std::string app_name) : VE::application{ app_name } {};
|
test_app(std::string app_name) : VE::application{ app_name } {};
|
||||||
~test_app() = default;
|
~test_app() = default;
|
||||||
|
|
||||||
public:
|
|
||||||
template<typename... Args>
|
|
||||||
void push_layer(Args... args)
|
|
||||||
{
|
|
||||||
this->VE::application::push_layer(args...);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +25,13 @@ namespace VE
|
|||||||
new sandbox::opengl_panel{}
|
new sandbox::opengl_panel{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.on_attach(
|
||||||
|
new sandbox::test_panel{},
|
||||||
|
new sandbox::test_panel_2{},
|
||||||
|
new sandbox::opengl_panel{},
|
||||||
|
new sandbox::local_panel{}
|
||||||
|
);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,4 @@ namespace VE
|
|||||||
{
|
{
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void application::attach_layers()
|
|
||||||
{
|
|
||||||
for (auto l : m_layers_stack) l->on_attach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ namespace VE
|
|||||||
void push_layer(Args*... args)
|
void push_layer(Args*... args)
|
||||||
{
|
{
|
||||||
(m_layers_stack.push_back(args), ...);
|
(m_layers_stack.push_back(args), ...);
|
||||||
attach_layers();
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
void on_attach(Args*... args)
|
||||||
|
{
|
||||||
|
(args->on_attach(), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user