diff --git a/include/Engine/Rendering/ImGuiRenderPass.h b/include/Engine/Rendering/ImGuiRenderPass.h index d28f1143..8b979bd0 100644 --- a/include/Engine/Rendering/ImGuiRenderPass.h +++ b/include/Engine/Rendering/ImGuiRenderPass.h @@ -5,6 +5,7 @@ #include "../Core/EMousePress.h" #include "../Core/EMouseRelease.h" #include "../Core/EMouseMove.h" +#include "../Core/EMouseScroll.h" #include "../Core/EKeyDown.h" #include "../Core/EKeyUp.h" #include "../Core/EKeyboardChar.h" @@ -23,6 +24,7 @@ private: GLFWwindow* g_Window; double g_Time = 0.0; + float g_MouseWheel = 0.f; GLuint g_FontTexture; int g_ShaderHandle; int g_VertHandle; @@ -42,6 +44,8 @@ private: bool OnMouseRelease(const Events::MouseRelease& e); EventRelay m_EMouseMove; bool OnMouseMove(const Events::MouseMove& e); + EventRelay m_EMouseScroll; + bool OnMouseScroll(const Events::MouseScroll& e); EventRelay m_EKeyDown; bool OnKeyDown(const Events::KeyDown& e); EventRelay m_EKeyUp; diff --git a/src/Engine/Rendering/ImGuiRenderPass.cpp b/src/Engine/Rendering/ImGuiRenderPass.cpp index 0acf9668..319eb98d 100644 --- a/src/Engine/Rendering/ImGuiRenderPass.cpp +++ b/src/Engine/Rendering/ImGuiRenderPass.cpp @@ -43,6 +43,7 @@ ImGuiRenderPass::ImGuiRenderPass(IRenderer* renderer, EventBroker* eventBroker) EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &ImGuiRenderPass::OnMousePress); EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &ImGuiRenderPass::OnMouseRelease); EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &ImGuiRenderPass::OnMouseMove); + EVENT_SUBSCRIBE_MEMBER(m_EMouseScroll, &ImGuiRenderPass::OnMouseScroll); EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &ImGuiRenderPass::OnKeyDown); EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &ImGuiRenderPass::OnKeyUp); EVENT_SUBSCRIBE_MEMBER(m_EKeyboardChar, &ImGuiRenderPass::OnKeyboardChar); @@ -66,6 +67,9 @@ void ImGuiRenderPass::Update(double dt) io.KeyShift = glfwGetKey(g_Window, GLFW_KEY_LEFT_SHIFT) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_SHIFT); io.KeyAlt = glfwGetKey(g_Window, GLFW_KEY_LEFT_ALT) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_ALT); + io.MouseWheel = g_MouseWheel; + g_MouseWheel = 0; + ImGui::NewFrame(); static float val = 0.f; @@ -184,6 +188,12 @@ bool ImGuiRenderPass::OnMouseMove(const Events::MouseMove& e) return true; } +bool ImGuiRenderPass::OnMouseScroll(const Events::MouseScroll& e) +{ + g_MouseWheel += (float)e.DeltaY; + return true; +} + bool ImGuiRenderPass::OnKeyDown(const Events::KeyDown& e) { ImGuiIO& io = ImGui::GetIO();