Example #1
0
        public static void SetMouseButtonCallback(IntPtr window, MouseButtonCallback callback)
        {
            lock (Lock) {
                CallbackCache[nameof(SetMouseButtonCallback)] = callback;
            }

            SetMouseButtonCallback(window, callback == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(callback));
        }
Example #2
0
        public static MouseButtonCallback SetMouseButtonCallback(WindowPtr window, MouseButtonCallback callback)
        {
            var callbacks = GetCallbacks(window);
            var old       = callbacks.mouseButton;

            callbacks.mouseButton = callback;
            glfwSetMouseButtonCallback(window, callback);
            CheckError();
            return(old);
        }
Example #3
0
 public static void init()
 {
     keyPressedCallback     = null;
     keyReleasedCallback    = null;
     padMovedCallback       = null;
     buttonPressedCallback  = null;
     buttonReleasedCallback = null;
     mouseMovedCallback     = null;
     mousePressedCallback   = null;
     mouseReleasedCallback  = null;
 }
Example #4
0
        public static void clearCallbacks()
        {
            // Clear callbacks
            keyPressedCallback     = null;
            keyReleasedCallback    = null;
            padMovedCallback       = null;
            buttonPressedCallback  = null;
            buttonReleasedCallback = null;
            mouseMovedCallback     = null;
            mousePressedCallback   = null;
            mouseReleasedCallback  = null;

            // Reset states
            oldMouse    = newMouse;
            oldKeyboard = newKeyboard;
            oldGamePad  = newGamePad;
        }
Example #5
0
 static extern void GLUT_RegisterMouse(
     MouseMoveCallback mouseMoveCallback,
     MouseButtonCallback mouseDownCallback,
     MouseButtonCallback mouseUpCallback);
 public static extern IntPtr glfwSetMouseButtonCallback(WindowPtr window, MouseButtonCallback callback);
Example #7
0
 public static void setMouseReleasedCallback(MouseButtonCallback callback)
 {
     mouseReleasedCallback = callback;
 }
Example #8
0
        static bool ImGui_ImplGlfw_Init(Window window, bool installCallbacks)
        {
            windowHandle = window;
            time         = 0.0f;

            ImGuiIOPtr io = ImGui.GetIO();

            io.BackendFlags |= ImGuiBackendFlags.HasMouseCursors;
            io.BackendFlags |= ImGuiBackendFlags.HasSetMousePos;
            //io.BackendPlatformName = "imgui_impl_glfw";

            io.KeyMap[(int)ImGuiKey.Tab]         = (int)Keys.Tab;
            io.KeyMap[(int)ImGuiKey.LeftArrow]   = (int)Keys.Left;
            io.KeyMap[(int)ImGuiKey.RightArrow]  = (int)Keys.Right;
            io.KeyMap[(int)ImGuiKey.UpArrow]     = (int)Keys.Up;
            io.KeyMap[(int)ImGuiKey.DownArrow]   = (int)Keys.Down;
            io.KeyMap[(int)ImGuiKey.PageUp]      = (int)Keys.PageUp;
            io.KeyMap[(int)ImGuiKey.PageDown]    = (int)Keys.PageDown;
            io.KeyMap[(int)ImGuiKey.Home]        = (int)Keys.Home;
            io.KeyMap[(int)ImGuiKey.End]         = (int)Keys.End;
            io.KeyMap[(int)ImGuiKey.Insert]      = (int)Keys.Insert;
            io.KeyMap[(int)ImGuiKey.Delete]      = (int)Keys.Delete;
            io.KeyMap[(int)ImGuiKey.Backspace]   = (int)Keys.Backspace;
            io.KeyMap[(int)ImGuiKey.Space]       = (int)Keys.Space;
            io.KeyMap[(int)ImGuiKey.Enter]       = (int)Keys.Enter;
            io.KeyMap[(int)ImGuiKey.Escape]      = (int)Keys.Escape;
            io.KeyMap[(int)ImGuiKey.KeyPadEnter] = (int)Keys.NumpadEnter;
            io.KeyMap[(int)ImGuiKey.A]           = (int)Keys.A;
            io.KeyMap[(int)ImGuiKey.C]           = (int)Keys.C;
            io.KeyMap[(int)ImGuiKey.V]           = (int)Keys.V;
            io.KeyMap[(int)ImGuiKey.X]           = (int)Keys.X;
            io.KeyMap[(int)ImGuiKey.Y]           = (int)Keys.Y;
            io.KeyMap[(int)ImGuiKey.Z]           = (int)Keys.Z;

//            io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
//            io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
//            io.ClipboardUserData = g_Window;
//#if defined(_WIN32)
//            io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
//#endif

            ErrorCallback prev_error_callback = Glfw.SetErrorCallback(null);

            mouseCursors[(int)ImGuiMouseCursor.Arrow]     = Glfw.CreateStandardCursor(CursorType.Arrow);
            mouseCursors[(int)ImGuiMouseCursor.TextInput] = Glfw.CreateStandardCursor(CursorType.Beam);
            mouseCursors[(int)ImGuiMouseCursor.ResizeNS]  = Glfw.CreateStandardCursor(CursorType.ResizeVertical);
            mouseCursors[(int)ImGuiMouseCursor.ResizeEW]  = Glfw.CreateStandardCursor(CursorType.ResizeHorizontal);
            mouseCursors[(int)ImGuiMouseCursor.Hand]      = Glfw.CreateStandardCursor(CursorType.Hand);

            // if GLFW_HAS_NEW_CURSORS
            //mouseCursors[(int)ImGuiMouseCursor.ResizeAll] = GLFW.Glfw.CreateStandardCursor(GLFW.CursorType. GLFW_RESIZE_ALL_CURSOR);
            //mouseCursors[(int)ImGuiMouseCursor.ResizeNESW] = GLFW.Glfw.CreateStandardCursor(GLFW.CursorType. GLFW_RESIZE_NESW_CURSOR);
            //mouseCursors[(int)ImGuiMouseCursor.ResizeNWSE] = GLFW.Glfw.CreateStandardCursor(GLFW.CursorType. GLFW_RESIZE_NWSE_CURSOR);
            //mouseCursors[(int)ImGuiMouseCursor.NotAllowed] = GLFW.Glfw.CreateStandardCursor(GLFW.CursorType. GLFW_NOT_ALLOWED_CURSOR);

            mouseCursors[(int)ImGuiMouseCursor.ResizeAll]  = Glfw.CreateStandardCursor(CursorType.Arrow);
            mouseCursors[(int)ImGuiMouseCursor.ResizeNESW] = Glfw.CreateStandardCursor(CursorType.Arrow);
            mouseCursors[(int)ImGuiMouseCursor.ResizeNWSE] = Glfw.CreateStandardCursor(CursorType.Arrow);
            mouseCursors[(int)ImGuiMouseCursor.NotAllowed] = Glfw.CreateStandardCursor(CursorType.Arrow);

            Glfw.SetErrorCallback(prev_error_callback);

            prevUserCallbackMousebutton = null;
            prevUserCallbackScroll      = null;
            prevUserCallbackKey         = null;
            prevUserCallbackChar        = null;
            if (installCallbacks)
            {
                installedCallbacks          = true;
                prevUserCallbackMousebutton = Glfw.SetMouseButtonCallback(windowHandle, mousebuttonCallbackHolder = ImGui_ImplGlfw_MouseButtonCallback);
                prevUserCallbackScroll      = Glfw.SetScrollCallback(windowHandle, scrollCallbackHolder = ImGui_ImplGlfw_ScrollCallback);
                prevUserCallbackKey         = Glfw.SetKeyCallback(windowHandle, keyCallbackHolder = ImGui_ImplGlfw_KeyCallback);
                prevUserCallbackChar        = Glfw.SetCharCallback(windowHandle, charCallbackHolder = ImGui_ImplGlfw_CharCallback);
            }

            return(true);
        }
Example #9
0
 public static extern void SetMouseButtonCallback(MouseButtonCallback callback);
Example #10
0
 public static void AddMouseUpListener(MouseButtonCallback action)
 {
     Platform.OnMouseUp += action;
 }
Example #11
0
        public static MouseButtonCallback SetMouseButtonCallback(WindowHandle window, MouseButtonCallback callback)
        {
            var old = glfwSetMouseButtonCallback(window, callback);

            CheckError(nameof(SetMouseButtonCallback));
            return(old);
        }
Example #12
0
 private static extern MouseButtonCallback glfwSetMouseButtonCallback(WindowHandle window, MouseButtonCallback callback);