From fec8094ea6cb7f9d6cb1246e586323eff22a202e Mon Sep 17 00:00:00 2001 From: Tim Burgess Date: Mon, 6 Apr 2026 22:57:43 +0100 Subject: [PATCH 1/2] Braille: Use > (dots 3-4-5) for expression, rehearsal mark, staff and system text annotations. Fix #28362 and possibly others. --- src/braille/internal/braille.cpp | 69 +++++++++++++++++++++++++++++--- src/braille/internal/braille.h | 10 ++++- 2 files changed, 72 insertions(+), 7 deletions(-) diff --git a/src/braille/internal/braille.cpp b/src/braille/internal/braille.cpp index 1b1fd87fb7f49..ba199c80952d4 100644 --- a/src/braille/internal/braille.cpp +++ b/src/braille/internal/braille.cpp @@ -36,6 +36,7 @@ #include "engraving/dom/durationtype.h" #include "engraving/dom/dynamic.h" #include "engraving/dom/engravingitem.h" +#include "engraving/dom/expression.h" #include "engraving/dom/fermata.h" #include "engraving/dom/fingering.h" #include "engraving/dom/hairpin.h" @@ -50,13 +51,16 @@ #include "engraving/dom/page.h" #include "engraving/dom/part.h" #include "engraving/dom/pitchspelling.h" +#include "engraving/dom/rehearsalmark.h" #include "engraving/dom/rest.h" #include "engraving/dom/score.h" #include "engraving/dom/segment.h" #include "engraving/dom/slur.h" #include "engraving/dom/spanner.h" #include "engraving/dom/staff.h" +#include "engraving/dom/stafftext.h" #include "engraving/dom/system.h" +#include "engraving/dom/systemtext.h" #include "engraving/dom/tempotext.h" #include "engraving/dom/text.h" #include "engraving/dom/tie.h" @@ -822,7 +826,7 @@ bool Braille::write(QIODevice& device) // we write the measure number if (currentLineLength == 0) { TextToUEBBraille textToBraille; - QString measureNumber = textToBraille.braille(QString::number(m->no() + 1)).remove(0, 1) + " "; + QString measureNumber = textToBraille.braille(QString::number(m->measureNumber() + 1)).remove(0, 1) + " "; int measureNumberLen = measureNumber.size(); line[0] += measureNumber; for (size_t i = 1; i < nrStaves; i++) { @@ -836,7 +840,7 @@ bool Braille::write(QIODevice& device) } for (size_t i = 0; i < nrStaves; ++i) { - BRAILLE_TRACE() << "Measure " << mb->no() + 1 << " Staff " << i; + BRAILLE_TRACE() << "Measure " << m->measureNumber() + 1 << " Staff " << i; measureBraille[i] = brailleMeasure(m, static_cast(i)).toUtf8(); @@ -1252,7 +1256,7 @@ bool Braille::brailleSingleItem(BrailleEngravingItemList* beiz, EngravingItem* e beiz->addEngravingItem(el, brailleJump(toJump(el))); return true; } else if (el->isDynamic()) { - beiz->addEngravingItem(el, brailleDynamic(toDynamic(el))); + beiz->addEngravingItem(el, brailleDynamic(toDynamic(el))); return true; } else if (el->isClef()) { beiz->addEngravingItem(el, brailleClef(toClef(el))); @@ -1326,7 +1330,15 @@ void Braille::brailleMeasureItems(BrailleEngravingItemList* beiz, Measure* measu //Render everything that is in Voice 1 for (auto seg = measure->first(); seg; seg = seg->next()) { for (EngravingItem* annotation : seg->annotations()) { - if (annotation->isTempoText()) { + if (annotation->isExpression()) { + beiz->addEngravingItem(annotation, brailleExpressionText(toExpression(annotation), staffCount)); // Expression text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + } else if (annotation->isRehearsalMark()) { + beiz->addEngravingItem(annotation, brailleRehearsalMark(toRehearsalMark(annotation), staffCount)); // Rehearsal marks are not rendered in the staff they are attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. // Rehearsal marks are not rendered in the staff they are attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + } else if (annotation->isStaffText()) { + beiz->addEngravingItem(annotation, brailleStaffText(toStaffText(annotation), staffCount)); // Staff text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + } else if (annotation->isSystemText()) { + beiz->addEngravingItem(annotation, brailleSystemText(toSystemText(annotation), staffCount)); + } else if (annotation->isTempoText()) { beiz->addEngravingItem(annotation, brailleTempoText(toTempoText(annotation), staffCount)); } if (annotation->track() == staffCount * VOICES) { @@ -1359,7 +1371,7 @@ void Braille::brailleMeasureItems(BrailleEngravingItemList* beiz, Measure* measu beiz->addEngravingItem(el, brailleBarline(toBarLine(el))); } else if (el->isMeasureRepeat()) { beiz->addEngravingItem(el, brailleMeasureRepeat(toMeasureRepeat(el))); - } + } } // Render the rest of the voices @@ -2330,7 +2342,7 @@ QString Braille::brailleMeasure(Measure* measure, int staffCount) } if (annotation->track() == staffCount * VOICES) { if (annotation->isDynamic()) { - out << brailleDynamic(toDynamic(annotation)); + out << brailleDynamic(toDynamic(annotation)); } } } @@ -2668,6 +2680,51 @@ QString Braille::brailleRest(Rest* rest) return result; } +QString Braille::brailleExpressionText(Expression* expression, int staffIdx) +{ + if ((!expression) || (expression->plainText().isEmpty())) { + return QString(); + } + + // Expression text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + resetOctave(expression->staffIdx()); + return ">" + TextToUEBBraille().braille(expression->plainText()); +} + + +QString Braille::brailleRehearsalMark(RehearsalMark* rehearsalMark, int staffIdx) +{ + if ((!rehearsalMark) || (rehearsalMark->plainText().isEmpty())) { + return QString(); + } + + resetOctave(rehearsalMark->staffIdx()); + // Need a reference + return ">" + TextToUEBBraille().braille(rehearsalMark->plainText()); +} + + QString Braille::brailleStaffText(StaffText* staffText, int staffIdx) +{ + if (!staffText || staffText->plainText().isEmpty()) { + return QString(); +} + + // Staff text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + resetOctave(staffText->staffIdx()); +return ">" + TextToUEBBraille().braille(staffText->plainText()); +} + +QString Braille::brailleSystemText(SystemText* systemText, int staffIdx) +{ + if (!systemText || systemText->plainText().isEmpty()) { + return QString(); + } + + // System text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + resetOctave(systemText->staffIdx()); + return ">" + TextToUEBBraille().braille(systemText->plainText()); +} + QString Braille::brailleTempoText(TempoText* tempoText, int staffIdx) { if (!tempoText) { diff --git a/src/braille/internal/braille.h b/src/braille/internal/braille.h index 8ae1e726f18bf..39383409de2cb 100644 --- a/src/braille/internal/braille.h +++ b/src/braille/internal/braille.h @@ -36,6 +36,7 @@ class Clef; class DurationElement; class Dynamic; class EngravingItem; +class Expression; class Fermata; class Fingering; class Hairpin; @@ -47,9 +48,12 @@ class Marker; class Measure; class MeasureRepeat; class Note; +class RehearsalMark; class Rest; class Score; class Slur; +class StaffText; +class SystemText; class TempoText; class TimeSig; class Tuplet; @@ -222,7 +226,11 @@ class Braille QString brailleNote(const QString& pitchName, DurationType durationType, int dots); QString brailleOctave(int octave); QString brailleRest(Rest* rest); - QString brailleTempoText(TempoText* tempoText, int staffIdx); + QString brailleStaffText(StaffText * staffText, int staffIdx); +QString brailleSystemText(SystemText* systemText, int staffIdx); + QString brailleRehearsalMark(RehearsalMark* rehearsalMark, int staffIdx); +QString brailleExpressionText(Expression* expression, int staffIdx); + QString brailleTempoText(TempoText* tempoText, int staffIdx); QString brailleTie(Chord* chord); QString brailleTie(Note* note); QString brailleTimeSig(TimeSig* timeSig); From 9b683c5efe51244e9f71da5ca34b885b0397b5aa Mon Sep 17 00:00:00 2001 From: Tim Burgess Date: Mon, 6 Apr 2026 23:15:55 +0100 Subject: [PATCH 2/2] Braille: Use > (dots 3-4-5) for expression, rehearsal mark, staff and system text annotations. Fix #28362 and possibly others.. Now uncrustified. --- src/braille/internal/braille.cpp | 35 ++++++++++++++++---------------- src/braille/internal/braille.h | 9 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/braille/internal/braille.cpp b/src/braille/internal/braille.cpp index ba199c80952d4..e139d9abb6441 100644 --- a/src/braille/internal/braille.cpp +++ b/src/braille/internal/braille.cpp @@ -1256,7 +1256,7 @@ bool Braille::brailleSingleItem(BrailleEngravingItemList* beiz, EngravingItem* e beiz->addEngravingItem(el, brailleJump(toJump(el))); return true; } else if (el->isDynamic()) { - beiz->addEngravingItem(el, brailleDynamic(toDynamic(el))); + beiz->addEngravingItem(el, brailleDynamic(toDynamic(el))); return true; } else if (el->isClef()) { beiz->addEngravingItem(el, brailleClef(toClef(el))); @@ -1331,14 +1331,14 @@ void Braille::brailleMeasureItems(BrailleEngravingItemList* beiz, Measure* measu for (auto seg = measure->first(); seg; seg = seg->next()) { for (EngravingItem* annotation : seg->annotations()) { if (annotation->isExpression()) { - beiz->addEngravingItem(annotation, brailleExpressionText(toExpression(annotation), staffCount)); // Expression text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + beiz->addEngravingItem(annotation, brailleExpressionText(toExpression(annotation), staffCount)); // Expression text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. } else if (annotation->isRehearsalMark()) { - beiz->addEngravingItem(annotation, brailleRehearsalMark(toRehearsalMark(annotation), staffCount)); // Rehearsal marks are not rendered in the staff they are attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. // Rehearsal marks are not rendered in the staff they are attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. - } else if (annotation->isStaffText()) { - beiz->addEngravingItem(annotation, brailleStaffText(toStaffText(annotation), staffCount)); // Staff text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + beiz->addEngravingItem(annotation, brailleRehearsalMark(toRehearsalMark(annotation), staffCount)); // Rehearsal marks are not rendered in the staff they are attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. // Rehearsal marks are not rendered in the staff they are attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + } else if (annotation->isStaffText()) { + beiz->addEngravingItem(annotation, brailleStaffText(toStaffText(annotation), staffCount)); // Staff text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. } else if (annotation->isSystemText()) { - beiz->addEngravingItem(annotation, brailleSystemText(toSystemText(annotation), staffCount)); - } else if (annotation->isTempoText()) { + beiz->addEngravingItem(annotation, brailleSystemText(toSystemText(annotation), staffCount)); + } else if (annotation->isTempoText()) { beiz->addEngravingItem(annotation, brailleTempoText(toTempoText(annotation), staffCount)); } if (annotation->track() == staffCount * VOICES) { @@ -1371,7 +1371,7 @@ void Braille::brailleMeasureItems(BrailleEngravingItemList* beiz, Measure* measu beiz->addEngravingItem(el, brailleBarline(toBarLine(el))); } else if (el->isMeasureRepeat()) { beiz->addEngravingItem(el, brailleMeasureRepeat(toMeasureRepeat(el))); - } + } } // Render the rest of the voices @@ -2342,7 +2342,7 @@ QString Braille::brailleMeasure(Measure* measure, int staffCount) } if (annotation->track() == staffCount * VOICES) { if (annotation->isDynamic()) { - out << brailleDynamic(toDynamic(annotation)); + out << brailleDynamic(toDynamic(annotation)); } } } @@ -2691,27 +2691,26 @@ QString Braille::brailleExpressionText(Expression* expression, int staffIdx) return ">" + TextToUEBBraille().braille(expression->plainText()); } - QString Braille::brailleRehearsalMark(RehearsalMark* rehearsalMark, int staffIdx) { if ((!rehearsalMark) || (rehearsalMark->plainText().isEmpty())) { return QString(); } - resetOctave(rehearsalMark->staffIdx()); + resetOctave(rehearsalMark->staffIdx()); // Need a reference return ">" + TextToUEBBraille().braille(rehearsalMark->plainText()); } - QString Braille::brailleStaffText(StaffText* staffText, int staffIdx) +QString Braille::brailleStaffText(StaffText* staffText, int staffIdx) { - if (!staffText || staffText->plainText().isEmpty()) { - return QString(); -} + if (!staffText || staffText->plainText().isEmpty()) { + return QString(); + } - // Staff text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. - resetOctave(staffText->staffIdx()); -return ">" + TextToUEBBraille().braille(staffText->plainText()); + // Staff text is not rendered in the staff it is attached to, but in the first staff. See 11.1.1. Page 87. Music Braille Code 2015. + resetOctave(staffText->staffIdx()); + return ">" + TextToUEBBraille().braille(staffText->plainText()); } QString Braille::brailleSystemText(SystemText* systemText, int staffIdx) diff --git a/src/braille/internal/braille.h b/src/braille/internal/braille.h index 39383409de2cb..aca325aa5874b 100644 --- a/src/braille/internal/braille.h +++ b/src/braille/internal/braille.h @@ -48,6 +48,7 @@ class Marker; class Measure; class MeasureRepeat; class Note; + class RehearsalMark; class Rest; class Score; @@ -226,11 +227,11 @@ class Braille QString brailleNote(const QString& pitchName, DurationType durationType, int dots); QString brailleOctave(int octave); QString brailleRest(Rest* rest); - QString brailleStaffText(StaffText * staffText, int staffIdx); -QString brailleSystemText(SystemText* systemText, int staffIdx); + QString brailleStaffText(StaffText* staffText, int staffIdx); + QString brailleSystemText(SystemText* systemText, int staffIdx); QString brailleRehearsalMark(RehearsalMark* rehearsalMark, int staffIdx); -QString brailleExpressionText(Expression* expression, int staffIdx); - QString brailleTempoText(TempoText* tempoText, int staffIdx); + QString brailleExpressionText(Expression* expression, int staffIdx); + QString brailleTempoText(TempoText* tempoText, int staffIdx); QString brailleTie(Chord* chord); QString brailleTie(Note* note); QString brailleTimeSig(TimeSig* timeSig);