Skip to content

Commit

Permalink
Fix GH#22247: Right-align measure-anchored text to the barline
Browse files Browse the repository at this point in the history
Backport of musescore#22554
  • Loading branch information
XiaoMigros authored and Jojo-Schmitz committed Apr 29, 2024
1 parent d089067 commit 3186e22
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 3 deletions.
5 changes: 4 additions & 1 deletion libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// the file LICENCE.GPL
//=============================================================================

#include "barline.h"
#include "box.h"
#include "page.h"
#include "measure.h"
Expand Down Expand Up @@ -948,8 +949,10 @@ void TextBlock::layout(TextBase* t)
}
break;
case ElementType::MEASURE: {
// ignore courtesy keysig, timesig, but fall back if needed
Measure* m = toMeasure(e);
layoutWidth = m->bbox().width();
const BarLine* bl = m->endBarLine();
layoutWidth = bl ? bl->segment()->x() + bl->width() : m->bbox().width();
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ else
emmentaler-text-2 gonville-text-2 bravura-text-2 musejazz-text-2\
emmentaler-text-3 gonville-text-3 bravura-text-3 musejazz-text-3\
flag flag-straight ledger-lines-2 ledger-lines-3 frame frametext ottava bend-1 \
barline-1 barline-2 instrument-1 instrument-names-1 symbol-1 \
barline-1 barline-2 text-barline-alignment instrument-1 instrument-names-1 symbol-1 \
slurs-1 slurs-2 slurs-3 slurs-4 slurs-5 slurs-6 slurs-7 slurs-8 slurs-9 slurs-10 \
hairpins-1 pedal-1 line-1 line-2 line-3 line-4 line-5 line-6 line-7 line-colour line-dashed gliss-1 gliss-2 gliss-3 \
chord-layout-1 chord-layout-2 chord-layout-3 chord-layout-4 chord-layout-5\
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set SRC=bravura-mmrest,gonville-mmrest, ^
emmentaler-text-2,gonville-text-2,bravura-text-2,musejazz-text-2, ^
emmentaler-text-3,gonville-text-3,bravura-text-3,musejazz-text-3, ^
flag,flag-straight,ledger-lines-2,ledger-lines-3,frame,frametext,ottava,bend-1, ^
barline-1,barline-2,instrument-1,instrument-names-1,symbol-1, ^
barline-1,barline-2,text-barline-alignment,instrument-1,instrument-names-1,symbol-1, ^
slurs-1,slurs-2,slurs-3,slurs-4,slurs-5,slurs-6,slurs-7,slurs-8,slurs-9,slurs-10, ^
hairpins-1,pedal-1,line-1,line-2,line-3,line-4,line-5,line-6,line-7,line-colour,line-dashed,gliss-1,gliss-2,gliss-3, ^
chord-layout-1,chord-layout-2,chord-layout-3,chord-layout-4,chord-layout-5, ^
Expand Down
Binary file added vtest/text-barline-alignment-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
198 changes: 198 additions & 0 deletions vtest/text-barline-alignment.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.02">
<programVersion>3.6.3</programVersion>
<programRevision></programRevision>
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<pageWidth>1.5748</pageWidth>
<pageHeight>1.5748</pageHeight>
<pagePrintableWidth>1.5748</pagePrintableWidth>
<pageEvenLeftMargin>0</pageEvenLeftMargin>
<pageOddLeftMargin>0</pageOddLeftMargin>
<pageEvenTopMargin>0.590551</pageEvenTopMargin>
<pageEvenBottomMargin>0.590551</pageEvenBottomMargin>
<pageOddTopMargin>0</pageOddTopMargin>
<pageOddBottomMargin>0</pageOddBottomMargin>
<staffUpperBorder>5</staffUpperBorder>
<staffLowerBorder>2</staffLowerBorder>
<enableVerticalSpread>1</enableVerticalSpread>
<minSystemSpread>0</minSystemSpread>
<maxSystemSpread>7</maxSystemSpread>
<lyricsMinBottomDistance>1.5</lyricsMinBottomDistance>
<enableIndentationOnFirstSystem>0</enableIndentationOnFirstSystem>
<Spatium>1.74978</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="audioComUrl"></metaTag>
<metaTag name="composer">XiaoMigros</metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="creationDate"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="mscVersion">3.02</metaTag>
<metaTag name="platform"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="subtitle"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<Order id="orchestral" customized="1">
<name>Orchestral</name>
<instrument id="piano">
<family id="keyboards">Tasteninstrumente</family>
</instrument>
<section id="woodwind" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>flutes</family>
<family>oboes</family>
<family>clarinets</family>
<family>saxophones</family>
<family>bassoons</family>
<unsorted group="woodwinds"/>
</section>
<section id="brass" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>horns</family>
<family>trumpets</family>
<family>cornets</family>
<family>flugelhorns</family>
<family>trombones</family>
<family>tubas</family>
</section>
<section id="timpani" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>timpani</family>
</section>
<section id="percussion" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>keyboard-percussion</family>
<family>drums</family>
<family>unpitched-metal-percussion</family>
<family>unpitched-wooden-percussion</family>
<family>other-percussion</family>
</section>
<family>keyboards</family>
<family>harps</family>
<family>organs</family>
<family>synths</family>
<soloists/>
<section id="voices" brackets="true" showSystemMarkings="false" barLineSpan="false" thinBrackets="true">
<family>voices</family>
<family>voice-groups</family>
</section>
<section id="strings" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>orchestral-strings</family>
</section>
<unsorted/>
</Order>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="1" span="2" col="2"/>
<barLineSpan>1</barLineSpan>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano</instrumentId>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
<synti>Fluid</synti>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure>
<LayoutBreak>
<subtype>line</subtype>
</LayoutBreak>
<Jump>
<style>Repeat Text Right</style>
<text>D.C.</text>
<jumpTo>start</jumpTo>
<playUntil>end</playUntil>
<continueAt></continueAt>
</Jump>
<voice>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</voice>
</Measure>
<Measure>
<voice>
<KeySig>
<accidental>3</accidental>
</KeySig>
<TimeSig>
<sigN>3</sigN>
<sigD>4</sigD>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration>3/4</duration>
</Rest>
</voice>
</Measure>
</Staff>
</Score>
</museScore>

0 comments on commit 3186e22

Please sign in to comment.