diff --git a/bin/layers/local_panel/local_panel.cpp b/bin/layers/local_panel/local_panel.cpp index 36c538d..beae37d 100755 --- a/bin/layers/local_panel/local_panel.cpp +++ b/bin/layers/local_panel/local_panel.cpp @@ -12,7 +12,7 @@ namespace sandbox void local_panel::render() { - if (ImGui::Button("RUN thread", ImVec2(28, 30))) + if (ImGui::Button("RUN thread", ImVec2(128, 130))) { auto f = []() { diff --git a/bin/layers/local_panel/local_panel.hpp b/bin/layers/local_panel/local_panel.hpp index a019cbb..94c739c 100755 --- a/bin/layers/local_panel/local_panel.hpp +++ b/bin/layers/local_panel/local_panel.hpp @@ -8,7 +8,7 @@ namespace sandbox { 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 }; }; } diff --git a/bin/layers/test_panel/test_panel.cpp b/bin/layers/test_panel/test_panel.cpp index dfbfb1c..e7e894b 100755 --- a/bin/layers/test_panel/test_panel.cpp +++ b/bin/layers/test_panel/test_panel.cpp @@ -16,9 +16,9 @@ namespace sandbox 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); } @@ -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_PRESSED) hack::log()("once"); } + + if (e.m_type.type() == typeid(test_event)) + { + auto t = std::any_cast(e.m_type); + if (t == test_event::TEST_EVEN) + hack::log()(std::any_cast(e.m_data)); + } } void test_panel::update() diff --git a/bin/main.cpp b/bin/main.cpp index f76ac75..ef48d1f 100755 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -1,6 +1,7 @@ #include "layers/test_panel/test_panel.hpp" #include "layers/test_panel_2/test_panel_2.hpp" #include "layers/opengl_panel/opengl_panel.hpp" +#include "layers/local_panel/local_panel.hpp" namespace sandbox { @@ -9,13 +10,6 @@ namespace sandbox public: test_app(std::string app_name) : VE::application{ app_name } {}; ~test_app() = default; - - public: - template - void push_layer(Args... args) - { - this->VE::application::push_layer(args...); - } }; } @@ -31,6 +25,13 @@ namespace VE 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; } } diff --git a/src/application/application.cpp b/src/application/application.cpp index 478d2cd..abfc521 100755 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -34,9 +34,4 @@ namespace VE { return m_instance; } - - void application::attach_layers() - { - for (auto l : m_layers_stack) l->on_attach(); - } } diff --git a/src/application/application.hpp b/src/application/application.hpp index 991bc87..66719b3 100755 --- a/src/application/application.hpp +++ b/src/application/application.hpp @@ -28,7 +28,12 @@ namespace VE void push_layer(Args*... args) { (m_layers_stack.push_back(args), ...); - attach_layers(); + } + + template + void on_attach(Args*... args) + { + (args->on_attach(), ...); } private: