[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Merge_rests_engraver: fix vertical rest positions (issue 334740043 by ad
Merge_rests_engraver: fix vertical rest positions (issue 334740043 by address@hidden)
Wed, 04 Oct 2017 08:03:01 -0700
for sort of bug report on the user list.
Merge_rests_engraver: fix vertical rest positions
When used with \magnifyStaff the engraver failed to position merged
rests correctly. Using staff-position instead of Y-offset for vertical
positioning fixes this.
Please review this at https://codereview.appspot.com/334740043/
Affected files (+9, -15 lines):
diff --git a/scm/scheme-engravers.scm b/scm/scheme-engravers.scm
@@ -128,20 +128,14 @@ if there were one voice."
(define (is-single-bar-rest? mmrest)
(eqv? (ly:grob-property mmrest 'measure-count) 1))
- (define (is-whole-rest? rest)
- (eqv? (ly:grob-property rest 'duration-log) 0))
- (define (mmrest-offset mmrest)
+ (define (mmrest-position mmrest)
"For single measures they should hang from the second line from the top
- (offset of 1). For longer multimeasure rests they should be centered on
- middle line (offset of 0).
+ (staff-position of 2). For longer multimeasure rests they should be
centered on the
+ middle line (staff-position of 0).
NOTE: For one-line staves full single measure rests should be positioned
0, but I don't anticipate this engraver's use in that case. No errors are
given in this case."
- (if (is-single-bar-rest? mmrest) 1 0))
- (define (rest-offset rest)
- (if (is-whole-rest? rest) 1 0))
+ (if (is-single-bar-rest? mmrest) 2 0))
(define (rest-eqv rest-len-prop)
"Compare rests according the given property"
@@ -158,12 +152,12 @@ if there were one voice."
(define (merge-mmrests rests)
"Move all multimeasure rests to the single voice location."
(if (all-equal rests (rest-eqv 'measure-count))
- (merge-rests rests mmrest-offset)))
+ (merge-rests rests mmrest-position)))
- (define (merge-rests rests offset-function)
- (let ((y-offset (offset-function (car rests))))
+ (define (merge-rests rests position-function)
+ (let ((staff-pos (position-function (car rests))))
- (lambda (rest) (ly:grob-set-property! rest 'Y-offset y-offset))
+ (lambda (rest) (ly:grob-set-property! rest 'staff-position
(lambda (rest) (ly:grob-set-property! rest 'transparent #t))
@@ -217,7 +211,7 @@ if there were one voice."
(all-equal durs moment=?)
- (merge-rests rests rest-offset)
+ (merge-rests rests (lambda (r) 0))
;; ly:grob-suicide! works nicely for dots, as opposed to
(if (pair? dots) (for-each ly:grob-suicide! (cdr dots)))))
(if (has-at-least-two curr-mmrests)
|[Prev in Thread]
||[Next in Thread]|
- Merge_rests_engraver: fix vertical rest positions (issue 334740043 by address@hidden),