Skip to content

Commit

Permalink
Merge pull request #1254 from MarcSabatella/31301-half-alignment
Browse files Browse the repository at this point in the history
fix #31301: alignment of half notes
  • Loading branch information
lasconic committed Sep 3, 2014
2 parents 05ba2ab + 9c552b0 commit 65b62ff
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions libmscore/layout.cpp
Expand Up @@ -183,14 +183,23 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
qreal centerDown = 0.0; // offset to apply in order to center downstem chords
qreal centerAdjustUp = 0.0; // adjustment to upstem chord needed after centering donwstem chord
qreal centerAdjustDown = 0.0; // adjustment to downstem chord needed after centering upstem chord
qreal centerThreshold = 0.1 * sp; // only center chords if they differ from nominal by this amount

// only center chords if they differ from nominal by at least this amount
// this avoids unnecessary centering on differences due only to floating point roundoff
// it also allows for the possibility of disabling centering
// for notes only "slightly" larger than nominal, like half notes
// but this will result in them not being aligned with each other between voices
// unless you change to left alignment as described in the comments below
qreal centerThreshold = 0.01 * sp;

headDiff = maxUpWidth - nominalWidth;
if (headDiff > centerThreshold) {
// larger than nominal
centerUp = headDiff * 0.5;
oversizeUp = headDiff;
// to left align rather than center, change the above to
//centerUp = headDiff;
maxUpWidth = nominalWidth + centerUp;
oversizeUp = headDiff;
}
else if (-headDiff > centerThreshold) {
// smaller than nominal
Expand All @@ -199,10 +208,14 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
}
headDiff = maxDownWidth - nominalWidth;
if (headDiff > centerThreshold) {
// larger than nominal
centerDown = headDiff * -0.5;
// to left align rather than center, change the above to
//centerAdjustUp = headDiff;
maxDownWidth = nominalWidth - centerDown;
}
else if (-headDiff > centerThreshold) {
// smaller than nominal
centerDown = headDiff * -0.5;
centerAdjustUp = centerDown;
}
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Expand Up @@ -24,7 +24,7 @@ if test -n "$1"; then
else
SRC="mmrest-1 bravura-mmrest mmrest-2 mmrest-4 mmrest-5 mmrest-6 mmrest-7 mmrest-8 mmrest-9\
fmrest-1 fmrest-2 fmrest-3 fmrest-4 fmrest-5 fmrest-6 measure-repeat-1 \
noteheadposition-1 valign-1 emmentaler-1 bravura-1 emmentaler-2 bravura-2\
noteheadposition-1 valign-1 valign-2 emmentaler-1 bravura-1 emmentaler-2 bravura-2\
emmentaler-3 bravura-3 emmentaler-4 bravura-4 emmentaler-5 bravura-5\
emmentaler-6 bravura-6 emmentaler-7 bravura-7\
emmentaler-8 bravura-8 emmentaler-9 bravura-9 emmentaler-10 bravura-10\
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Expand Up @@ -5,7 +5,7 @@ rem "compare" - image magick compare program

set SRC=mmrest-1,bravura-mmrest,mmrest-2,mmrest-4,mmrest-5,mmrest-6,mmrest-7,mmrest-8,mmrest-9, ^
fmrest-1,fmrest-2,fmrest-3,fmrest-4,fmrest-5,fmrest-6,measure-repeat-1, ^
noteheadposition-1,valign-1,emmentaler-1,bravura-1,emmentaler-2,bravura-2, ^
noteheadposition-1,valign-1,valign-2,emmentaler-1,bravura-1,emmentaler-2,bravura-2, ^
emmentaler-3,bravura-3,emmentaler-4,bravura-4,emmentaler-5,bravura-5, ^
emmentaler-6,bravura-6,emmentaler-7,bravura-7, ^
emmentaler-8,bravura-8,emmentaler-9,bravura-9,emmentaler-10,bravura-10, ^
Expand Down
Binary file modified vtest/valign-1-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/valign-2-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/valign-2.mscz
Binary file not shown.

0 comments on commit 65b62ff

Please sign in to comment.