Skip to content

Commit

Permalink
Merge pull request #40 from uthidata/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadsden committed Apr 22, 2024
2 parents 29ab4b9 + 9f996f8 commit bc6ef97
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tin_whistle_tablature.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ MuseScore {
console.log("^^ -------- " + title + " ---------- ^^")
} // end dumpObjectEntries

function removeDuplicatesInSegment(segment, elementToKeep) {
var removables = [];

for (var i = 0; i < segment.annotations.length; i++) {
var element = segment.annotations[i];
if (element.is(elementToKeep)) {
continue;
}

if (element.offsetX == elementToKeep.offsetX && element.offsetY == elementToKeep.offsetY) {
removables.push(element);
}
}

for (var i = 0; i < removables.length; i++) {
var element = segment.annotations[i];
removeElement(element);
}
}

function renderTinWhistleTablature () {
curScore.startCmd();

Expand Down Expand Up @@ -288,6 +308,8 @@ MuseScore {
// (See the note below about behavior of the text.offsetY property.)
text.offsetY = tabOffsetY // place the tab below the staff

removeDuplicatesInSegment(cursor.segment, text);

// Create new text element for next tab placement
text = newElement(Element.STAFF_TEXT)
}
Expand Down Expand Up @@ -340,6 +362,8 @@ MuseScore {
else
text.offsetX = 0.5

removeDuplicatesInSegment(cursor.segment, text);

// Create new text element for next tab placement
text = newElement(Element.STAFF_TEXT)
} // end if repeated
Expand Down Expand Up @@ -376,6 +400,8 @@ MuseScore {
// (See the note below about behavior of the text.offsetY property.)
text.offsetY = tabOffsetY // place the tab below the staff

removeDuplicatesInSegment(cursor.segment, text);

// Create new text element for next tab placement
text = newElement(Element.STAFF_TEXT)
}
Expand Down

0 comments on commit bc6ef97

Please sign in to comment.