Browse Source

less centering on the cursor when moving blocks around

master
Nils 2 years ago
parent
commit
1ea98e24da
  1. 17
      engine/api.py
  2. 9
      qtgui/scorescene.py

17
engine/api.py

@ -118,7 +118,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
if session.data.currentMetronomeTrack is track:
setMetronome(track.asMetronomeData, label=track.name) #template api
def _updateTrack(self, trId):
def _updateTrack(self, trId):
"""The most important function. Create a static representation of the music data which
can be used by a GUI to draw notes.
track.staticRepresentation also creates the internal midi representation for cbox. """
@ -843,7 +843,7 @@ def appendBlock(trackid = None):
else:
session.history.register(lambda blId = id(block): deleteBlock(blId), descriptionString = "append block")
callbacks._updateTrack(id(tr))
callbacks._setCursor()
#callbacks._setCursor() #this will make the GUI jump around because it centers on the cursor
def splitBlock():
tr = session.data.currentTrack()
@ -880,7 +880,7 @@ def joinBlock():
rearrangeBlocksInMultipleTracks(dictOfTrackIdsWithListOfBlockIds) #handles undo and callbacks for redrawing
session.data.goTo(*where) #just for the user experience.
callbacks._setCursor()
#callbacks._setCursor() #this will make the GUI jump around because it centers on the cursor
def deleteBlock(blockId):
track, block = session.data.blockById(blockId)
@ -891,7 +891,7 @@ def deleteBlock(blockId):
#Blocks are never truly deleted but a stored in the Block.allBlocks dict. This keeps the reference to this deleted block alive and it can be added through rearrange, which gets its blocks from this dict.
session.history.register(lambda i=id(track), l=oldBlockArrangement: rearrangeBlocks(i, l), descriptionString = "delete block")
callbacks._updateTrack(id(track))
callbacks._setCursor()
#callbacks._setCursor() #this will make the GUI jump around because it centers on the cursor
return True
else:
return False
@ -922,7 +922,7 @@ def duplicateBlock(blockId, times = 1):
for i in range(times):
track.duplicateBlock(block)
callbacks._updateTrack(id(track))
callbacks._setCursor()
#callbacks._setCursor()
def duplicateContentLinkBlock(blockId, times = 1):
track, block = session.data.blockById(blockId)
@ -930,7 +930,7 @@ def duplicateContentLinkBlock(blockId, times = 1):
for i in range(times):
track.duplicateContentLinkBlock(block)
callbacks._updateTrack(id(track))
callbacks._setCursor()
#callbacks._setCursor() #this will make the GUI jump around because it centers on the cursor
def moveBlockToOtherTrack(blockId, newTrackId, listOfBlockIdsForNewTrack):
"""First move the block to the new track and then
@ -957,7 +957,7 @@ def moveBlockToOtherTrack(blockId, newTrackId, listOfBlockIdsForNewTrack):
callbacks._updateTrack(id(oldTrack))
callbacks._updateTrack(newTrackId)
callbacks._setCursor()
#callbacks._setCursor() #this will make the GUI jump around because it centers on the cursor
def rearrangeBlocks(trackid, listOfBlockIds):
track = session.data.trackById(trackid)
@ -973,6 +973,7 @@ def rearrangeBlocks(trackid, listOfBlockIds):
def rearrangeBlocksInMultipleTracks(dictOfTrackIdsWithListOfBlockIds):
"""dictOfTrackIdsWithListOfBlockIds is [trackId] = [listOfBlockIds]"""
print ("multitrack")
forUndo = {}
for trackId, listOfBlockIds in dictOfTrackIdsWithListOfBlockIds.items():
track = session.data.trackById(trackId)
@ -988,7 +989,7 @@ def rearrangeBlocksInMultipleTracks(dictOfTrackIdsWithListOfBlockIds):
for trackId in dictOfTrackIdsWithListOfBlockIds.keys():
callbacks._updateTrack(trackId)
callbacks._setCursor()
#callbacks._setCursor() no. this makes the GUI jump around.
def changeBlock(blockId, newParametersDict):
"""for example "name" or "minimumInTicks" """

9
qtgui/scorescene.py

@ -454,14 +454,12 @@ class GuiScore(QtWidgets.QGraphicsScene):
Don't forget that an item needs to have the flag movable or selectable or else
it will not get mouseRelease or mouseMove events. MousePress always works.
Only active when mouse was pressed!
This happens EVERY mouse move. Just idle mouse movement over the window.
"""
self._mmE_ensureCursorVisible(event) #Works with all buttons. Good.
if self.duringTrackDragAndDrop:
#X is locked for tracks.
#self._mmE_ensureCursorVisible(event)
self._mmE_ensureCursorVisible(event)
x = self.duringTrackDragAndDrop.staticExportItem["guiPosStart"].x()
y = event.scenePos().y()
self.duringTrackDragAndDrop.setPos(x, y)
@ -470,12 +468,13 @@ class GuiScore(QtWidgets.QGraphicsScene):
#GuiBlockHandles are children of a Track. Their Y position will be offset by the track when we move them around with the mouse.
#Which is the same the distance to the first track is on top. We need to substract that for a good look and feel.
#The actual later dropping of the block is handled with the mouse cursor coordinates, the moving colored block is just eyecandy.
self._mmE_ensureCursorVisible(event)
x = event.scenePos().x()
y = event.scenePos().y() - self.duringBlockDragAndDrop.parentGuiTrack.y()
self.duringBlockDragAndDrop.setPos(x, y)
else:
super().mouseMoveEvent(event)
# #this happens EVERY mouse move. Just idle mouse movement over the window.

Loading…
Cancel
Save