diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui/editormain.py | 15 | ||||
-rw-r--r-- | src/editorui/paths.py | 32 |
2 files changed, 38 insertions, 9 deletions
diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py index 4b2e686..11df8dd 100644 --- a/src/editorui/editormain.py +++ b/src/editorui/editormain.py @@ -506,6 +506,11 @@ class KPEditorWidget(QtGui.QGraphicsView): x, y = clicked.x(), clicked.y() itemsUnder = self.scene().items(clicked) + if event.modifiers() & Qt.AltModifier: + dialog = True + else: + dialog = False + for item in itemsUnder: if isinstance(item, KPEditorNode): # Paint a path to this node (if one is selected) @@ -541,7 +546,7 @@ class KPEditorWidget(QtGui.QGraphicsView): path = KPPath(sourceNode, destNode) KP.map.pathLayer.paths.append(path) - KP.mainWindow.pathNodeList.addLayer(path) + KP.mainWindow.pathNodeList.addLayer(path, dialog) item = KPEditorPath(path) self.scene().addItem(item) @@ -556,7 +561,7 @@ class KPEditorWidget(QtGui.QGraphicsView): node = KPNode() node.position = (x - 12, y - 12) KP.map.pathLayer.nodes.append(node) - KP.mainWindow.pathNodeList.addLayer(node) + KP.mainWindow.pathNodeList.addLayer(node, dialog) # Start node => Original path => New node => New path => End node @@ -577,7 +582,7 @@ class KPEditorWidget(QtGui.QGraphicsView): newPath = KPPath(node, endNode, origPath) KP.map.pathLayer.paths.append(newPath) - KP.mainWindow.pathNodeList.addLayer(newPath) + KP.mainWindow.pathNodeList.addLayer(newPath, dialog) pathItem = KPEditorPath(newPath) self.scene().addItem(pathItem) @@ -588,7 +593,7 @@ class KPEditorWidget(QtGui.QGraphicsView): node = KPNode() node.position = (x - 12, y - 12) KP.map.pathLayer.nodes.append(node) - KP.mainWindow.pathNodeList.addLayer(node) + KP.mainWindow.pathNodeList.addLayer(node, dialog) item = KPEditorNode(node) self.scene().addItem(item) @@ -614,7 +619,7 @@ class KPEditorWidget(QtGui.QGraphicsView): path = KPPath(sourceNode, node) KP.map.pathLayer.paths.append(path) - KP.mainWindow.pathNodeList.addLayer(path) + KP.mainWindow.pathNodeList.addLayer(path, dialog) pathItem = KPEditorPath(path) self.scene().addItem(pathItem) diff --git a/src/editorui/paths.py b/src/editorui/paths.py index a40ab2b..4110188 100644 --- a/src/editorui/paths.py +++ b/src/editorui/paths.py @@ -111,7 +111,7 @@ class KPEditorNode(KPEditorItem): self._levelRect = self._boundingRect self._stopRect = QtCore.QRectF(-12, -12, 24, 24) self._tinyRect = QtCore.QRectF(-6, -6, 12, 12) - + self.isLayerSelected = False if not hasattr(KPEditorNode, 'SELECTION_PEN'): KPEditorNode.SELECTION_PEN = QtGui.QPen(Qt.blue, 1, Qt.DotLine) @@ -261,6 +261,11 @@ class KPEditorNode(KPEditorItem): exit.qtItem.updatePosition() + def setLayerSelected(self, selected): + self.isLayerSelected = selected + self.update() + + def paint(self, painter, option, widget): painter.setRenderHint(QtGui.QPainter.Antialiasing) @@ -294,14 +299,20 @@ class KPEditorNode(KPEditorItem): selectionRect = self._boundingRect.adjusted(1,5,-1,-5) elif len(node.exits) != 2: - brush = QtGui.QBrush(QtGui.QColor(255, 220, 220)) + if self.isLayerSelected: + brush = QtGui.QBrush(QtGui.QColor(255, 40, 40)) + else: + brush = QtGui.QBrush(QtGui.QColor(255, 220, 220)) painter.setPen(QtGui.QColor(255, 255, 255)) painter.setBrush(brush) painter.drawEllipse(self._stopRect) selectionRect = self._stopRect.adjusted(-1,-1,1,1) else: - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + if self.isLayerSelected: + brush = QtGui.QBrush(QtGui.QColor(255, 40, 40)) + else: + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) painter.setPen(QtGui.QColor(255, 255, 255)) painter.setBrush(brush) painter.drawEllipse(self._tinyRect) @@ -640,6 +651,7 @@ class KPEditorPath(QtGui.QGraphicsLineItem): self._startNodeRef = weakref.ref(startNode) self._endNodeRef = weakref.ref(endNode) self._pathRef = weakref.ref(path) + self.isLayerSelected = False path.qtItem = self @@ -685,11 +697,23 @@ class KPEditorPath(QtGui.QGraphicsLineItem): self.setLine(QtCore.QLineF(-dx, -dy, dx, dy)) + def setLayerSelected(self, selected): + self.isLayerSelected = selected + self.update() + + def paint(self, painter, option, widget): painter.setRenderHint(QtGui.QPainter.Antialiasing) - painter.setPen(KPEditorPath.PEN) + if self.isLayerSelected: + brush = QtGui.QBrush(QtGui.QColor(255, 40, 40, 200)) + pen = QtGui.QPen(brush, 12, Qt.SolidLine, Qt.RoundCap) + painter.setPen(pen) + painter.setBrush(brush) + else: + painter.setPen(KPEditorPath.PEN) + painter.drawLine(self.line()) if self.isSelected(): |