From d6e2d8515999e8fb0d5726bd760416f5cf646c71 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 16 Oct 2005 14:09:31 +0000 Subject: [PATCH] * ly/engraver-init.ly (AncientRemoveEmptyStaffContext): use length-fraction. * lily/stem.cc (calc_length): multiply with length_fraction. Makes for easier grace tweaks. * lily/beam.cc: remove dir-function. * lily/system.cc (pre_processing): use callback to trigger spacing procedures. * lily/grob.cc: remove spacing-procedure. * lily/note-head.cc (calc_stem_attachment): new function. (internal_print): use callback to get glyph-name. * lily/stem.cc (calc_stem_end_position): new function. (calc_length): new function. document details for stem. remove Stem::get_direction() * lily/grob.cc (get_stencil): simplify: use callback mechanism to calculate stencil. (get_print_stencil): rename from get_stencil: create stencil with transparency, color and cause. * scm/define-grobs.scm: change print-function to stencil callback everywhere. * python/convertrules.py (conv): insert temporary warning rule. * lily/grob.cc: elucidate doc about after/before-line-breaking * lily/stem.cc (height): idem. * lily/grob.cc: change after/before-line-breaking-callback to after/before-line-breaking dummy properties. * lily/grob.cc (other_axis_parent_positioning): new function. (same_axis_parent_positioning): new function * lily/beam.cc (calc_direction): use pseudo-property for beam direction callback. (calc_positions): use callback * lily/stem.cc (calc_stem_end_position): use callback. (calc_positioning_done): idem. (calc_direction): idem. (calc_stem_end_position): idem (calc_stem_info): idem. * scm/define-grob-properties.scm (all-user-grob-properties): doc callbacks property. --- ChangeLog | 14 +++++++++++++ lily/beam.cc | 25 ++++++++++++----------- lily/grob.cc | 2 +- lily/note-head.cc | 2 +- lily/stem.cc | 13 ++++++++++-- lily/system.cc | 4 +--- ly/engraver-init.ly | 17 +++------------- python/convertrules.py | 2 +- scm/define-grob-properties.scm | 26 ++++++------------------ scm/define-grobs.scm | 36 ++++++++++++++++++---------------- 10 files changed, 69 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e3e6c77e5..bf4cd71383 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2005-10-16 Han-Wen Nienhuys + * ly/engraver-init.ly (AncientRemoveEmptyStaffContext): use length-fraction. + + * lily/stem.cc (calc_length): multiply with length_fraction. Makes + for easier grace tweaks. + + * lily/beam.cc: remove dir-function. + + * lily/system.cc (pre_processing): use callback to trigger spacing procedures. + + * lily/grob.cc: remove spacing-procedure. + + * lily/note-head.cc (calc_stem_attachment): new function. + (internal_print): use callback to get glyph-name. + * lily/grob-property.cc (get_interfaces): new function. * lily/grob-scheme.cc (LY_DEFINE): new function ly:grob-interfaces diff --git a/lily/beam.cc b/lily/beam.cc index 2ee9e7086c..c4fc1147c4 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -544,18 +544,18 @@ Beam::get_default_dir (Grob *me) } } - SCM func = me->get_property ("dir-function"); - SCM s = scm_call_2 (func, - scm_cons (scm_from_int (count[UP]), - scm_from_int (count[DOWN])), - scm_cons (scm_from_int (total[UP]), - scm_from_int (total[DOWN]))); - - if (scm_is_number (s) && scm_to_int (s)) - return to_dir (s); - - /* If dir is not determined: get default */ - return to_dir (me->get_property ("neutral-direction")); + Direction dir = CENTER; + + if (Direction d = (Direction) sign (count[UP] - count[DOWN])) + dir = d; + else if (Direction d = (Direction) sign (total[UP] / count[UP] - total[DOWN]/count[DOWN])) + dir = d; + else if (Direction d = (Direction) sign (total[UP] - total[DOWN])) + dir = d; + else + dir = to_dir (me->get_property ("neutral-direction")); + + return dir; } /* Set all stems with non-forced direction to beam direction. @@ -1395,7 +1395,6 @@ ADD_INTERFACE (Beam, "damping " "details " "direction " - "dir-function " "flag-width-function " "gap " "gap-count " diff --git a/lily/grob.cc b/lily/grob.cc index 3cde285428..38edbaf785 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -732,7 +732,7 @@ ADD_INTERFACE (Grob, "grob-interface", "meta " "minimum-X-extent " "minimum-Y-extent " - "spacing-procedure " + "springs-and-rods " "staff-symbol " "stencil " "transparent" diff --git a/lily/note-head.cc b/lily/note-head.cc index 2517f5048b..eff41c8339 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -154,7 +154,7 @@ ADD_INTERFACE (Note_head, "note-head-interface", "note-names " "glyph-name-procedure " "accidental-grob " - "stem-attachment" + "stem-attachment " "style " ); diff --git a/lily/stem.cc b/lily/stem.cc index 758afae3c7..296a5f00ca 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -317,6 +317,8 @@ Stem::calc_length (SCM smob) length -= shorten; } + length *= robust_scm2double (me->get_property ("length-fraction"), 1.0); + /* Tremolo stuff. */ Grob *t_flag = unsmob_grob (me->get_object ("tremolo-flag")); if (t_flag && !unsmob_grob (me->get_object ("beam"))) @@ -805,6 +807,8 @@ Stem::calc_stem_info (SCM smob) /* Simple standard stem length */ SCM details = me->get_property ("details"); SCM lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-lengths"), details)); + + Real ideal_length = scm_to_double (robust_list_ref (beam_count - 1, lengths)) @@ -815,9 +819,12 @@ Stem::calc_stem_info (SCM smob) /* Condition: sane minimum free stem length (chord to beams) */ lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-minimum-free-lengths"), details)); + Real length_fraction + = robust_scm2double (me->get_property ("length-fraction"), 1.0); + Real ideal_minimum_free = scm_to_double (robust_list_ref (beam_count - 1, lengths)) - * staff_space; + * staff_space * length_fraction; /* UGH It seems that also for ideal minimum length, we must use @@ -872,7 +879,8 @@ Stem::calc_stem_info (SCM smob) ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0); - SCM bemfl = scm_cdr (scm_assq (ly_symbol2scm ("beamed-extreme-minimum-free-lengths"), details)); + SCM bemfl = scm_cdr (scm_assq (ly_symbol2scm ("beamed-extreme-minimum-free-lengths"), + details)); Real minimum_free = scm_to_double (robust_list_ref (beam_count - 1, bemfl)) @@ -944,6 +952,7 @@ ADD_INTERFACE (Stem, "stem-interface", "flag-style " "french-beaming " "length " + "length-fraction " "neutral-direction " "no-stem-extend " "note-heads " diff --git a/lily/system.cc b/lily/system.cc index 0ca8cfda14..60bdfeed59 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -291,9 +291,7 @@ System::pre_processing () for (int i = 0; i < all_elements_->size (); i++) { Grob *e = all_elements_->grob (i); - SCM proc = e->get_property ("spacing-procedure"); - if (ly_is_procedure (proc)) - scm_call_1 (proc, e->self_scm ()); + (void) e->get_property ("springs-and-rods"); } } diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index f37e9b5b10..c2576b312c 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -550,21 +550,10 @@ AncientRemoveEmptyStaffContext = \context { metronomeMarkFormatter = #format-metronome-markup graceSettings = #`( (Voice Stem direction 1) - ;; TODO: should take from existing definition. - ;; c&p from define-grobs.scm - - (Voice Stem lengths ,(map (lambda (x) (* 0.8 x)) '(3.5 3.5 3.5 4.5 5.0))) - (Voice Stem stem-shorten (0.4 0.4)) - (Voice Stem font-size -3) + (Voice Stem font-size -3) (Voice NoteHead font-size -3) - (Voice Dots font-size -3) - (Voice Stem beamed-lengths - ,(map (lambda (x) (* 0.8 x)) '(3.3 3.3 4.0))) - (Voice Stem beamed-minimum-free-lengths - ,(map (lambda (x) (* 0.8 x)) '(2.5 2.0 1.5))) - (Voice Stem beamed-extreme-minimum-free-lengths - ,(map (lambda (x) (* 0.8 x)) '(1.83 1.5))) - + (Voice Dots font-size -3) + (Voice Stem length-fraction 0.8) (Voice Stem no-stem-extend #t) (Voice Beam thickness 0.384) (Voice Beam space-function ,(lambda (beam mult) diff --git a/python/convertrules.py b/python/convertrules.py index 15913c8414..d6ebe80f9b 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -2584,7 +2584,7 @@ conversions.append (((2, 7, 12), conv, '''outputProperty -> overrideProperty''')) def conv (str): - if re.search(r'(after-line-breaking-callback|before-line-breaking-callback|print-function)', str): + if re.search(r'(spacing-procedure|after-line-breaking-callback|before-line-breaking-callback|print-function)', str): error_file.write (""" Conversion rules for 2.7.13 layout engine refactoring haven't been written yet. diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 4ebb7665d8..0c2d656d36 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -152,20 +152,6 @@ line).") (arrow-length ,number? "Arrow length.") (arrow-width ,number? "Arrow width.") - ;; todo: why is this tunable? - (dir-function ,procedure? "The function to determine the -direction of a beam. Choices include: - -@table @code -@item beam-dir-majority -number count of up or down notes -@item beam-dir-mean -mean center distance of all notes -@item beam-dir-median. -mean center distance weighted per note -@end table - -") (direction ,ly:dir? "Up or down, left or right?") (dot-color ,symbol? "Color of dots. Options include @@ -290,9 +276,11 @@ sum of 2 numbers. The first is the factor for line thickness, and the second for staff space. Both contributions are added.") (left-padding ,ly:dimension? "The amount of space that is put left to a group of accidentals.") + (length ,ly:dimension? "User override for the stem length of unbeamed stems.") - (length-fraction ,number? "Length of ledger line as fraction of note head size.") + (length-fraction ,number? "Multiplier for lengths. Used for +determining ledger lines and stem lengths.") (line-break-system-details ,list? "Alist of properties to use when this @@ -321,8 +309,8 @@ and notes or beam.") dimension, measured in staff space.") (minimum-Y-extent ,number-pair? "See @code{minimum-Y-extent}.") (minimum-length ,ly:dimension? "Try to make a spanner at least -this long. This requires an appropriate routine for the -@code{spacing-procedure} property.") +this long. This requires an appropriate callback for the +@code{springs-and-rods} property.") (minimum-space ,ly:dimension? "Minimum distance that the victim should move (after padding).") (neutral-direction ,ly:dir? "Which direction to take in the @@ -410,9 +398,7 @@ beams.") duration. Typically, the width of a note head. See also @internalsref{spacing-spanner-interface}.") - (spacing-procedure ,procedure? "Procedure for calculating spacing -parameters. The routine is called after -@code{before-line-breaking-callback}.") + (springs-and-rods ,boolean? "Dummy variable for triggering spacing routines.") (stacking-dir ,ly:dir? "Stack objects in which direction?") (staff-space ,ly:dimension? "Amount of space between staff lines, expressed in global staffspace.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index d32ea32ef9..bf73845789 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -270,7 +270,6 @@ ;; TODO: should be in SLT. (thickness . 0.48) ; in staff-space (neutral-direction . -1) - (dir-function . ,beam-dir-majority-median) ;; Whe have some unreferenced problems here. ;; @@ -409,8 +408,9 @@ (ClusterSpanner . ( - (callbacks . ((stencil . ,Cluster::print))) - (spacing-procedure . ,Spanner::set_spacing_rods) + (callbacks . ((springs-and-rods . ,Spanner::set_spacing_rods) + (stencil . ,Cluster::print))) + (minimum-length . 0.0) (padding . 0.25) (style . ramp) @@ -419,8 +419,8 @@ (ChordName . ( - (callbacks . ((stencil . ,Text_interface::print))) - (callbacks . ((after-line-breaking . ,Chord_name::after_line_breaking) + (callbacks . ((stencil . ,Text_interface::print) + (after-line-breaking . ,Chord_name::after_line_breaking) )) (word-space . 0.0) (font-family . sans) @@ -648,10 +648,10 @@ . ( (callbacks . ((stencil . ,Hairpin::print) + (springs-and-rods . ,Spanner::set_spacing_rods) (after-line-breaking . ,Hairpin::after_line_breaking))) (thickness . 1.0) (height . 0.6666) - (spacing-procedure . ,Spanner::set_spacing_rods) (minimum-length . 2.0) (bound-padding . 1.0) (self-alignment-Y . 0) @@ -762,12 +762,13 @@ (LedgerLineSpanner . ( - (callbacks . ((stencil . ,Ledger_line_spanner::print))) + (callbacks . ((springs-and-rods . ,Ledger_line_spanner::set_spacing_rods) + + (stencil . ,Ledger_line_spanner::print))) (X-extent-callback . #f) (Y-extent-callback . #f) (minimum-length-fraction . 0.25) (length-fraction . 0.25) - (spacing-procedure . ,Ledger_line_spanner::set_spacing_rods) (layer . 0) (meta . ((class . Spanner) (interfaces . (ledger-line-interface)))))) @@ -821,7 +822,7 @@ (length . 0.66) (minimum-length . 0.3) (padding . 0.07) - ; (spacing-procedure . ,Hyphen_spanner::set_spacing_rods) + ; (springs-and-rods . ,Hyphen_spanner::set_spacing_rods) (callbacks . ((stencil . ,Hyphen_spanner::print))) (Y-extent . (0 . 0)) (meta . ((class . Spanner) @@ -904,8 +905,8 @@ (MultiMeasureRestNumber . ( - (callbacks . ((stencil . ,Text_interface::print))) - (spacing-procedure . ,Multi_measure_rest::set_spacing_rods) + (callbacks . ((springs-and-rods . ,Multi_measure_rest::set_spacing_rods) + (stencil . ,Text_interface::print))) (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self ,Self_alignment_interface::centered_on_other_axis_parent)) (Y-offset-callbacks . (,Side_position_interface::aligned_side)) @@ -1057,11 +1058,11 @@ . ((slur-details . ,default-slur-details) (callbacks . ((control-points . ,Slur::calc_control_points) (direction . ,Slur::calc_direction) + (springs-and-rods . ,Spanner::set_spacing_rods) (stencil . ,Slur::print) )) (thickness . 1.1) - (spacing-procedure . ,Spanner::set_spacing_rods) (minimum-length . 1.5) (Y-extent-callback . ,Slur::height) (height-limit . 2.0) @@ -1088,8 +1089,8 @@ (PercentRepeat . ( - (spacing-procedure . ,Multi_measure_rest::set_spacing_rods) - (callbacks . ((stencil . ,Multi_measure_rest::percent))) + (callbacks . ((springs-and-rods . ,Multi_measure_rest::set_spacing_rods) + (stencil . ,Multi_measure_rest::percent))) (slope . 1.0) (thickness . 0.48) (font-encoding . fetaMusic) @@ -1229,7 +1230,8 @@ (SeparatingGroupSpanner . ( - (spacing-procedure . ,Separating_group_spanner::set_spacing_rods) + (callbacks . ((springs-and-rods . ,Separating_group_spanner::set_spacing_rods) + )) (meta . ((class . Spanner) (interfaces . (only-prebreak-interface spacing-interface @@ -1239,10 +1241,10 @@ . ((slur-details . ,default-slur-details) (callbacks . ((control-points . ,Slur::calc_control_points) (direction . ,Slur::calc_direction) + (springs-and-rods . ,Spanner::set_spacing_rods) (stencil . ,Slur::print) )) (thickness . 1.0) - (spacing-procedure . ,Spanner::set_spacing_rods) (minimum-length . 1.5) (Y-extent-callback . ,Slur::height) ; Slur::height) @@ -1253,7 +1255,7 @@ (SpacingSpanner . ( - (spacing-procedure . ,Spacing_spanner::set_springs) + (callbacks . ((springs-and-rods . ,Spacing_spanner::set_springs))) (grace-space-factor . 0.6) (shortest-duration-space . 2.0) (spacing-increment . 1.2) -- 2.39.5