Пример #1
0
        public static CharCallback SetCharCallback(WindowHandle window, CharCallback callback)
        {
            var old = glfwSetCharCallback(window, callback);

            CheckError(nameof(SetCharCallback));
            return(old);
        }
Пример #2
0
        public static void SetCharCallback(IntPtr window, CharCallback callback)
        {
            lock (Lock) {
                CallbackCache[nameof(SetCharCallback)] = callback;
            }

            SetCharCallback(window, callback == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(callback));
        }
Пример #3
0
        public static CharCallback SetCharCallback(WindowPtr window, CharCallback callback)
        {
            var callbacks = GetCallbacks(window);
            var old       = callbacks._char;

            callbacks._char = callback;
            glfwSetCharCallback(window, callback);
            CheckError();
            return(old);
        }
Пример #4
0
        private bool RegisterKeyHandler(CharCallback charCallback = null)
        {
            if (charCallback == null)
            {
                charCallback = KeyDownExternal;
            }

            IntPtr callback = Marshal.GetFunctionPointerForDelegate(charCallback);

            _handle = RegisterExternalSubscriber(callback);

            return(true);
        }
Пример #5
0
        private bool RegisterKeyHandler(CharCallback charCallback = null)
        {
            if (charCallback == null)
            {
                charCallback = KeyDownExternal;
            }

            try
            {
                IntPtr callback = Marshal.GetFunctionPointerForDelegate(charCallback);
                _handle = RegisterExternalSubscriber(callback);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(true);
        }
Пример #6
0
 static extern void Noesis_Win32Display_RegisterCallbacks(
     LocationChangedCallback locationChangedCallback,
     SizeChangedCallback sizeChangedCallback,
     StateChangedCallback stateChangedCallback,
     FileDroppedCallback fileDroppedCallback,
     ActivatedCallback activatedCallback,
     DeactivatedCallback deactivatedCallback,
     RenderCallback renderCallback,
     MouseMoveCallback mouseMoveCallback,
     MouseButtonDownCallback mouseButtonDownCallback,
     MouseButtonUpCallback mouseButtonUpCallback,
     MouseDoubleClickCallback mouseDoubleClickCallback,
     MouseWheelCallback mouseWheelCallback,
     KeyDownCallback keyDownCallback,
     KeyUpCallback keyUpCallback,
     CharCallback charCallback,
     TouchMoveCallback touchMoveCallback,
     TouchDownCallback touchDownCallback,
     TouchUpCallback touchUpCallback);
Пример #7
0
 public static extern IntPtr glfwSetCharCallback(WindowPtr window, CharCallback callback);
Пример #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);
        }
Пример #9
0
 public static void SendMeABC( CharCallback userCallback)
 {
     SampleClass_SendMeABC ( userCallback );
 }
Пример #10
0
 private static extern void SampleClass_SendMeABC(CharCallback cb);
Пример #11
0
 private static extern CharCallback glfwSetCharCallback(WindowHandle window, CharCallback callback);