From 26b84ce19acc8b265877b84a67295486573f8d73 Mon Sep 17 00:00:00 2001 From: Nils Date: Sat, 14 May 2022 21:40:52 +0200 Subject: [PATCH] auto shrink x factor in block mode --- qtgui/scorescene.py | 10 ++++++++-- qtgui/scoreview.py | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/qtgui/scorescene.py b/qtgui/scorescene.py index f54b9b8..dfaa806 100644 --- a/qtgui/scorescene.py +++ b/qtgui/scorescene.py @@ -111,8 +111,8 @@ class GuiScore(QtWidgets.QGraphicsScene): def updateModeSingleTrackRedraw(self, nameAsString:str, trackId:int, trackExport:tuple): """trackExport is a tuple of block export dicts""" self.tracks[trackId].updateMode(nameAsString) - #if nameAsString == "block": - # self.tracks[trackId].stretchXCoordinates(0.25) #go into small scaling mode. 0.25 is hardcoded and the same as scoreView.updateMode + if nameAsString == "block": + self.tracks[trackId].stretchXCoordinates(0.25) #go into small scaling mode. 0.25 is hardcoded and the same as scoreView.updateMode def maxTrackLength(self): if self.tracks: @@ -403,6 +403,12 @@ class GuiScore(QtWidgets.QGraphicsScene): block.mousePressEventCustom(event) event.accept() #eat it return + else: #CC mode but no modifiers + #implicit qt scene click detection was unreliable. In the end the manual route was the best option: + block = self.blockAt(event.scenePos()) + if block and type(block) is CCGraphTransparentBlock: + block.parentCCPath.mousePressEventToAdd(event) + return super().mousePressEvent(event) diff --git a/qtgui/scoreview.py b/qtgui/scoreview.py index 0a663bb..f7988dc 100644 --- a/qtgui/scoreview.py +++ b/qtgui/scoreview.py @@ -200,8 +200,8 @@ class ScoreView(QtWidgets.QGraphicsView): if self.mainWindow.ui.actionCC_Mode.isChecked(): - #if calledByMenu and self._lastSavedMode == "block": - # self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling + if calledByMenu and self._lastSavedMode == "block": + self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling self.mainWindow.menuActionDatabase.ccEditMode() self.mainWindow.menuActionDatabase.writeProtection(True) @@ -209,8 +209,8 @@ class ScoreView(QtWidgets.QGraphicsView): self.mainWindow.menuActionDatabase.loadToolbarContext("cc") elif self.mainWindow.ui.actionNotation_Mode.isChecked(): - #if calledByMenu and self._lastSavedMode == "block": - # self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling + if calledByMenu and self._lastSavedMode == "block": + self.stretchXCoordinates(4.0) #return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling self.mainWindow.menuActionDatabase.noteEditMode() self.mainWindow.menuActionDatabase.writeProtection(False) @@ -219,8 +219,8 @@ class ScoreView(QtWidgets.QGraphicsView): elif self.mainWindow.ui.actionBlock_Mode.isChecked(): assert calledByMenu, "We currently assume that only the program start calls this function not via the menu, and that chooses notation mode" - #if not self._lastSavedMode == "block": #check that we don't go from block mode to block mode again, since XScaling is cumulative - # self.stretchXCoordinates(0.25) #go into small scaling mode. 0.25 is hardcoded and the same as scene.updateModeSingleTrackRedraw + if not self._lastSavedMode == "block": #check that we don't go from block mode to block mode again, since XScaling is cumulative + self.stretchXCoordinates(0.25) #go into small scaling mode. 0.25 is hardcoded and the same as scene.updateModeSingleTrackRedraw self.mainWindow.menuActionDatabase.noteEditMode() self.mainWindow.menuActionDatabase.writeProtection(True) self.scoreScene.updateMode("block")