internal static void setIcon(GLFWWindow windowHandle, GLFWImage image) { //if (SharedLibraryLoader.isMac) // return; GLFW.GLFW.SetWindowIcon(windowHandle, image); }
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); } }
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; } }
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); } }
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); }
private void charCallback(GLFWWindow window1, uint codepoint) { if ((codepoint & 0xff00) == 0xf700) { return; } lastCharacter = (char)codepoint; window.getGraphics().requestRendering(); eventQueue.keyTyped((char)codepoint); }
private void closeCallback(GLFWWindow window) { postRunnable((() => { if (windowListener != null) { if (!windowListener.closeRequested()) { GLFW.GLFW.SetWindowShouldClose(window, false); } } })); }
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); }
private void iconifyCallback(GLFWWindow window, bool focused) { postRunnable((() => { windowListener?.iconified(focused); iconified = focused; if (focused) { listener.pause(); } else { listener.resume(); } })); }
private void focusCallback(GLFWWindow window, bool focused) { postRunnable((() => { if (windowListener != null) { if (focused) { windowListener.focusGained(); } else { windowListener.focusLost(); } } })); }
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); }
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); } }
private void dropCallback(GLFWWindow window, int count, string[] paths) { postRunnable((() => { windowListener?.filesDropped(paths); })); }
private void refreshCallback(GLFWWindow window) { postRunnable((() => { windowListener?.refreshRequested(); })); }
void windowHandleChanged(GLFWWindow windowHandle) { this.windowHandle = windowHandle; input.windowHandleChanged(windowHandle); }
private void scrollCallback(GLFWWindow window1, double xpos, double ypos) { window.getGraphics().requestRendering(); eventQueue.scrolled((int)-Math.Sign(ypos)); }