mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ImGui fixed
- Disabled DpiAwareness - Now using ImGui implementation WndProcHandler - Fixed horizontal scrolling
This commit is contained in:
@@ -13,7 +13,7 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
public override void OnAttach()
|
public override void OnAttach()
|
||||||
{
|
{
|
||||||
ImGuiImplWin32.EnableDpiAwareness();
|
//ImGuiImplWin32.EnableDpiAwareness();
|
||||||
Log.EngineLogger.Trace("Initializing ImGui...");
|
Log.EngineLogger.Trace("Initializing ImGui...");
|
||||||
|
|
||||||
ImGui.CHECKVERSION();
|
ImGui.CHECKVERSION();
|
||||||
@@ -37,8 +37,6 @@ namespace GlitchyEngine.ImGui
|
|||||||
style.Colors[(int)ImGui.Col.WindowBg].w = 1.0f;
|
style.Colors[(int)ImGui.Col.WindowBg].w = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui.Dock
|
|
||||||
|
|
||||||
#if GE_WINDOWS
|
#if GE_WINDOWS
|
||||||
// Todo: temporary, needs to be platform independent
|
// Todo: temporary, needs to be platform independent
|
||||||
ImGuiImplWin32.Init((Windows.HWnd)(int)Application.Get().Window.NativeWindow);
|
ImGuiImplWin32.Init((Windows.HWnd)(int)Application.Get().Window.NativeWindow);
|
||||||
@@ -55,6 +53,7 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
public override void OnEvent(Event event)
|
public override void OnEvent(Event event)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
EventDispatcher dispatcher = scope EventDispatcher(event);
|
EventDispatcher dispatcher = scope EventDispatcher(event);
|
||||||
|
|
||||||
dispatcher.Dispatch<WindowResizeEvent>(scope (e) =>
|
dispatcher.Dispatch<WindowResizeEvent>(scope (e) =>
|
||||||
@@ -76,37 +75,49 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
dispatcher.Dispatch<MouseButtonPressedEvent>(scope (e) =>
|
dispatcher.Dispatch<MouseButtonPressedEvent>(scope (e) =>
|
||||||
{
|
{
|
||||||
ref ImGui.IO io = ref ImGui.GetIO();
|
int button = 0;
|
||||||
|
|
||||||
switch(e.MouseButton)
|
switch(e.MouseButton)
|
||||||
{
|
{
|
||||||
case .LeftButton:
|
case .LeftButton:
|
||||||
io.MouseDown[(uint)ImGui.MouseButton.Left] = true;
|
button = (uint)ImGui.MouseButton.Left;
|
||||||
case .RightButton:
|
case .RightButton:
|
||||||
io.MouseDown[(uint)ImGui.MouseButton.Right] = true;
|
button = (uint)ImGui.MouseButton.Right;
|
||||||
case .MiddleButton:
|
case .MiddleButton:
|
||||||
io.MouseDown[(uint)ImGui.MouseButton.Middle] = true;
|
button = (uint)ImGui.MouseButton.Middle;
|
||||||
|
case .XButton1:
|
||||||
|
button = (uint)3;
|
||||||
|
case .XButton2:
|
||||||
|
button = (uint)4;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ref ImGui.IO io = ref ImGui.GetIO();
|
||||||
|
io.MouseDown[button] = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatcher.Dispatch<MouseButtonReleasedEvent>(scope (e) =>
|
dispatcher.Dispatch<MouseButtonReleasedEvent>(scope (e) =>
|
||||||
{
|
{
|
||||||
ref ImGui.IO io = ref ImGui.GetIO();
|
int button = 0;
|
||||||
|
|
||||||
switch(e.MouseButton)
|
switch(e.MouseButton)
|
||||||
{
|
{
|
||||||
case .LeftButton:
|
case .LeftButton:
|
||||||
io.MouseDown[(uint)ImGui.MouseButton.Left] = false;
|
button = (uint)ImGui.MouseButton.Left;
|
||||||
case .RightButton:
|
case .RightButton:
|
||||||
io.MouseDown[(uint)ImGui.MouseButton.Right] = false;
|
button = (uint)ImGui.MouseButton.Right;
|
||||||
case .MiddleButton:
|
case .MiddleButton:
|
||||||
io.MouseDown[(uint)ImGui.MouseButton.Middle] = false;
|
button = (uint)ImGui.MouseButton.Middle;
|
||||||
|
case .XButton1:
|
||||||
|
button = (uint)3;
|
||||||
|
case .XButton2:
|
||||||
|
button = (uint)4;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ref ImGui.IO io = ref ImGui.GetIO();
|
||||||
|
io.MouseDown[button] = false;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,6 +132,9 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
dispatcher.Dispatch<KeyPressedEvent>(scope (e) =>
|
dispatcher.Dispatch<KeyPressedEvent>(scope (e) =>
|
||||||
{
|
{
|
||||||
|
if(e.KeyCode >= (.)256)
|
||||||
|
return false;
|
||||||
|
|
||||||
ref ImGui.IO io = ref ImGui.GetIO();
|
ref ImGui.IO io = ref ImGui.GetIO();
|
||||||
io.KeysDown[(int32)e.KeyCode] = true;
|
io.KeysDown[(int32)e.KeyCode] = true;
|
||||||
|
|
||||||
@@ -134,6 +148,9 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
dispatcher.Dispatch<KeyReleasedEvent>(scope (e) =>
|
dispatcher.Dispatch<KeyReleasedEvent>(scope (e) =>
|
||||||
{
|
{
|
||||||
|
if(e.KeyCode >= (.)256)
|
||||||
|
return false;
|
||||||
|
|
||||||
ref ImGui.IO io = ref ImGui.GetIO();
|
ref ImGui.IO io = ref ImGui.GetIO();
|
||||||
io.KeysDown[(int32)e.KeyCode] = false;
|
io.KeysDown[(int32)e.KeyCode] = false;
|
||||||
|
|
||||||
@@ -152,6 +169,7 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Begin()
|
public void Begin()
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ namespace GlitchyEngine
|
|||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.ImGuiImplWin32.WndProcHandler(hwnd, uMsg, wParam, lParam);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
////
|
////
|
||||||
@@ -371,8 +373,7 @@ namespace GlitchyEngine
|
|||||||
// Horizontal scrolling
|
// Horizontal scrolling
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
{
|
{
|
||||||
// horizontal scrolling is inverted for some reason
|
int32 rotation = (int16)HighOrder!((int64)wParam) / WHEEL_DELTA;
|
||||||
int32 rotation = -(int16)HighOrder!((int64)wParam) / WHEEL_DELTA;
|
|
||||||
|
|
||||||
var event = scope MouseScrolledEvent(rotation, 0);
|
var event = scope MouseScrolledEvent(rotation, 0);
|
||||||
window._eventCallback(event);
|
window._eventCallback(event);
|
||||||
|
|||||||
Reference in New Issue
Block a user