diff --git a/bin/layers/test_panel/test_panel.cpp b/bin/layers/test_panel/test_panel.cpp index 364ce48..70329c8 100755 --- a/bin/layers/test_panel/test_panel.cpp +++ b/bin/layers/test_panel/test_panel.cpp @@ -22,7 +22,7 @@ namespace sandbox if (ImGui::Button("RUN", ImVec2(28, 30))) { - VE::event e { test_event::TEST_EVEN , std::string("test event message") }; + VE::event e { "target_id", test_event::TEST_EVEN , std::string("test event message") }; execute(e); } diff --git a/bin/layers/test_panel_2/test_panel_2.cpp b/bin/layers/test_panel_2/test_panel_2.cpp index a33cf97..31efa0d 100755 --- a/bin/layers/test_panel_2/test_panel_2.cpp +++ b/bin/layers/test_panel_2/test_panel_2.cpp @@ -24,7 +24,7 @@ namespace sandbox if (!ImGui::Begin("#test_panel_2", &m_p_open, m_window_flags)) ImGui::End(); if (ImGui::Button("RUN", ImVec2(28, 30))) { - VE::event e { test_event::TEST_EVEN , std::string("test event message") }; + VE::event e { "target_id", test_event::TEST_EVEN , std::string("test event message") }; execute(e); } @@ -32,7 +32,7 @@ namespace sandbox if (ImGui::Button(VE::style::icon::ICON_STOP, ImVec2(28, 30))) { - VE::event e { test_event::TEST_EVEN , std::string("test icon button") }; + VE::event e { "target_id", test_event::TEST_EVEN , std::string("test icon button") }; execute(e); } diff --git a/bin/main.cpp b/bin/main.cpp index 83c5b20..f76ac75 100755 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -23,15 +23,15 @@ namespace VE { inline application& create() { - static sandbox::test_app e{ "vertex_engine_sandbox" }; + static sandbox::test_app app{ "vertex_engine_sandbox" }; - e.push_layer( + app.push_layer( new sandbox::test_panel{}, new sandbox::test_panel_2{}, new sandbox::opengl_panel{} ); - return e; + return app; } } diff --git a/src/application/application.cpp b/src/application/application.cpp index 2831cf4..519541e 100755 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -48,7 +48,7 @@ namespace VE for (const auto l : m_layers_stack) l->set_event_fn(VE_EVENT_FN); } - void application::on_event(event& e) + void application::on_event(event e) { if (e.is_parallele) for (auto l : m_layers_stack) auto future = std::async(std::launch::async, [&]() { l->on_event(e); }); diff --git a/src/application/application.hpp b/src/application/application.hpp index d6ed44b..6c13045 100755 --- a/src/application/application.hpp +++ b/src/application/application.hpp @@ -36,7 +36,7 @@ namespace VE void clear(); void attach_layers(); void set_event_fn(); - void on_event(event& e); + void on_event(event e); }; // реализация см. в проекте diff --git a/src/event/event.hpp b/src/event/event.hpp index b4a3a28..ce6b46f 100755 --- a/src/event/event.hpp +++ b/src/event/event.hpp @@ -22,12 +22,21 @@ namespace VE WINDOW_FOCUS, }; + enum class event_target + { + VE + }; + struct event { - event(std::any t, std::any d) : m_type{ t }, m_data{ d } {} + event(std::any target, std::any type, std::any data) : m_target { target }, m_type{ type }, m_data{ data } {} ~event() = default; + + std::any m_target; std::any m_type; std::any m_data; + // HERE + // как-то не прикольно так !!! bool is_parallele{ false }; }; } diff --git a/src/glfw/glfw.cpp b/src/glfw/glfw.cpp index 09a82a2..9532c97 100755 --- a/src/glfw/glfw.cpp +++ b/src/glfw/glfw.cpp @@ -121,7 +121,7 @@ namespace VE glfwSetKeyCallback(m_win, [](GLFWwindow* w, int key, int scancode, int action, int mods) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ action, key }; + event e{ event_target::VE, action, key }; // HERE // тут одноврекменно срабатывает только один сигнал @@ -157,7 +157,7 @@ namespace VE glfwSetMouseButtonCallback(m_win, [](GLFWwindow* w, int button, int action, int mods) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ action, button }; + event e{ event_target::VE, action, button }; switch (action) { @@ -188,14 +188,14 @@ namespace VE glfwSetScrollCallback(m_win, [](GLFWwindow* w, double xOffset, double yOffset) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_type::MOUSE_SCROLL, std::pair{ static_cast(xOffset), static_cast(yOffset) } }; + event e{ event_target::VE, event_type::MOUSE_SCROLL, std::pair{ static_cast(xOffset), static_cast(yOffset) } }; d->execute(e); }); glfwSetCursorPosCallback(m_win, [](GLFWwindow* w, double xPos, double yPos) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_type::MOUSE_CURSOR_POSITION, std::pair{ static_cast(xPos), static_cast(yPos) } }; + event e{ event_target::VE, event_type::MOUSE_CURSOR_POSITION, std::pair{ static_cast(xPos), static_cast(yPos) } }; d->execute(e); }); } @@ -210,21 +210,21 @@ namespace VE d->m_width = width; d->m_height = height; - event e{ event_type::WINDOW_RESIZE, std::pair{ static_cast(width), static_cast(height) } }; + event e{ event_target::VE, event_type::WINDOW_RESIZE, std::pair{ static_cast(width), static_cast(height) } }; d->execute(e); }); glfwSetWindowCloseCallback(m_win, [](GLFWwindow* w) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_type::WINDOW_CLOSE, nullptr }; + event e{ event_target::VE, event_type::WINDOW_CLOSE, nullptr }; d->execute(e); }); glfwSetWindowFocusCallback(m_win, [](GLFWwindow* w, int focused) { auto d = static_cast(glfwGetWindowUserPointer(w)); - event e{ event_type::WINDOW_FOCUS, focused }; + event e{ event_target::VE, event_type::WINDOW_FOCUS, focused }; d->execute(e); }); diff --git a/src/glfw/glfw.hpp b/src/glfw/glfw.hpp index e86591c..c2ebd96 100755 --- a/src/glfw/glfw.hpp +++ b/src/glfw/glfw.hpp @@ -40,7 +40,7 @@ namespace VE void update(); void clear() const; - void set_event_fn(const event_fn& fn); + void set_event_fn(const event_fn& fn); private: void set_hint(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0b03c78..bbd54fb 100755 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -43,8 +43,8 @@ namespace VE void gui::end_frame() { - ImGuiIO& io = ImGui::GetIO(); - io.DisplaySize = ImVec2((float)m_glfw->width(), (float)m_glfw->height()); + // ImGuiIO& io = ImGui::GetIO(); + // io.DisplaySize = ImVec2((float)m_glfw->width(), (float)m_glfw->height()); ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); diff --git a/src/layer/layer.hpp b/src/layer/layer.hpp index 6b166e1..a7585d6 100755 --- a/src/layer/layer.hpp +++ b/src/layer/layer.hpp @@ -22,10 +22,10 @@ namespace VE virtual void render() {}; virtual void on_event(event e) {}; - void set_event_fn(const event_fn& fn) { execute = fn; }; + void set_event_fn(const event_fn& fn) { execute = fn; }; protected: - event_fn execute; + event_fn execute; }; } diff --git a/src/utils/using.hpp b/src/utils/using.hpp index f8be6a8..ed01663 100644 --- a/src/utils/using.hpp +++ b/src/utils/using.hpp @@ -5,7 +5,7 @@ namespace VE { template - using event_fn = std::function; + using event_fn = std::function; template using layers_stack = std::vector;