How to use the pyno.utils.x_y_pan_scale function in pyno

To help you get started, we’ve selected a few pyno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github honix / Pyno / pyno / window.py View on Github external
def on_mouse_motion(self, x, y, dx, dy):
        self.mouse = (x, y)

        x, y = x_y_pan_scale(x, y, self.pan_scale, self.get_size())
        self.pointer = (x, y)

        if not self.selected_nodes:
            if self.code_editor:
                if self.code_editor.intersect_point(self.pointer):
                    if not self.code_editor.hover and not self.field:
                        self.push_handlers(self.code_editor)
                    self.code_editor.pan_scale = self.pan_scale
                    self.code_editor.screen_size = self.get_size()
                    self.code_editor.hover = True
                    self.code_editor.node.hover = True
                    return
            elif self.field:
                if self.field.intersect_point((x, y)):
                    self.field.pan_scale = self.pan_scale
                    self.field.screen_size = self.get_size()
github honix / Pyno / pyno / codeEditor.py View on Github external
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)
github honix / Pyno / pyno / window.py View on Github external
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
        x, y = x_y_pan_scale(x, y, self.pan_scale, self.get_size())
        dx, dy = int(dx / self.pan_scale[1]), int(dy / self.pan_scale[1])

        if self.node_drag and buttons != 5:
            for node in self.selected_nodes:
                node.x += dx
                node.y += dy
                node.make_child_active()
        elif self.select:
            self.w = self.selectPoint
            self.c = (x, y)
        elif self.connection:
            self.pointer = (x, y)
            for node in self.nodes:
                node.intersect_point((x, y))

            p = self.pointer
github honix / Pyno / pyno / window.py View on Github external
def on_mouse_press(self, x, y, button, modifiers):
        if self.menu.click(x, y, button):
            return

        x, y = x_y_pan_scale(x, y, self.pan_scale, self.get_size())

        if button == 1:
            if self.field:
                self.pop_handlers()
                self.push_handlers()
                self.field = None
            if self.code_editor:
                if self.code_editor.intersect_point((x, y)):
                    return
                else:
                    if self.code_editor.hover:
                        self.pop_handlers()
                        self.push_handlers()
                    self.code_editor = None
            for node in self.nodes:
                if node.intersect_point((x, y)):
github honix / Pyno / pyno / field.py View on Github external
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()
github honix / Pyno / pyno / field.py View on Github external
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
github honix / Pyno / pyno / codeEditor.py View on Github external
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()
github honix / Pyno / pyno / window.py View on Github external
def on_mouse_release(self, x, y, button, modifiers):
        x, y = x_y_pan_scale(x, y, self.pan_scale, self.get_size())

        if button == 1:
            self.node_drag = False
            self.connection = False

            self.line[0].redraw((-9000, 9000), (-9000, 9010))
            self.line[1].redraw((-9000, 9010), (-9010, 9000))

            if self.select:
                select = []
                for node in self.nodes:
                    if point_intersect_quad((node.x, node.y),
                                            (self.c + self.w)):
                        select.append(node)
                        node.draw_color = color_inverse(node.color)
                self.selected_nodes = select