Exemple #1
0
    def process_inputs(self):
        # todo: consider moving to init
        io = imgui.get_io()

        w, h = glfw.glfwGetWindowSize(self.handle)
        dw, dh = glfw.glfwGetFramebufferSize(self.handle)

        io.display_size = w, h
        io.display_fb_scale = float(dw) / w, float(dh) / h

        io.delta_time = 1.0 / 60

        if glfw.glfwGetWindowAttrib(self.handle, glfw.GLFW_FOCUSED):
            io.mouse_pos = glfw.glfwGetCursorPos(self.handle)
        else:
            io.mouse_pos = -1, -1

        io.mouse_down[0] = glfw.glfwGetMouseButton(self.handle, 0)
        io.mouse_down[1] = glfw.glfwGetMouseButton(self.handle, 1)
        io.mouse_down[2] = glfw.glfwGetMouseButton(self.handle, 2)

        current_time = glfw.glfwGetTime()

        if self._gui_time:
            self.io.delta_time = current_time - self._gui_time
        else:
            self.io.delta_time = 1. / 60.

        self._gui_time = current_time
Exemple #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)
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)