Пример #1
0
 def process_unconsumed_user_input(self, user_input):
     if self.is_minimized():
         return
     x, y = glfw.glfwGetCursorPos(self._window)
     # x, y are in screen coordinates. pyglui expects pixel coordinates.
     pos = self.screen_to_pixel(x, y)
     pos = normalize(pos, self.framebuffer_size)
     # Position in img pixels
     pos = denormalize(pos, self.texture.shape[:2])
     for button, action, mods in user_input.buttons:
         self.on_click(pos, button, action)
Пример #2
0
        def on_mouse_button(win, button, action, mods):
            x, y = glfw.glfwGetCursorPos(win)
            if self._hidpi:
                x, y = 2 * x, 2 * y

            button = __mouse_map__.get(button, window.mouse.UNKNOWN)
            if action == glfw.GLFW_RELEASE:
                self._button = window.mouse.NONE
                self._mouse_x = x
                self._mouse_y = y
                self.dispatch_event('on_mouse_release', x, y, button)
            elif action == glfw.GLFW_PRESS:
                self._button = button
                self._mouse_x = x
                self._mouse_y = y
                self.dispatch_event('on_mouse_press', x, y, button)
Пример #3
0
 def on_scroll(win, xoffset, yoffset):
     x, y = glfw.glfwGetCursorPos(win)
     if self._hidpi:
         x, y = 2 * x, 2 * y
     self.dispatch_event('on_mouse_scroll', x, y, xoffset, yoffset)