From 69117bdcdc980dfab55d95e994a4ccbe86b4ad24 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sun, 19 Dec 2021 20:58:13 +0100 Subject: [PATCH] indent tracks that are in groups --- qtgui/songeditor.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/qtgui/songeditor.py b/qtgui/songeditor.py index a41d33e..77bb9fd 100644 --- a/qtgui/songeditor.py +++ b/qtgui/songeditor.py @@ -1085,9 +1085,15 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene): menu.exec_(pos) class TrackLabel(QtWidgets.QGraphicsRectItem): + """One track label with color, name line edit etc. + Only gets the data when update() is called. + """ + def __init__(self, parentScene, width, height): super().__init__(0, 0, width, height) self.parentScene = parentScene + self.exportDict = None #set in self.update + self.statusMessage = self.parentScene.parentView.parentMainWindow.statusBar().showMessage #a version with the correct path of this is in every class of Patroneo self.setPen(QtGui.QPen(QtCore.Qt.NoPen)) @@ -1097,23 +1103,35 @@ class TrackLabel(QtWidgets.QGraphicsRectItem): self.positioningHandle = TrackLabel.PositioningHandle(parentTrackLabel=self) self.positioningHandle.setParentItem(self) - self.positioningHandle.setPos(0,0) + self.lengthMultiplicatorSpinBox = TrackLabel.lengthMultiplicatorSpinBox(parentTrackLabel=self) self.lengthMultiplicatorSpinBox.setParentItem(self) - self.lengthMultiplicatorSpinBox.setPos(SIZE_UNIT,2) + self.colorButton = TrackLabel.ColorPicker(parentTrackLabel=self) self.colorButton.setParentItem(self) - self.colorButton.setPos(3*SIZE_UNIT, 3) - self.lineEdit = TrackLabel.NameLineEdit(parentTrackLabel=self) self.label = QtWidgets.QGraphicsProxyWidget() self.label.setWidget(self.lineEdit) self.label.setParentItem(self) - self.label.setPos(4*SIZE_UNIT+3,0) + + self.positionButtons() + + def positionButtons(self, inGroup:bool=False): + """Used for init, but also for update to show if we are in a track-group or not by + indentation.""" + if inGroup: + offsetInSizeUnit = SIZE_UNIT + else: + offsetInSizeUnit = 0 + + self.positioningHandle.setPos(0,0) + self.lengthMultiplicatorSpinBox.setPos(SIZE_UNIT,2) + self.colorButton.setPos(3*SIZE_UNIT+offsetInSizeUnit, 3) + self.label.setPos(4*SIZE_UNIT+3+offsetInSizeUnit,0) class lengthMultiplicatorSpinBox(QtWidgets.QGraphicsProxyWidget): def __init__(self, parentTrackLabel): @@ -1275,6 +1293,7 @@ class TrackLabel(QtWidgets.QGraphicsRectItem): def update(self, exportDict): self.exportDict = exportDict + self.positionButtons(inGroup=bool(exportDict["group"])) self.lineEdit.setText(exportDict["sequencerInterface"]["name"]) self.colorButton.setBrush(QtGui.QColor(exportDict["color"])) self.lengthMultiplicatorSpinBox.spinBox.blockSignals(True)