Browse Source

re-activate old, slow grid. basis for following optimisations

master
Nils 3 years ago
parent
commit
81fcf9d2a0
  1. 2
      qtgui/mainwindow.py
  2. 17
      qtgui/menu.py
  3. 14
      qtgui/scorescene.py
  4. 6
      qtgui/scoreview.py

2
qtgui/mainwindow.py

@ -122,7 +122,7 @@ class MainWindow(TemplateMainWindow):
#Now all tracks and items from a loaded backend-file are created. We can setup the initial editMode and viewPort.
self.scoreView.updateMode() #hide CCs at program start and other stuff
#self.scoreView.scoreScene.grid.redrawTickGrid() #Init the grid only after everything got loaded and drawn to prevent a gap in the display. #TODO: which might be a bug. but this here works fine.
self.scoreView.scoreScene.grid.redrawTickGrid() #Init the grid only after everything got loaded and drawn to prevent a gap in the display. #TODO: which might be a bug. but this here works fine.
#There is so much going on in the engine, we never reach a save status on load.
#Here is the crowbar-method.

17
qtgui/menu.py

@ -178,7 +178,7 @@ class MenuActionDatabase(object):
#...
}
self.mainWindow.ui.actionChange_Grid_Rhythm.setVisible(False)
self.actions = { #always available in the main window. It doesn't matter if you change to CC mode or Note Edit etc.
self.mainWindow.ui.actionToggle_Notehead_Rectangles : self.mainWindow.scoreView.toggleNoteheadsRectangles,
self.mainWindow.ui.actionData_Editor : self.mainWindow.toggleMainView,
@ -189,7 +189,7 @@ class MenuActionDatabase(object):
self.mainWindow.ui.actionBlock_Mode : self.mainWindow.scoreView.updateMode,
self.mainWindow.ui.actionCC_Mode : self.mainWindow.scoreView.updateMode,
#self.mainWindow.ui.actionChange_Grid_Rhythm : self.mainWindow.scoreView.changeGridRhythm,
self.mainWindow.ui.actionChange_Grid_Rhythm : self.mainWindow.scoreView.changeGridRhythm,
self.mainWindow.ui.actionAdd_Track : api.newEmptyTrack,
self.mainWindow.ui.actionDelete_Current_Track : api.deleteCurrentTrack,
self.mainWindow.ui.actionUse_Current_Track_as_Metronome : api.useCurrentTrackAsMetronome,
@ -343,7 +343,7 @@ class MenuActionDatabase(object):
self.mainWindow.ui.actionNotation_Mode,
self.mainWindow.ui.actionBlock_Mode,
self.mainWindow.ui.actionCC_Mode,
#self.mainWindow.ui.actionChange_Grid_Rhythm,
self.mainWindow.ui.actionChange_Grid_Rhythm,
self.mainWindow.ui.actionAdd_Track,
self.mainWindow.ui.actionUndo,
self.mainWindow.ui.actionRedo,
@ -363,19 +363,16 @@ class MenuActionDatabase(object):
#Prepare non-designer widgets. Designer can't put normal widgets in a toolbar, but Qt can.
#Eventhough this is a dict, which has no order, the CREATION has an order. So the first item in the dict will be the first item in the toolBar
self.extraToolBarWidgets = {
#"snapToGrid" : self.mainWindow.ui.toolBar.addWidget(ToolBarSnapToGrid(mainWindow=self.mainWindow)),
"snapToGrid" : self.mainWindow.ui.toolBar.addWidget(ToolBarSnapToGrid(mainWindow=self.mainWindow)),
"metronome" : self.mainWindow.ui.toolBar.addWidget(ToolBarMetronome(mainWindow=self.mainWindow)),
"playbackSpeed" : self.mainWindow.ui.toolBar.addWidget(ToolBarPlaybackSpeed(mainWindow=self.mainWindow)),
"ccType" : self.mainWindow.ui.toolBar.addWidget(ToolBarCCType(mainWindow=self.mainWindow)), #keep this at the end of the toolbar because it toggles visibility
}
self.toolbarContexts = {
#"notation" : [self.extraToolBarWidgets["snapToGrid"], self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["playbackSpeed"], ],
"notation" : [self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["playbackSpeed"], ],
#"cc" : [self.extraToolBarWidgets["snapToGrid"], self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["ccType"], self.extraToolBarWidgets["playbackSpeed"]],
"cc" : [self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["ccType"], self.extraToolBarWidgets["playbackSpeed"]],
#"block": [self.extraToolBarWidgets["snapToGrid"], self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["playbackSpeed"], ],
"block": [self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["playbackSpeed"], ],
"notation" : [self.extraToolBarWidgets["snapToGrid"], self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["playbackSpeed"], ],
"cc" : [self.extraToolBarWidgets["snapToGrid"], self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["ccType"], self.extraToolBarWidgets["playbackSpeed"]],
"block": [self.extraToolBarWidgets["snapToGrid"], self.extraToolBarWidgets["metronome"], self.extraToolBarWidgets["playbackSpeed"], ],
}
#Now connect all actions to functions

14
qtgui/scorescene.py

@ -32,7 +32,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
import engine.api as api
from .constantsAndConfigs import constantsAndConfigs
#from .grid import GuiGrid
from .grid import GuiGrid
from .conductor import Conductor, ConductorTransparentBlock
from .musicstructures import GuiBlockHandle, GuiTrack
from .graphs import CCGraphTransparentBlock, CCPath
@ -69,10 +69,10 @@ class GuiScore(QtWidgets.QGraphicsScene):
self.backColor.setNamedColor("#fdfdff")
self.setBackgroundBrush(self.backColor)
#self.grid = GuiGrid(parentScene=self)
#self.addItem(self.grid)
#self.grid.setPos(0, -20 * constantsAndConfigs.stafflineGap) #this is more calculation than simply using self.yStart, and might require manual adjustment in the future, but at least it guarantees the grid matches the staffline positions
#self.grid.setZValue(-50)
self.grid = GuiGrid(parentScene=self)
self.addItem(self.grid)
self.grid.setPos(0, -20 * constantsAndConfigs.stafflineGap) #this is more calculation than simply using self.yStart, and might require manual adjustment in the future, but at least it guarantees the grid matches the staffline positions
self.grid.setZValue(-50)
self.cachedSceneHeight = 0 #set in self.redraw. Used by updateTrack to set the sceneRect
@ -100,7 +100,7 @@ class GuiScore(QtWidgets.QGraphicsScene):
for track in self.tracks.values():
track.updateMode(nameAsString)
#self.grid.updateMode(nameAsString)
self.grid.updateMode(nameAsString)
def maxTrackLength(self):
if self.tracks:
@ -310,7 +310,7 @@ class GuiScore(QtWidgets.QGraphicsScene):
Docstring there."""
#The big structures have a fixed position at (0,0) and move its child items, like notes, internally
#Some items, like the cursor, move around, as a whole item, in the scene directly and need no stretchXCoordinates() themselves.
#self.grid.stretchXCoordinates(factor)
self.grid.stretchXCoordinates(factor)
self.conductor.stretchXCoordinates(factor)
self.cursor.setX(self.cursor.pos().x() * factor)
self.playhead.setX(self.playhead.pos().x() * factor)

6
qtgui/scoreview.py

@ -31,7 +31,7 @@ from template.helper import onlyOne
#Our Modules
from .constantsAndConfigs import constantsAndConfigs
from .scorescene import GuiScore
#from .submenus import GridRhytmEdit
from .submenus import GridRhytmEdit
import engine.api as api
class ScoreView(QtWidgets.QGraphicsView):
@ -148,8 +148,8 @@ class ScoreView(QtWidgets.QGraphicsView):
# self.scoreScene.grid.reactToresizeEventOrZoom()
# super().resizeEvent(event)
#def changeGridRhythm(self):
# GridRhytmEdit(mainWindow=self.mainWindow) #handles everything.
def changeGridRhythm(self):
GridRhytmEdit(mainWindow=self.mainWindow) #handles everything.
def updateMode(self, *args):
"""Switch through different views for editing:

Loading…
Cancel
Save