Skip to content

Commit

Permalink
Notenames plugins: For hidden notes skip notenames
Browse files Browse the repository at this point in the history
Backport of musescore#8142, part 1
  • Loading branch information
Jojo-Schmitz committed Jul 27, 2021
1 parent e92d6d4 commit 4af8f05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
12 changes: 7 additions & 5 deletions share/plugins/notenames-interactive.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Note Names Plugin
//
// Copyright (C) 2012 Werner Schweer
// Copyright (C) 2013 - 2019 Joachim Schmitz
// Copyright (C) 2013 - 2021 Joachim Schmitz
// Copyright (C) 2014 Jörn Eichler
// Copyright (C) 2020 MuseScore BVBA
//
Expand All @@ -20,7 +20,7 @@ import QtQuick.Controls 2.0
import MuseScore 3.0

MuseScore {
version: "3.4"
version: "3.5"
description: qsTr("This plugin names notes as per your language setting")
menuPath: "Plugins.Notes." + qsTr("Note Names (Interactive)")
pluginType: "dock"
Expand Down Expand Up @@ -59,10 +59,12 @@ MuseScore {
function getChordName(chord) {
var text = "";
var notes = chord.notes;
var sep = "\n"; // change to "," if you want them horizontally (anybody?)
for (var i = 0; i < notes.length; i++) {
var sep = "\n"; // change to "," if you want them horizontally (anybody?)
if ( i > 0 )
text = sep + text; // any but top note
if (!notes[i].visible)
continue // skip invisible notes
if (text) // only if text isn't empty
text = sep + text;
if (typeof notes[i].tpc === "undefined") // like for grace notes ?!?
return;
switch (notes[i].tpc) {
Expand Down
26 changes: 16 additions & 10 deletions share/plugins/notenames.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Note Names Plugin
//
// Copyright (C) 2012 Werner Schweer
// Copyright (C) 2013 - 2020 Joachim Schmitz
// Copyright (C) 2013 - 2021 Joachim Schmitz
// Copyright (C) 2014 Jörn Eichler
// Copyright (C) 2020 Johan Temmerman
//
Expand All @@ -19,20 +19,22 @@ import QtQuick 2.2
import MuseScore 3.0

MuseScore {
version: "3.4.2.1"
version: "3.5"
description: qsTr("This plugin names notes as per your language setting")
menuPath: "Plugins.Notes." + qsTr("Note Names")

// Small note name size is fraction of the full font size.
property var fontSizeMini: 0.7;

function nameChord (notes, text, small) {
var sep = "\n"; // change to "," if you want them horizontally (anybody?)
for (var i = 0; i < notes.length; i++) {
var sep = "\n"; // change to "," if you want them horizontally (anybody?)
if ( i > 0 )
text.text = sep + text.text; // any but top note
if (!notes[i].visible)
continue // skip invisible notes
if (text.text) // only if text isn't empty
text.text = sep + text.text;
if (small)
text.fontSize *= fontSizeMini
text.fontSize *= fontSizeMini
if (typeof notes[i].tpc === "undefined") // like for grace notes ?!?
return
switch (notes[i].tpc) {
Expand Down Expand Up @@ -130,15 +132,17 @@ MuseScore {
var chord = list[chordNum];
// Set note text, grace notes are shown a bit smaller
nameChord(chord.notes, text, small)
cursor.add(text)
if (text.text)
cursor.add(text)
// X position the note name over the grace chord
text.offsetX = chord.posX
switch (cursor.voice) {
case 1: case 3: text.placement = Placement.BELOW; break;
}

// If we consume a STAFF_TEXT we must manufacture a new one.
text = newElement(Element.STAFF_TEXT); // Make another STAFF_TEXT
if (text.text)
text = newElement(Element.STAFF_TEXT); // Make another STAFF_TEXT
}
}
return text
Expand Down Expand Up @@ -207,13 +211,15 @@ MuseScore {
// Now handle the note names on the main chord...
var notes = cursor.element.notes;
nameChord(notes, text, false);
cursor.add(text);
if (text.text)
cursor.add(text);

switch (cursor.voice) {
case 1: case 3: text.placement = Placement.BELOW; break;
}

text = newElement(Element.STAFF_TEXT) // Make another STAFF_TEXT object
if (text.text)
text = newElement(Element.STAFF_TEXT) // Make another STAFF_TEXT object

// Finally process trailing grace notes if they exist...
text = renderGraceNoteNames(cursor, trailingFifo, text, true)
Expand Down

0 comments on commit 4af8f05

Please sign in to comment.