def wheelEvent(self, event: QtGui.QWheelEvent): """Implementation. Handles zooming the editor's view. """ if (event.modifiers() & Qt.ControlModifier and event.orientation() == Qt.Vertical): if event.delta() > 0: self.zoomIn() else: self.zoomOut() # TODO: Improve cursor anchoring; be more like Aseprite prevAnchor = self.transformationAnchor() self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setTransform(QTransform.fromScale(self.zoom(), self.zoom())) self.updateSceneRect(self.zoom()) self.setTransformationAnchor(prevAnchor) event.accept() elif event.orientation() == Qt.Horizontal: # XXX: Workaround for the insane horizontal scroll delta of 15240 on the # Logitech G502 mouse. if abs(event.delta()) == 15240: newDelta = 120 if event.delta() > 0 else -120 event = QtGui.QWheelEvent(event.pos(), event.globalPos(), newDelta, event.buttons(), event.modifiers(), orient=Qt.Horizontal) super().wheelEvent(event) else: super().wheelEvent(event)
def flipVertically(self): """Flips the tile vertically; that is, over its horizontal axis.""" flipped = QTransform.fromScale(self.scale(), self.scale() * -1) self.setTransform(flipped)