diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-05-21 01:41:02 -0500 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-05-21 01:41:02 -0500 |
commit | ba959d67836d483007c384f1a87fcfba12332295 (patch) | |
tree | 67ebe1f6259c5f82c4e1fdc45a9249d9d0bede76 /src/editorui/editormain.py | |
parent | 197fca6d7d16fa849c6e8e214008108a26ac4c7c (diff) | |
download | koopatlas-ba959d67836d483007c384f1a87fcfba12332295.tar.gz koopatlas-ba959d67836d483007c384f1a87fcfba12332295.zip |
Added copying, proper top-dwn selection
Diffstat (limited to '')
-rw-r--r-- | src/editorui/editormain.py | 50 |
1 files changed, 33 insertions, 17 deletions
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() |