2005-10-16 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * 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
}
}
- 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.
"damping "
"details "
"direction "
- "dir-function "
"flag-width-function "
"gap "
"gap-count "
"meta "
"minimum-X-extent "
"minimum-Y-extent "
- "spacing-procedure "
+ "springs-and-rods "
"staff-symbol "
"stencil "
"transparent"
"note-names "
"glyph-name-procedure "
"accidental-grob "
- "stem-attachment"
+ "stem-attachment "
"style "
);
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")))
/* 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))
/* 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
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))
"flag-style "
"french-beaming "
"length "
+ "length-fraction "
"neutral-direction "
"no-stem-extend "
"note-heads "
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");
}
}
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)
'''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.
(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
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
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
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.")
;; 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.
;;
(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)
(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)
. (
(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)
(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))))))
(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)
(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))
. ((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)
(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)
(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
. ((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)
(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)