Subscribed ImGui to MouseScroll event
This commit is contained in:
@@ -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<ImGuiRenderPass, Events::MouseMove> m_EMouseMove;
|
||||
bool OnMouseMove(const Events::MouseMove& e);
|
||||
EventRelay<ImGuiRenderPass, Events::MouseScroll> m_EMouseScroll;
|
||||
bool OnMouseScroll(const Events::MouseScroll& e);
|
||||
EventRelay<ImGuiRenderPass, Events::KeyDown> m_EKeyDown;
|
||||
bool OnKeyDown(const Events::KeyDown& e);
|
||||
EventRelay<ImGuiRenderPass, Events::KeyUp> m_EKeyUp;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user