Esempio n. 1
0
    def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
        x, y = x_y_pan_scale(x, y, self.pan_scale, self.screen_size)
        dx, dy = int(dx / self.pan_scale[1]), int(dy / self.pan_scale[1])

        if buttons == 1:
            if self.incr:
                t = self.document.text
                n = float(t) if '.' in t else int(t)
                i = dy / 10 if (modifiers == 1 or modifiers == 17) else dy
                r = n + i
                s = str(r) if isinstance(r, int) else "%.2f" % r
                self.document.text = s
                self.caret.visible = False
                self.caret.position = self.caret.mark = len(self.document.text)
                self.resize_field()
                self.x -= dx
                self.y -= dy
                self.need_update = True
            elif self.resize:
                self.w = max(self.w + dx * 2, 70)
                self.h = max(self.h - dy * 2, 30)
                self.x -= dx
                self.y -= dy
            elif self.hover and self.caret.visible:
                self.caret.on_mouse_drag(x, y, dx, dy, buttons, modifiers)
                self.x -= dx
                self.y -= dy
        self.style()
Esempio n. 2
0
    def on_mouse_press(self, x, y, button, modifiers):
        x, y = x_y_pan_scale(x, y, self.pan_scale, self.screen_size)

        if button == 1:
            if self.hover:
                self.set_focus()
                self.caret.on_mouse_press(x, y, button, modifiers)
            else:
                self.lost_focus()
Esempio n. 3
0
    def on_mouse_press(self, x, y, button, modifiers):
        x, y = x_y_pan_scale(x, y, self.pan_scale, self.screen_size)

        if self.intersect_corner((x, y)):
            self.resize = True
        elif button == 1 and self.hover:
            self.set_focus()
            self.caret.on_mouse_press(x, y, button, modifiers)
            self.update_highlighting()
Esempio n. 4
0
    def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
        x, y = x_y_pan_scale(x, y, self.pan_scale, self.screen_size)
        dx, dy = int(dx / self.pan_scale[1]), int(dy / self.pan_scale[1])

        if buttons == 1 and self.resize:
            width = max(self.node.editor_size[0] + dx, 300)
            height = max(self.node.editor_size[1] - dy, 150)
            self.node.editor_size = width, height
        elif buttons == 1 and self.hover:
            self.caret.on_mouse_drag(x, y, dx, dy, buttons, modifiers)