From 54495e6456e2df78b25ace3dbe88716c5970ce76 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Wed, 30 Nov 2011 11:10:36 +0100 Subject: [PATCH] Prevent accidentals and articulations from moving over leftmost NonMusicalPaperColumns. Inversely, allows accidentals to tuck over change clefs and prevents ledger lines from overlapping barlines in cramped situations. This is done by allowing the pure-from-neighbor-interface to add extra-spacing-height to certain non-musical grobs and removing the blanked skyline-padding applied to NonMusicalPaperColumns. --- input/regression/spacing-folded-clef3.ly | 18 +++++++++ lily/spacing-loose-columns.cc | 4 ++ scm/define-grobs.scm | 47 ++++++++++++------------ scm/output-lib.scm | 9 ++++- 4 files changed, 53 insertions(+), 25 deletions(-) diff --git a/input/regression/spacing-folded-clef3.ly b/input/regression/spacing-folded-clef3.ly index ed94152b5a..a428a4e4f7 100644 --- a/input/regression/spacing-folded-clef3.ly +++ b/input/regression/spacing-folded-clef3.ly @@ -23,3 +23,21 @@ s2. } >> + +\new PianoStaff << + \new Staff = "rh" \relative c'' { + \time 6/8 + bes16 c d + \change Staff = lh + \stemUp bes a g + \change Staff = rh + \stemDown bes c d + \change Staff = lh + \clef bass + \stemUp ces, a g + + } + \new Staff = "lh" \relative c' { + s2. + } +>> diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index cc706fb6b0..b73f193d2d 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -176,6 +176,10 @@ set_loose_columns (System *which, Column_x_positions const *posns) tight_note_space = spring.min_distance (); } + Real loose_col_horizontal_length = loose_col->extent (loose_col, X_AXIS).length (); + base_note_space = max (base_note_space, loose_col_horizontal_length); + tight_note_space = max (tight_note_space, loose_col_horizontal_length); + clique_spacing.push_back (base_note_space); clique_tight_spacing.push_back (tight_note_space); } diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 9cb0e6b5e1..2723ffbfb0 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -520,7 +520,7 @@ (break-align-anchor . ,ly:break-aligned-interface::calc-extent-aligned-anchor) (break-align-symbol . clef) (break-visibility . ,begin-of-line-visible) - ;(extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height) + (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-at-beginning-of-line) (glyph-name . ,ly:clef::calc-glyph-name) (non-musical . #t) (space-alist . ((cue-clef . (extra-space . 2.0)) @@ -534,12 +534,12 @@ (stencil . ,ly:clef::print) (Y-offset . ,ly:staff-symbol-referencer::callback) (meta . ((class . Item) - ;(object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) - ; (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) + (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) + (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) (interfaces . (break-aligned-interface clef-interface font-interface - ;pure-from-neighbor-interface + pure-from-neighbor-interface staff-symbol-referencer-interface)))))) (ClusterSpanner @@ -588,7 +588,7 @@ (break-align-anchor . ,ly:break-aligned-interface::calc-extent-aligned-anchor) (break-align-symbol . cue-clef) (break-visibility . ,begin-of-line-visible) - ;(extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height) + (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-at-beginning-of-line) (font-size . -4) (glyph-name . ,ly:clef::calc-glyph-name) (non-musical . #t) @@ -604,12 +604,12 @@ (stencil . ,ly:clef::print) (Y-offset . ,ly:staff-symbol-referencer::callback) (meta . ((class . Item) - ;(object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) - ; (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) + (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) + (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) (interfaces . (break-aligned-interface clef-interface font-interface - ;pure-from-neighbor-interface + pure-from-neighbor-interface staff-symbol-referencer-interface)))))) (CueEndClef @@ -618,7 +618,7 @@ (break-align-anchor . ,ly:break-aligned-interface::calc-extent-aligned-anchor) (break-align-symbol . cue-end-clef) (break-visibility . ,begin-of-line-invisible) - ;(extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height) + (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-at-beginning-of-line) (font-size . -4) (glyph-name . ,ly:clef::calc-glyph-name) (non-musical . #t) @@ -635,12 +635,12 @@ (stencil . ,ly:clef::print) (Y-offset . ,ly:staff-symbol-referencer::callback) (meta . ((class . Item) - ;(object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) - ; (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) + (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) + (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) (interfaces . (break-aligned-interface clef-interface font-interface - ;pure-from-neighbor-interface + pure-from-neighbor-interface staff-symbol-referencer-interface)))))) (Custos @@ -1103,12 +1103,16 @@ (first-note . (fixed-space . 2.5)))) (stencil . ,ly:key-signature-interface::print) (extra-spacing-width . (0.0 . 1.0)) + (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff) (Y-offset . ,ly:staff-symbol-referencer::callback) (meta . ((class . Item) + (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) + (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) (interfaces . (break-aligned-interface font-interface key-cancellation-interface key-signature-interface + pure-from-neighbor-interface staff-symbol-referencer-interface)))))) (KeySignature @@ -1127,15 +1131,15 @@ (first-note . (fixed-space . 2.5)))) (stencil . ,ly:key-signature-interface::print) (extra-spacing-width . (0.0 . 1.0)) - ;(extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff) + (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff) (Y-offset . ,ly:staff-symbol-referencer::callback) (meta . ((class . Item) - ;(object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) - ; (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) + (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) + (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) (interfaces . (break-aligned-interface font-interface key-signature-interface - ;pure-from-neighbor-interface + pure-from-neighbor-interface staff-symbol-referencer-interface)))))) @@ -1409,8 +1413,6 @@ (before-line-breaking . ,ly:paper-column::before-line-breaking) (full-measure-extra-space . 1.0) (horizontal-skylines . ,ly:separation-item::calc-skylines) - ;; sufficient padding to prevent ledger lines from moving over/under - (skyline-vertical-padding . 0.6) ;; (stencil . ,ly:paper-column::print) (keep-inside-line . #t) @@ -2280,8 +2282,7 @@ (break-align-symbol . time-signature) (break-align-anchor-alignment . ,LEFT) (break-visibility . ,all-visible) - ;(extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff) - (extra-spacing-height . (-1.0 . 1.0)) + (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff) (extra-spacing-width . (0.0 . 0.8)) (non-musical . #t) (space-alist . ( @@ -2292,11 +2293,11 @@ (stencil . ,ly:time-signature::print) (style . C) (meta . ((class . Item) - ;(object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) - ; (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) + (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common) + (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs))) (interfaces . (break-aligned-interface font-interface - ;pure-from-neighbor-interface + pure-from-neighbor-interface time-signature-interface)))))) (TrillPitchAccidental diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 57f89eeb3b..9227787b8c 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -390,6 +390,11 @@ and duration-log @var{log}." (equal? (ly:item-break-dir g) RIGHT)) (ly:grob-translate-axis! g 3.5 X))) +(define-public (pure-from-neighbor-interface::extra-spacing-height-at-beginning-of-line grob) + (if (= 1 (ly:item-break-dir grob)) + (pure-from-neighbor-interface::extra-spacing-height grob) + (cons -0.1 0.1))) + (define-public (pure-from-neighbor-interface::extra-spacing-height grob) (let* ((height (ly:grob::stencil-height grob)) (from-neighbors (interval-union @@ -411,9 +416,9 @@ and duration-log @var{log}." (not (and (eq? x car) (not (ly:grob-property grob 'allow-span-bar))))) (x esh) - 0)) + (x (cons -1.01 1.01)))) (cons car cdr)) - '(0 . 0)))) + '(-1.01 . 1.01)))) (define (pure-from-neighbor-interface::extra-spacing-height-including-staff grob) (let ((esh (pure-from-neighbor-interface::extra-spacing-height grob)) -- 2.39.2