Exemplo n.º 1
0
        internal static void setIcon(GLFWWindow windowHandle, GLFWImage image)
        {
            //if (SharedLibraryLoader.isMac)
            //    return;

            GLFW.GLFW.SetWindowIcon(windowHandle, image);
        }
Exemplo n.º 2
0
        internal void create(GLFWWindow windowHandle)
        {
            this.windowHandle = windowHandle;
            input             = new Input(this);
            graphics          = new Graphics(this);


            // that's to aboid callbacks from getting garbage collected
            _focusFunc   = focusCallback;
            _iconifyFunc = iconifyCallback;
            _closeFunc   = closeCallback;
            _dropFunc    = dropCallback;
            _refreshFunc = refreshCallback;


            GLFW.GLFW.SetWindowFocusCallback(windowHandle, _focusFunc);
            GLFW.GLFW.SetWindowIconifyCallback(windowHandle, _iconifyFunc);
            // todo: missing binding
            //GLFW.GLFW.SetWindowMaximizeCallback(windowHandle, maximizeCallback);
            GLFW.GLFW.SetWindowCloseCallback(windowHandle, _closeFunc);
            GLFW.GLFW.SetDropCallback(windowHandle, _dropFunc);
            GLFW.GLFW.SetWindowRefreshCallback(windowHandle, _refreshFunc);

            if (windowListener != null)
            {
                windowListener.created(this);
            }
        }
Exemplo n.º 3
0
        private void keyCallback(GLFWWindow window1, GLFWKeyCode key, int scancode, GLFWInputState state, GLFWKeyMods mods)
        {
            switch (state)
            {
            case GLFW.GLFW.InputState.Press:
                var gdxkey = getGdxKeyCode(key);
                eventQueue.keyDown(gdxkey);
                pressedKeys++;
                keyJustPressed = true;
                justPressedKeys[(int)gdxkey] = true;
                window.getGraphics().requestRendering();
                lastCharacter = (char)0;
                char character = characterForKeyCode(gdxkey);
                if (character != 0)
                {
                    charCallback(window1, (uint)character);
                }
                break;

            case GLFW.GLFW.InputState.Release:
                pressedKeys--;
                window.getGraphics().requestRendering();
                eventQueue.keyUp(getGdxKeyCode(key));
                break;

            case GLFW.GLFW.InputState.Repeat:
                pressedKeys--;
                window.getGraphics().requestRendering();
                eventQueue.keyUp(getGdxKeyCode(key));
                break;
            }
        }
Exemplo n.º 4
0
        private void cursorPosCallback(GLFWWindow window1, double xpos, double ypos)
        {
            deltaX = (int)xpos - logicalMouseX;
            deltaY = (int)ypos - logicalMouseY;
            mouseX = logicalMouseX = (int)xpos;
            mouseY = logicalMouseY = (int)ypos;

            if (window.getConfig().hdpiMode == HdpiMode.Pixels)
            {
                float xScale = window.getGraphics().getBackBufferWidth() / (float)window.getGraphics().getLogicalWidth();
                float yScale = window.getGraphics().getBackBufferHeight() / (float)window.getGraphics().getLogicalHeight();
                deltaX = (int)(deltaX * xScale);
                deltaY = (int)(deltaY * yScale);
                mouseX = (int)(mouseX * xScale);
                mouseY = (int)(mouseY * yScale);
            }

            window.getGraphics().requestRendering();
            if (mousePressed > 0)
            {
                eventQueue.touchDragged(mouseX, mouseY, 0);
            }
            else
            {
                eventQueue.mouseMoved(mouseX, mouseY);
            }
        }
Exemplo n.º 5
0
 internal static void setSizeLimits(GLFWWindow windowHandle, int minWidth, int minHeight, int maxWidth, int maxHeight)
 {
     GLFW.GLFW.SetWindowSizeLimits(windowHandle,
                                   minWidth > -1 ? minWidth : GLFW.GLFW.DontCare,
                                   minHeight > -1 ? minHeight : GLFW.GLFW.DontCare,
                                   maxWidth > -1 ? maxWidth : GLFW.GLFW.DontCare,
                                   maxHeight > -1 ? maxHeight : GLFW.GLFW.DontCare);
 }
Exemplo n.º 6
0
 private void charCallback(GLFWWindow window1, uint codepoint)
 {
     if ((codepoint & 0xff00) == 0xf700)
     {
         return;
     }
     lastCharacter = (char)codepoint;
     window.getGraphics().requestRendering();
     eventQueue.keyTyped((char)codepoint);
 }
Exemplo n.º 7
0
 private void closeCallback(GLFWWindow window)
 {
     postRunnable((() =>
     {
         if (windowListener != null)
         {
             if (!windowListener.closeRequested())
             {
                 GLFW.GLFW.SetWindowShouldClose(window, false);
             }
         }
     }));
 }
Exemplo n.º 8
0
        private void resizeCallback(GLFWWindow window1, int width, int height)
        {
            updateFramebufferInfo();
            if (!window.isListenerInitialized())
            {
                return;
            }

            window.makeCurrent();
            GL.Viewport(0, 0, width, height);
            window.getListener().resize(getWidth(), getHeight());
            window.getListener().render();
            GLFW.GLFW.SwapBuffers(window1);
        }
Exemplo n.º 9
0
 private void iconifyCallback(GLFWWindow window, bool focused)
 {
     postRunnable((() =>
     {
         windowListener?.iconified(focused);
         iconified = focused;
         if (focused)
         {
             listener.pause();
         }
         else
         {
             listener.resume();
         }
     }));
 }
Exemplo n.º 10
0
 private void focusCallback(GLFWWindow window, bool focused)
 {
     postRunnable((() =>
     {
         if (windowListener != null)
         {
             if (focused)
             {
                 windowListener.focusGained();
             }
             else
             {
                 windowListener.focusLost();
             }
         }
     }));
 }
Exemplo n.º 11
0
        public void windowHandleChanged(GLFWWindow windowHandle)
        {
            resetPollingStates();

            _keyFunc         = keyCallback;
            _charFunc        = charCallback;
            _scrollFunc      = scrollCallback;
            _cursorPosFunc   = cursorPosCallback;
            _mouseButtonFunc = mouseButtonCallback;


            GLFW.GLFW.SetKeyCallback(window.getWindowHandle(), _keyFunc);
            GLFW.GLFW.SetCharCallback(window.getWindowHandle(), _charFunc);
            GLFW.GLFW.SetScrollCallback(window.getWindowHandle(), _scrollFunc);
            GLFW.GLFW.SetCursorPosCallback(window.getWindowHandle(), _cursorPosFunc);
            GLFW.GLFW.SetMouseButtonCallback(window.getWindowHandle(), _mouseButtonFunc);
        }
Exemplo n.º 12
0
        private void mouseButtonCallback(GLFWWindow window1, GLFWMouseButton button, GLFWInputState state, GLFWKeyMods mods)
        {
            var gdxButton = toGdxButton(button);

            if (gdxButton == Buttons.UKNOWN)
            {
                return;
            }

            if (state == GLFW.GLFW.InputState.Press)
            {
                mousePressed++;
                _justTouched = true;
                window.getGraphics().requestRendering();
                eventQueue.touchDown(mouseX, mouseY, 0, gdxButton);
            }
            else
            {
                mousePressed = Math.Max(0, mousePressed - 1);
                window.getGraphics().requestRendering();
                eventQueue.touchUp(mouseX, mouseY, 0, gdxButton);
            }
        }
Exemplo n.º 13
0
 private void dropCallback(GLFWWindow window, int count, string[] paths)
 {
     postRunnable((() => { windowListener?.filesDropped(paths); }));
 }
Exemplo n.º 14
0
 private void refreshCallback(GLFWWindow window)
 {
     postRunnable((() => { windowListener?.refreshRequested(); }));
 }
Exemplo n.º 15
0
 void windowHandleChanged(GLFWWindow windowHandle)
 {
     this.windowHandle = windowHandle;
     input.windowHandleChanged(windowHandle);
 }
Exemplo n.º 16
0
 private void scrollCallback(GLFWWindow window1, double xpos, double ypos)
 {
     window.getGraphics().requestRendering();
     eventQueue.scrolled((int)-Math.Sign(ypos));
 }