From 06034c688d6f9344860200ba79d85b62b9a62a6f Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Sun, 31 Jan 2016 11:58:06 -0800 Subject: [PATCH] Wrap some mouse-related functions --- src/ImGui.NET/ImGui.cs | 93 ++++++++++++++++++++++++++++++++++++ src/ImGui.NET/ImGuiNative.cs | 6 +-- 2 files changed, 96 insertions(+), 3 deletions(-) diff --git a/src/ImGui.NET/ImGui.cs b/src/ImGui.NET/ImGui.cs index 96ec2e9..b02ee4d 100644 --- a/src/ImGui.NET/ImGui.cs +++ b/src/ImGui.NET/ImGui.cs @@ -518,6 +518,99 @@ namespace ImGuiNET ImGuiNative.igEndChildFrame(); } + public static bool IsKeyDown(int keyIndex) + { + return ImGuiNative.igIsKeyDown(keyIndex); + } + + public static bool IsKeyPressed(int keyIndex, bool repeat) + { + return ImGuiNative.igIsKeyPressed(keyIndex, repeat); + } + + public static bool IsKeyReleased(int keyIndex) + { + return ImGuiNative.igIsKeyReleased(keyIndex); + } + + public static bool IsMouseDown(int button) + { + return ImGuiNative.igIsMouseDown(button); + } + + public static bool IsMouseClicked(int button, bool repeat) + { + return ImGuiNative.igIsMouseClicked(button, repeat); + } + + public static bool IsMouseDoubleClicked(int button) + { + return ImGuiNative.igIsMouseDoubleClicked(button); + } + + public static bool IsMouseReleased(int button) + { + return ImGuiNative.igIsMouseReleased(button); + } + + public static bool IsMouseHoveringWindow() + { + return ImGuiNative.igIsMouseHoveringWindow(); + } + + public static bool IsMouseHoveringAnyWindow() + { + return ImGuiNative.igIsMouseHoveringAnyWindow(); + } + + public static bool IsMouseHoveringRect(Vector2 minPosition, Vector2 maxPosition, bool clip) + { + return IsMouseHoveringRect(minPosition, maxPosition, clip); + } + + public static bool IsMouseDragging(int button, float lockThreshold) + { + return ImGuiNative.igIsMouseDragging(button, lockThreshold); + } + + public static Vector2 GetMousePos() + { + Vector2 retVal; + ImGuiNative.igGetMousePos(out retVal); + return retVal; + } + + public static Vector2 GetMousePosOnOpeningCurrentPopup() + { + Vector2 retVal; + ImGuiNative.igGetMousePosOnOpeningCurrentPopup(out retVal); + return retVal; + } + + public static Vector2 GetMouseDragDelta(int button, float lockThreshold) + { + Vector2 retVal; + ImGuiNative.igGetMouseDragDelta(out retVal, button, lockThreshold); + return retVal; + } + + public static void ResetMouseDragDelta(int button) + { + ImGuiNative.igResetMouseDragDelta(button); + } + + public static MouseCursorKind MouseCursor + { + get + { + return ImGuiNative.igGetMouseCursor(); + } + set + { + ImGuiNative.igSetMouseCursor(value); + } + } + public static bool BeginChild(string id, Vector2 size, bool border, WindowFlags flags) { return ImGuiNative.igBeginChild(id, size, border, flags); diff --git a/src/ImGui.NET/ImGuiNative.cs b/src/ImGui.NET/ImGuiNative.cs index c1d9c2b..50bbc9c 100644 --- a/src/ImGui.NET/ImGuiNative.cs +++ b/src/ImGui.NET/ImGuiNative.cs @@ -703,11 +703,11 @@ namespace ImGuiNET [return: MarshalAs(UnmanagedType.I1)] public static extern bool igIsMouseDragging(int button, float lock_threshold); [DllImport(cimguiLib)] - public static extern void igGetMousePos(Vector2* pOut); + public static extern void igGetMousePos(out Vector2 pOut); [DllImport(cimguiLib)] - public static extern void igGetMousePosOnOpeningCurrentPopup(Vector2* pOut); + public static extern void igGetMousePosOnOpeningCurrentPopup(out Vector2 pOut); [DllImport(cimguiLib)] - public static extern void igGetMouseDragDelta(Vector2* pOut, int button, float lock_threshold); + public static extern void igGetMouseDragDelta(out Vector2 pOut, int button, float lock_threshold); [DllImport(cimguiLib)] public static extern void igResetMouseDragDelta(int button); [DllImport(cimguiLib)]