diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui/doodads.py | 9 | ||||
-rw-r--r-- | src/editorui/editormain.py | 50 | ||||
-rw-r--r-- | src/editorui/objects.py | 9 |
3 files changed, 43 insertions, 25 deletions
diff --git a/src/editorui/doodads.py b/src/editorui/doodads.py index 6bb4576..89ccfc7 100644 --- a/src/editorui/doodads.py +++ b/src/editorui/doodads.py @@ -426,9 +426,9 @@ class KPEditorDoodad(KPEditorItem): def hoverMoveEvent(self, event): - if self._layerRef() != KP.mapScene.currentLayer: - self.setCursor(Qt.ArrowCursor) - return + # if self._layerRef() != KP.mapScene.currentLayer: + # self.setCursor(Qt.ArrowCursor) + # return pos = event.pos() bit = self.resizerPortionAt(pos.x(), pos.y()) @@ -460,7 +460,8 @@ class KPEditorDoodad(KPEditorItem): pos = event.pos() bit = self.resizerPortionAt(pos.x(), pos.y()) - if self._layerRef() == KP.mapScene.currentLayer and bit: + # if self._layerRef() == KP.mapScene.currentLayer and bit: + if bit: event.accept() if (event.modifiers() & Qt.ShiftModifier): diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py index 5dc8703..1a30fcf 100644 --- a/src/editorui/editormain.py +++ b/src/editorui/editormain.py @@ -379,6 +379,8 @@ class KPEditorWidget(QtGui.QGraphicsView): QtGui.QGraphicsView.__init__(self, scene, parent) self.setRenderHints(QtGui.QPainter.Antialiasing) + self.setViewportUpdateMode(self.FullViewportUpdate) + self.grid = False self.setAlignment(Qt.AlignLeft | Qt.AlignTop) self.setDragMode(self.RubberBandDrag) @@ -393,29 +395,29 @@ class KPEditorWidget(QtGui.QGraphicsView): def drawForeground(self, painter, rect): - painter.setPen(Qt.red) - painter.setBrush(Qt.transparent) + QtGui.QGraphicsView.drawForeground(self, painter, rect) - c = rect.center() - x = c.x() - y = c.y() + if self.grid: + painter.setPen(Qt.red) + painter.setBrush(Qt.transparent) - zooms = [5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 150.0, 200.0, 400.0] - m = zooms[KP.mainWindow.ZoomLevel] / 100.0 + c = rect.center() + x = c.x() + y = c.y() - mx = 880.0 / 2.0 * m - my = 660.0 / 2.0 * m + mx = 880.0 + my = 660.0 - m2x = 1180.0 / 2.0 * m - m2y = 660.0 / 2.0 * m + m2x = 1180.0 + m2y = 660.0 - # mx = 1792.0 / 2.0 * m - # my = 1344.0 / 2.0 * m - newRect = QtCore.QRectF(x-mx, y-my, mx*2.0, my*2.0) - painter.drawRect(newRect) + # mx = 1792.0 + # my = 1344.0 + newRect = QtCore.QRectF(x-(mx/2.0), y-(my/2.0), mx, my) + painter.drawRect(newRect) - newRect2 = QtCore.QRectF(x-m2x, y-m2y, m2x*2.0, m2y*2.0) - painter.drawRect(newRect2) + newRect2 = QtCore.QRectF(x-(m2x/2.0), y-(m2y/2.0), m2x, m2y) + painter.drawRect(newRect2) def assignNewScene(self, scene): self.setScene(scene) @@ -727,10 +729,20 @@ class KPEditorWidget(QtGui.QGraphicsView): def mousePressEvent(self, event): + itemsUnder = self.scene().items(self.mapToScene(event.pos()), Qt.IntersectsItemShape, Qt.AscendingOrder) + if event.button() == Qt.RightButton: self._tryToPaint(event) event.accept() + elif itemsUnder: + QtGui.QGraphicsView.mousePressEvent(self, event) + + if len(self.scene().selectedItems()) < 2: + self.scene().clearSelection() + itemsUnder[0].setSelected(True) + itemsUnder[0].grabMouse() + else: QtGui.QGraphicsView.mousePressEvent(self, event) @@ -746,6 +758,10 @@ class KPEditorWidget(QtGui.QGraphicsView): def mouseReleaseEvent(self, event): QtGui.QGraphicsView.mouseReleaseEvent(self, event) + try: + self.scene().mouseGrabberItem().ungrabMouse() + except: + pass self.userClick.emit() diff --git a/src/editorui/objects.py b/src/editorui/objects.py index 975b365..71566a6 100644 --- a/src/editorui/objects.py +++ b/src/editorui/objects.py @@ -51,9 +51,9 @@ class KPEditorObject(KPEditorItem): def hoverMoveEvent(self, event): - if self._layerRef() != KP.mapScene.currentLayer: - self.setCursor(Qt.ArrowCursor) - return + # if self._layerRef() != KP.mapScene.currentLayer: + # self.setCursor(Qt.ArrowCursor) + # return pos = event.pos() bit = self.resizerPortionAt(pos.x(), pos.y()) @@ -75,7 +75,8 @@ class KPEditorObject(KPEditorItem): pos = event.pos() bit = self.resizerPortionAt(pos.x(), pos.y()) - if self._layerRef() == KP.mapScene.currentLayer and bit: + # if self._layerRef() == KP.mapScene.currentLayer and bit: + if bit: event.accept() x, xSide, y, ySide = False, None, False, None |