-
-
Save RunasSudo/a948eac042bc230baecdb5864be53098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
import MuseScore 3.0 | |
MuseScore { | |
version: "1.0" | |
description: "MeasureNumNoCollide" | |
menuPath: "Plugins.MeasureNumNoCollide" | |
onRun: { | |
if (!curScore) { | |
Qt.quit(); | |
} | |
// Requires a measure number to be selected | |
// Measure number not exposed in Measure.elements, etc. :( | |
if (curScore.selection.elements.length === 0) { | |
Qt.quit(); | |
return; | |
} | |
if (curScore.selection.elements[0].name !== "MeasureNumber") { | |
Qt.quit(); | |
return; | |
} | |
var cursor = curScore.newCursor(); | |
// Select all measure numbers | |
cmd("select-similar"); | |
for (var i = 0; i < curScore.selection.elements.length; i++) { | |
var element = curScore.selection.elements[i]; | |
var measure = element.parent; | |
if (!element.visible) { | |
continue; | |
} | |
// First measure of the system? | |
var isFirstMeasure = measure.prevMeasureMM === null || measure.prevMeasureMM.pagePos.y !== measure.pagePos.y; | |
if (isFirstMeasure) { | |
continue; | |
} | |
if (element.placement === Placement.BELOW) { | |
element.offset.y = 1; | |
} else { | |
element.offset.y = -2; | |
} | |
if (measure.firstSegment.segmentType === Segment.ChordRest && measure.firstSegment.elementAt(0)) { | |
var chord = measure.firstSegment.elementAt(0); | |
if (chord.name === "Chord" && chord.notes.length > 0) { | |
var note = chord.notes[0]; | |
if (element.placement === Placement.BELOW) { | |
if (note.tieBack && note.line > 6 && note.line < 11) { | |
// Low tied note | |
element.offset.y = 1 + (note.line - 6) * 0.5; | |
} | |
} else { | |
if (note.tieBack && note.line < 0 && note.line > -5) { | |
// High tied note | |
element.offset.y = -2 + note.line * 0.5; | |
} | |
} | |
} | |
} | |
} | |
Qt.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment