Browse Source

Add context menu to move CC Blocks to start or end of a track

master
Nils 2 years ago
parent
commit
2a51e47a09
  1. 4
      CHANGELOG
  2. 53
      engine/api.py
  3. 21
      qtgui/graphs.py
  4. 1
      qtgui/musicstructures.py

4
CHANGELOG

@ -6,14 +6,16 @@ External contributors notice at the end of the line: (LastName, FirstName / nick
## 2022-10-15 2.2.0
Add SOLO functionality alongside the existing audible/mute layer. Control via shortcuts, track editor, or track list widget
Add SOLO functionality alongside the existing audible/mute layer. Control via shortcuts, track editor, or track-list widget
New function to create a new empty block from an existing one, that has reserved duration same as the original one.
Add more time signatures to the quick-insert dialog: 8/4, three variants of 7/8, two variants of 5/4 and more. Also reorder and better labels.
Add context menu to move CC Blocks to start or end of a track
Fix splitting of notes that were created by a previous split.
Block Mode: Fix invisible block labels and graphics when dragging blocks (adopting to unannounced Qt regressions once again)
Barlines more visible
Undo for initial metrical instruction and key sig (track editor)
Prevent block operations to jump to the cursor position in the GUI. Less jumpy.
Show first block name in track-list widget
Various small fixes, like typos in variable names and wrong string quotes. Small things can crash as well.
Lilypond:
Add transposition of the whole score to properties and metadata dialog

53
engine/api.py

@ -2409,6 +2409,59 @@ def mergeWithNextGraphBlock(graphBlockId):
callbacks._historyChanged()
callbacks._updateGraphTrackCC(trId, cc)
def moveCCBlockToStartOfTrack(graphBlockId):
trId, cc, graphBlock = session.data.graphBlockById(graphBlockId)
ccTrack = session.data.trackById(trId).ccGraphTracks[cc]
listOfBlockIds = ccTrack.asListOfBlockIds()
listOfBlockIds.pop(listOfBlockIds.index(graphBlockId)) #will succeed or raise ValueError.
listOfBlockIds.insert(0, graphBlockId)
rearrangeCCBlocks(trId, cc, listOfBlockIds) #does undo and callbacks
def moveCCBlockToEndOfTrack(graphBlockId):
trId, cc, graphBlock = session.data.graphBlockById(graphBlockId)
ccTrack = session.data.trackById(trId).ccGraphTracks[cc]
listOfBlockIds = ccTrack.asListOfBlockIds()
listOfBlockIds.pop(listOfBlockIds.index(graphBlockId)) #will succeed or raise ValueError.
listOfBlockIds.append(graphBlockId)
rearrangeCCBlocks(trId, cc, listOfBlockIds) #does undo and callbacks
def moveBlockToEndOfTrack(blockId):
"""Get a list of all blocks. Take the given one and place it at the end.
This is a high level function using rearrangeBlocks(), which does all the callbacks and
history"""
track, block = session.data.blockById(blockId)
currentBlockOrder = track.asListOfBlockIds()
if len(currentBlockOrder) == 1:
return
assert currentBlockOrder.count(blockId) == 1
currentBlockOrder.remove(blockId) #modifies list in place
currentBlockOrder.append(blockId)
rearrangeBlocks(id(track), currentBlockOrder)
def moveBlockToStartOfTrack(blockId):
"""Like moveBlockToEndOfTrack, but to the start"""
track, block = session.data.blockById(blockId)
currentBlockOrder = track.asListOfBlockIds()
if len(currentBlockOrder) == 1:
return
assert currentBlockOrder.count(blockId) == 1
currentBlockOrder.remove(blockId) #modifies list in place
currentBlockOrder.insert(0, blockId)
rearrangeBlocks(id(track), currentBlockOrder)
##CC Blocks and User Points
def addGraphItem(blockId, positionInTicksRelativeToBlock, newCCValue):

21
qtgui/graphs.py

@ -21,6 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging; logger = logging.getLogger(__name__); logger.info("import")
from PyQt5 import QtCore, QtGui, QtSvg, QtWidgets
translate = QtCore.QCoreApplication.translate
from .constantsAndConfigs import constantsAndConfigs
from template.qtgui.helper import stringToColor, removeInstancesFromScene, callContextMenu, stretchLine, stretchRect
import engine.api as api
@ -331,15 +334,19 @@ class CCGraphTransparentBlock(QtWidgets.QGraphicsRectItem):
def contextMenuEvent(self, event):
listOfLabelsAndFunctions = [
("split here", lambda: self.splitHere(event)),
("duplicate", lambda: api.duplicateCCBlock(self.staticExportItem["id"])),
("create content link", lambda: api.duplicateContentLinkCCBlock(self.staticExportItem["id"])),
("unlink", lambda: api.unlinkCCBlock(self.staticExportItem["id"])),
(translate("ccblock", "split here"), lambda: self.splitHere(event)),
(translate("ccblock", "duplicate"), lambda: api.duplicateCCBlock(self.staticExportItem["id"])),
(translate("ccblock", "create content link"), lambda: api.duplicateContentLinkCCBlock(self.staticExportItem["id"])),
(translate("ccblock", "unlink"), lambda: api.unlinkCCBlock(self.staticExportItem["id"])),
("separator", None),
(translate("ccblock", "move to start"), lambda: api.moveCCBlockToStartOfTrack(self.staticExportItem["id"])),
(translate("ccblock", "move to end"), lambda: api.moveCCBlockToEndOfTrack(self.staticExportItem["id"])),
("separator", None),
("join with next block", lambda: api.mergeWithNextGraphBlock(self.staticExportItem["id"])),
("delete block", lambda: api.deleteCCBlock(self.staticExportItem["id"])),
(translate("ccblock", "join with next block"), lambda: api.mergeWithNextGraphBlock(self.staticExportItem["id"])),
(translate("ccblock", "delete block"), lambda: api.deleteCCBlock(self.staticExportItem["id"])),
("separator", None),
("append block at the end", lambda ccNum = self.parentCCPath.getCCNumber(): api.appendGraphBlock(self.parentCCPath.parentDataTrackId, ccNum)),
(translate("ccblock", "append block at the end"), lambda ccNum = self.parentCCPath.getCCNumber(): api.appendGraphBlock(self.parentCCPath.parentDataTrackId, ccNum)),
]
callContextMenu(listOfLabelsAndFunctions)

1
qtgui/musicstructures.py

@ -178,6 +178,7 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
(translate("musicstructures", "duplicate to reserved empty"), lambda: api.duplicateToReservedSpaceBlock(self.staticExportItem["id"])),
(translate("musicstructures", "create content link"), lambda: api.duplicateContentLinkBlock(self.staticExportItem["id"])),
(translate("musicstructures", "unlink"), lambda: api.unlinkBlock(self.staticExportItem["id"])),
("separator", None),
(translate("musicstructures", "move to start"), lambda: api.moveBlockToStartOfTrack(self.staticExportItem["id"])),
(translate("musicstructures", "move to end"), lambda: api.moveBlockToEndOfTrack(self.staticExportItem["id"])),
("separator", None),

Loading…
Cancel
Save