Skip to content

Commit

Permalink
Minor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent committed Oct 10, 2021
1 parent a007fa0 commit 86490b3
Showing 1 changed file with 8 additions and 58 deletions.
66 changes: 8 additions & 58 deletions durationeditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import "zparkingb/selectionhelper.js" as SelHelper
MuseScore {
menuPath: "Plugins." + pluginName
description: "---"
version: "1.0.0"
version: "1.0.1"
readonly property var pluginName: "Duration Editor"
readonly property var selHelperVersion: "1.2.0"

pluginType: "dock"
dockArea: "right"
requiresScore: false
width: 600
height: 200
height: 100

Grid {
id: layButtons
Expand Down Expand Up @@ -51,9 +51,6 @@ MuseScore {
return;
}

if (Qt.fontFamilies().indexOf('Leland') < 0) {
console.log("Leland not found");
}

}

Expand Down Expand Up @@ -317,56 +314,7 @@ MuseScore {
return el;
}

/*function appendRest(cursor) {
var last = null;
var measure = cursor.measure;
var seg = measure.firstSegment;
debugMeasureLength(measure);
var i = 0;
do {
var element;
element = seg.elementAt(cursor.track);
console.log((i++) + ")" + element.userName());
if (element && ((element.type == Element.REST) || (element.type == Element.CHORD))) {
if (element.type === Element.CHORD)
last = element.notes[0];
else if (element.type === Element.REST)
last = element;
}
seg = seg.nextInMeasure;
} while (seg != null)
if (last == null) {
console.log(" Could not find a last note / rest in that measure ");
return;
}
cursor.score.selection.select(last);
insertRestAtSelection();
debugMeasureLength(measure);
}
function insertRest(cursor) {
cursor.setDuration(1, 2)
selectCursor(cursor);
insertRestAtSelection();
}
function insertRestAtSelection() {
cmd(" insert - a ");
var el = cursor.element;
removeElement(el); // to rest
}*/


function selectCursor(cursor) {
var el = cursor.element;
//console.log(el.duration.numerator + "--"+el.duration.denominator);
Expand Down Expand Up @@ -417,10 +365,10 @@ MuseScore {
}

// Select the range. !! Must be surrounded by startCmd/endCmd, otherwise a cmd(" cut ") crashes MS
console.log("-->Yes");
cursor.score.startCmd();
var tick=last.tick;
if (tick==cursor.score.lastSegment.tick) tick++; // Bug in MS with the end of score ticks
console.log("--> Yes. Selecting from " + first.tick + " to " + tick);
cursor.score.startCmd();
cursor.score.selection.selectRange(first.tick, tick, cursor.staffIdx, cursor.staffIdx);
cursor.score.endCmd();

Expand All @@ -438,8 +386,10 @@ MuseScore {
var element = null;
//while ((last!=null) && (((element = last.elementAt(track)) == null) || (element.type == Element.REST))) {
while ((last != null) && (((element = _d(last, track)) == null) || (element.type != Element.CHORD))) {
if (element != null)
if ((element != null) && (element.type == Element.REST)) {
the_real_last = last;
break;
}
last = last.prevInMeasure;
}
element = the_real_last.elementAt(track);
Expand Down

0 comments on commit 86490b3

Please sign in to comment.