def leaveEvent(self, _): shapes = self.interactive_shapes if self.aiming is True: set_closer_shapes_hovered(shapes, get_cursor(self)) else: set_shapes_hovered(shapes, get_cursor(self), self.clicked) self.repaint()
def set_hovered_shapes(self): shapes = self.interactive_shapes if self.aiming is True: set_crossed_shapes_hovered(self.center, get_cursor(self), shapes, get_cursor(self)) else: set_shapes_hovered(shapes, get_cursor(self), self.clicked) self.repaint()
def leaveEvent(self, _): shapes = self.interactive_shapes if self.aiming is True: set_crossed_shapes_hovered(self.center, get_cursor(self), shapes, get_cursor(self)) else: set_shapes_hovered(shapes, get_cursor(self), self.clicked) if self.close_on_leave is True: self.hide() self.repaint()
def exec_(self): point = get_cursor(self) point.setX(point.x() - 50) point.setY(point.y() - 75) self.move(point) result = super(ColorDialog, self).exec_() return result
def mousePressEvent(self, _): self.setFocus(QtCore.Qt.MouseFocusReason) cursor = get_cursor(self) direction = self.manipulator.get_direction(cursor) self.clicked = True self.transform.direction = direction self.manipulator_moved = False rect = self.manipulator.rect if rect is not None: self.transform.set_rect(rect) self.transform.reference_rect = QtCore.QRectF(rect) self.clicked_shape = None for shape in reversed(self.shapes): if shape.rect.contains(cursor): self.clicked_shape = shape break if rect and rect.contains(cursor): self.transform.set_reference_point(cursor) handeling = bool(direction or rect.contains(cursor) if rect else False) self.handeling = handeling if not self.handeling: self.selection_square.clicked(cursor) self.repaint()
def paint(self, painter): painter.setRenderHint(QtGui.QPainter.Antialiasing) draw_editor(painter, self.rect(), snap=self.transform.snap) for shape in self.shapes: shape.draw(painter) self.manipulator.draw(painter, get_cursor(self)) self.selection_square.draw(painter) if self.edit_center_mode is True: point = self.options['centerx'], self.options['centery'] draw_editor_center(painter, self.rect(), point)
def paintEvent(self, _): painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) # this is a workaround because a fully transparent widget doesn't # execute the mouseMove event when the cursor is hover a # transparent of the widget. This draw the reader rect has black # rect with a 1/255 transparency value draw_aiming_background(painter, self.rect()) for shape in self.shapes: shape.draw(painter) if self.aiming: draw_aiming(painter, self.center, get_cursor(self)) painter.end()
def mouseMoveEvent(self, _): cursor = get_cursor(self) if self.edit_center_mode is True: if self.clicked is False: return if self.transform.snap: x, y = snap(cursor.x(), cursor.y(), self.transform.snap) else: x, y = cursor.x(), cursor.y() self.centerMoved.emit(x, y) self.increase_undo_on_release = True self.repaint() return for shape in self.shapes: shape.set_hovered(cursor) if self.selection_square.handling: self.selection_square.handle(cursor) if self.handeling is False: return self.repaint() self.manipulator_moved = True rect = self.manipulator.rect if self.transform.direction: self.transform.resize([s.rect for s in self.selection], cursor) self.manipulator.update_geometries() elif rect is not None and rect.contains(cursor): self.transform.move([s.rect for s in self.selection], cursor) self.manipulator.update_geometries() for shape in self.shapes: shape.synchronize_rect() shape.synchronize_image() self.increase_undo_on_release = True self.selectedShapesChanged.emit() self.repaint()
def leaveEvent(self, _): shapes = self.interactive_shapes set_shapes_hovered(shapes, get_cursor(self), self.clicked) self.repaint()