From: Han-Wen Nienhuys Date: Tue, 8 Nov 2005 14:23:38 +0000 (+0000) Subject: * rehearsalmark-horiz-extent.ly: add note. X-Git-Tag: release/2.7.17~45 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b4000f0f08c29e86416eeaf644785d9bdb67394a;p=lilypond.git * rehearsalmark-horiz-extent.ly: add note. * scm/music-functions.scm (glue-mm-rest-texts): also put other events into EventChord. This fixes textspanners on mm rests. * lily/side-position-interface.cc (get_axis): read side-axis (set_axis): set side-axis. * scm/define-grobs.scm (all-grob-descriptions): add side-axis properties everywhere. * lily/spacing-spanner.cc (breakable_column_spacing): add average-spacing-wishes. Take maximum if not set. (musical_column_spacing): idem. * scm/define-grobs.scm (all-grob-descriptions): add average-spacing-wishes. * lily/grob-closure.cc (add_offset_callback): bugfix: properly add offset callbacks. This fixes alignment for Fingering objects. * scm/define-grobs.scm (all-grob-descriptions): tiny bit less space for key - timesig combination. * scm/define-grobs.scm (all-grob-descriptions): decrease distance to key sig. * scm/define-grobs.scm (all-grob-descriptions): remove self-X-offset. Fixes alignment of octavate-8. --- diff --git a/ChangeLog b/ChangeLog index 3d5a4d904f..0e4bf972ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2005-11-08 Han-Wen Nienhuys + * scm/music-functions.scm (glue-mm-rest-texts): also put other + events into EventChord. This fixes textspanners on mm rests. + + * lily/side-position-interface.cc (get_axis): read side-axis + (set_axis): set side-axis. + + * scm/define-grobs.scm (all-grob-descriptions): add side-axis + properties everywhere. + + * lily/spacing-spanner.cc (breakable_column_spacing): add + average-spacing-wishes. Take maximum if not set. + (musical_column_spacing): idem. + + * scm/define-grobs.scm (all-grob-descriptions): add average-spacing-wishes. + * lily/grob-closure.cc (add_offset_callback): bugfix: properly add offset callbacks. This fixes alignment for Fingering objects. diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index bf92fc4c8f..bc386b628e 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -109,4 +109,4 @@ ADD_INTERFACE (Axis_group_interface, "axis-group-interface", /* properties */ "axes " - "elements"); + "elements "); diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index 9279e16a6a..31401f029b 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -97,7 +97,6 @@ Bar_number_engraver::create_items () return; text_ = make_item ("BarNumber", SCM_EOL); - Side_position_interface::set_axis (text_, Y_AXIS); } ADD_TRANSLATOR (Bar_number_engraver, diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index ec7ee15a93..147578de0b 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -85,21 +85,21 @@ Instrument_name_engraver::create_text () } void -Instrument_name_engraver::acknowledge_bar_line (Grob_info i) +Instrument_name_engraver::acknowledge_bar_line (Grob_info info) { - (void)i; + (void) info; create_text (); } void -Instrument_name_engraver::acknowledge_axis_group (Grob_info i) +Instrument_name_engraver::acknowledge_axis_group (Grob_info info) { /* Ugh - typechecking for pedal and dynamic sucks. */ - if (dynamic_cast (i.grob ()) - && (i.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface")) - || i.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface")))) + if (dynamic_cast (info.grob ()) + && (info.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface")) + || info.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface")))) return; /* @@ -111,12 +111,12 @@ Instrument_name_engraver::acknowledge_axis_group (Grob_info i) We could also just use stavesFound, but lets keep this working without staffs as well. */ - if (dynamic_cast (i.grob ()) - && ((Axis_group_interface::has_interface (i.grob ()) - && Axis_group_interface::has_axis (i.grob (), Y_AXIS))) - && !Align_interface::has_interface (i.grob ())) + if (dynamic_cast (info.grob ()) + && ((Axis_group_interface::has_interface (info.grob ()) + && Axis_group_interface::has_axis (info.grob (), Y_AXIS))) + && !Align_interface::has_interface (info.grob ())) { - SCM nl = scm_cons (i.grob ()->self_scm (), + SCM nl = scm_cons (info.grob ()->self_scm (), get_property ("instrumentSupport")); context ()->set_property ("instrumentSupport", nl); @@ -139,6 +139,7 @@ Instrument_name_engraver::process_music () ADD_ACKNOWLEDGER (Instrument_name_engraver, bar_line); ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group); + ADD_TRANSLATOR (Instrument_name_engraver, /* doc */ " Prints the name of the instrument (specified by " " @code{Staff.instrument} and @code{Staff.instr}) " diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 928d0e8679..7d4ab573d3 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -208,24 +208,23 @@ Side_position_interface::aligned_side (Grob*me, Axis a) void Side_position_interface::set_axis (Grob *me, Axis a) { - add_offset_callback (me, - (a==X_AXIS) - ? x_aligned_side_proc - : y_aligned_side_proc, - a); + if (!scm_is_number (me->get_property ("side-axis"))) + { + me->set_property ("side-axis", scm_from_int (a)); + add_offset_callback (me, + (a==X_AXIS) + ? x_aligned_side_proc + : y_aligned_side_proc, + a); + } } - -// ugh. doesn't catch all variants. Axis Side_position_interface::get_axis (Grob *me) { - if (me->get_property_data (ly_symbol2scm ("X-offset")) - == Side_position_interface::x_aligned_side_proc) - return X_AXIS; - else if (me->get_property_data (ly_symbol2scm ("Y-offset")) - == Side_position_interface::y_aligned_side_proc) - return Y_AXIS; - + if (scm_is_number (me->get_property ("side-axis"))) + return Axis (scm_to_int (me->get_property ("side-axis"))); + + programming_error ("side-axis not set."); return NO_AXES; } @@ -241,6 +240,7 @@ ADD_INTERFACE (Side_position_interface, "side-position-interface", "direction-source " "minimum-space " "padding " + "side-axis " "side-relative-direction " "side-support-elements " "slur-padding " diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index f56af93598..baa7cd483f 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -246,6 +246,8 @@ Spacing_spanner::musical_column_spacing (Grob *me, bool expand_only = false; Real base_note_space = note_spacing (me, left_col, right_col, options, &expand_only); + Real max_fixed = 0; + Real max_space = 0; Real compound_note_space = 0.0; Real compound_fixed_note_space = 0.0; @@ -281,8 +283,12 @@ Spacing_spanner::musical_column_spacing (Grob *me, Note_spacing::get_spacing (wish, right_col, base_note_space, options->increment_, &space, &fixed); - compound_note_space = compound_note_space + space; - compound_fixed_note_space = compound_fixed_note_space + fixed; + + max_space = max (max_space, space); + max_fixed = max (max_fixed, fixed); + + compound_note_space += space; + compound_fixed_note_space += fixed; wish_count++; } } @@ -301,11 +307,16 @@ Spacing_spanner::musical_column_spacing (Grob *me, compound_note_space = base_note_space; compound_fixed_note_space = options->increment_; } - else + else if (to_boolean (me->get_property ("average-spacing-wishes"))) { compound_note_space /= wish_count; compound_fixed_note_space /= wish_count; } + else + { + compound_fixed_note_space = max_fixed; + compound_note_space = max_space; + } /* Whatever we do, the fixed space is smaller than the real @@ -356,6 +367,9 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, { Real compound_fixed = 0.0; Real compound_space = 0.0; + Real max_fixed = 0.0; + Real max_space = 0.0; + int wish_count = 0; Moment dt = Paper_column::when_mom (r) - Paper_column::when_mom (l); @@ -394,6 +408,9 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, space *= 0.8; } + max_space = max (max_space, space); + max_fixed = max (max_fixed, fixed_space); + compound_space += space; compound_fixed += fixed_space; wish_count++; @@ -408,8 +425,17 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, } else { - compound_space /= wish_count; - compound_fixed /= wish_count; + if (to_boolean (me->get_property ("average-spacing-wishes"))) + { + compound_space /= wish_count; + compound_fixed /= wish_count; + } + else + { + compound_fixed = max_fixed; + compound_space = max_space; + } + } if (options->stretch_uniformly_ && l->break_status_dir () != RIGHT) @@ -442,6 +468,7 @@ ADD_INTERFACE (Spacing_spanner, "spacing-spanner-interface", "head width) A 16th note is followed by 0.5 note head width. The\n" "quarter note is followed by 3 NHW, the half by 4 NHW, etc.\n", + "average-spacing-wishes " "grace-space-factor " "spacing-increment " "base-shortest-duration " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 0f730b5c1d..9695d628b8 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -39,6 +39,7 @@ arrow on the arpeggio squiggly line.") (auto-knee-gap ,ly:dimension? "If a gap is found between note heads where a horizontal beam fits that is larger than this number, make a kneed beam.") + (average-spacing-wishes ,boolean? "If set, the spacing wishes are averaged over staves.") (axes ,list? "list of axis numbers. In the case of alignment grobs, this should contain only one number.") @@ -177,10 +178,7 @@ fret diagram. Options include @code{none}, @code{in-dot}, and @code{below-strin typeset on a Stem. Valid options include @code{()} and @code{mensural}. Additionally, @code{\"no-flag\"} switches off the flag.") - - (strict-note-spacing ,boolean? "If set, unbroken columns -with non-musical material (clefs, barlines, etc.) are not spaced -separately, but put before musical columns.") + (font-family ,symbol? "The font family is the broadest category for selecting text fonts. Options include: @code{sans}, @code{roman} ") (font-encoding ,symbol? "The font encoding is the broadest category for selecting a font. Options include: @code{fetaMusic}, @@ -343,6 +341,9 @@ quicker the slur attains it @code{height-limit}.") (remove-first ,boolean? "Remove the first staff of a orchestral score?") (right-padding ,ly:dimension? "Space to insert between note and accidentals.") + (same-direction-correction ,number? "Optical correction amount +for stems that are placed in tight configurations. This amount is used +for stems with the same direction to compensate for note-head to stem distance.") (script-priority ,number? "A sorting key that determines in what order a script is within a stack of scripts.") @@ -368,6 +369,7 @@ note that starts here.") "Multiply direction of @code{direction-source} with this to get the direction of this object.") + (side-axis ,number? "Is this object horizontally or vertically next to another object?") (size ,number? "Size of object, relative to standard size.") (slope ,number? "The slope of this object.") (slur-padding ,number? "Extra distance between slur and script.") @@ -401,9 +403,9 @@ stems that are placed in tight configurations. For opposite directions, this amount is the correction for two normal sized stems that overlap completely.") - (same-direction-correction ,number? "Optical correction amount -for stems that are placed in tight configurations. This amount is used -for stems with the same direction to compensate for note-head to stem distance.") + (strict-note-spacing ,boolean? "If set, unbroken columns +with non-musical material (clefs, barlines, etc.) are not spaced +separately, but put before musical columns.") (string-count ,integer? "The number of strings in a fret diagram.") (stroke-style ,string? "set to \"grace\" to turn stroke through flag on.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 958e875f18..e2c00936f7 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -43,6 +43,7 @@ (direction . ,UP) (staff-padding . 0.25) (script-priority . 0) + (side-axis . ,X) (meta . ((class . Item) (interfaces . (side-position-interface script-interface @@ -105,6 +106,7 @@ (stencil . ,Accidental_interface::print) (after-line-breaking . ,Accidental_interface::after_line_breaking) + (side-axis . ,X) (meta . ((class . Item) (interfaces . (item-interface @@ -139,6 +141,7 @@ (X-offset . ,Side_position_interface::x_aligned_side) (direction . -1) (padding . 0.5) + (side-axis . ,X) (staff-position . 0.0) (meta . ((class . Item) (interfaces . (arpeggio-interface @@ -184,9 +187,7 @@ (BarNumber . ( - (stencil . ,Text_interface::print) - ; (breakable . #t) (break-visibility . ,begin-of-line-visible) (padding . 1.0) @@ -194,6 +195,7 @@ (font-family . roman) (font-size . -2) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (X-offset . ,Self_alignment_interface::x_aligned_on_self) (self-alignment-X . 1) @@ -485,6 +487,7 @@ (script-priority . 200) ;; todo: add X self alignment? (baseline-skip . 2) + (side-axis . ,Y) (font-series . bold) (meta . ((class . Item) (interfaces . (text-script-interface @@ -565,6 +568,7 @@ (direction . 1) (padding . 0.2) (staff-padding . 0.25) + (side-axis . ,Y) (meta . ((class . Item) (interfaces . (side-position-interface self-alignment-interface @@ -581,6 +585,7 @@ (slur-padding . 0.3) (minimum-space . 1.2) (direction . -1) + (side-axis . ,Y) (Y-extent . ,Axis_group_interface::height) (X-extent . ,Axis_group_interface::width) @@ -727,13 +732,12 @@ (HorizontalBracket . ( (thickness . 1.0) - (stencil . ,Horizontal_bracket::print) - (Y-offset . ,Side_position_interface::y_aligned_side) (padding . 0.2) (staff-padding . 0.2) (direction . -1) + (side-axis . ,Y) (bracket-flare . (0.5 . 0.5)) (meta . ((class . Spanner) (interfaces . (horizontal-bracket-interface @@ -753,12 +757,11 @@ (left-edge . (extra-space . 1.0)))) (self-alignment-Y . 0) - (stencil . ,Text_interface::print) - (break-align-symbol . instrument-name) (break-visibility . ,begin-of-line-visible) (baseline-skip . 2) + (side-axis . ,X) (meta . ((class . Item) (interfaces . (font-interface self-alignment-interface @@ -952,6 +955,7 @@ (Y-offset . ,Side_position_interface::y_aligned_side) (direction . 1) (padding . 0.8) + (side-axis . ,Y) (meta . ((class . Item) (interfaces . (text-interface side-position-interface @@ -961,6 +965,7 @@ (MeasureGrouping . ( (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (stencil . ,Measure_grouping::print) @@ -1000,6 +1005,8 @@ `(,+ ,(ly:make-simple-closure (list Self_alignment_interface::x_aligned_on_self)) ,(ly:make-simple-closure (list Self_alignment_interface::x_centered_on_y_parent))))) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) + (self-alignment-X . 0) (direction . 1) (padding . 0.4) @@ -1307,7 +1314,8 @@ (padding . 0.20) (staff-padding . 0.25) ;; (script-priority . 0) priorities for scripts, see script.scm - (X-offset . ,Self_alignment_interface::centered_on_x_parent) + (X-offset . , Self_alignment_interface::centered_on_x_parent) + (stencil . ,Script_interface::print) (direction . ,Script_interface::calc_direction) @@ -1365,7 +1373,7 @@ . ( (springs-and-rods . ,Spacing_spanner::set_springs) - + (average-spacing-wishes . #t) (grace-space-factor . 0.6) (shortest-duration-space . 2.0) (spacing-increment . 1.2) @@ -1408,6 +1416,7 @@ (font-series . bold) (padding . 1.0) (X-offset . ,Side_position_interface::x_aligned_side) + (side-axis . ,X) (direction . ,LEFT) (meta . ((class . Item) (interfaces . (side-position-interface @@ -1467,6 +1476,7 @@ (X-extent . ,Axis_group_interface::height) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (padding . 1.2) (minimum-space . 1.0) @@ -1571,6 +1581,7 @@ (axes . (1)) (X-extent . ,Axis_group_interface::height) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (padding . 1.2) (staff-padding . 1.2) (minimum-space . 1.0) @@ -1668,6 +1679,7 @@ (staff-padding . 0.8) (dash-fraction . 0.2) (dash-period . 3.0) + (side-axis . ,Y) (direction . 1) (meta . ((class . Spanner) (interfaces . (text-spanner-interface @@ -1722,6 +1734,7 @@ (padding . 0.5) (direction . 1) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (meta . ((class . Spanner) (interfaces . (text-spanner-interface side-position-interface @@ -1732,6 +1745,7 @@ (padding . 0.2) (direction . ,LEFT) (font-size . -4) + (side-axis . ,X) (stencil . ,Accidental_interface::print) (meta . ((class . Item) (interfaces . (item-interface @@ -1745,6 +1759,7 @@ (font-size . -4) (stencil . ,parenthesize-elements) (direction . ,RIGHT) + (side-axis . ,X) (padding . 0.3) (meta . ((class . Item) (interfaces . (side-position-interface @@ -1804,6 +1819,7 @@ (axes . (1)) (X-extent . ,Axis_group_interface::height) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (padding . 1.2) (staff-padding . 1.2) (minimum-space . 1.0) @@ -1855,6 +1871,7 @@ (break-align-symbol . clef) (break-visibility . ,begin-of-line-visible) (baseline-skip . 2) + (side-axis . ,Y) (meta . ((class . Item) (interfaces . (font-interface self-alignment-interface @@ -1870,6 +1887,7 @@ (padding . 1) (font-encoding . fetaNumber) (Y-offset . ,Side_position_interface::y_aligned_side) + (side-axis . ,Y) (thickness . 1.6) ;; linethickness (edge-height . (2.0 . 2.0)) ;; staffspace; (minimum-space . 5) diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 88c02025e2..40e7396c55 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -367,21 +367,41 @@ i.e. this is not an override" "Check if we have R1*4-\\markup { .. }, and if applicable convert to a property set for MultiMeasureRestNumber." (define (script-to-mmrest-text script-music) - "Extract 'direction and 'text from SCRIPT-MUSIC, and transform into property sets." + "Extract 'direction and 'text from SCRIPT-MUSIC, and transform MultiMeasureTextEvent" (let ((dir (ly:music-property script-music 'direction)) (p (make-music 'MultiMeasureTextEvent 'text (ly:music-property script-music 'text)))) (if (ly:dir? dir) (set! (ly:music-property p 'direction) dir)) p)) + (if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup) (let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types)))) - (es (ly:music-property music 'elements)) - (texts (map script-to-mmrest-text (filter text? es))) - (others (remove text? es))) - (if (pair? texts) + (event? (lambda (x) (memq 'event (ly:music-property x 'types)))) + (group-elts (ly:music-property music 'elements)) + (texts '()) + (events '()) + (others '())) + + (set! texts + (map script-to-mmrest-text (filter text? group-elts))) + (set! group-elts + (remove text? group-elts)) + + (set! events (filter event? group-elts)) + (set! others (remove event? group-elts)) + + (if (or (pair? texts) (pair? events)) (set! (ly:music-property music 'elements) - (cons (make-event-chord texts) others))))) + (cons (make-event-chord + (append texts events)) + others))) + + + (display-scheme-music (list music)) + + )) + music)