From 9d300696f59bce92dee50032690d54437f2270e3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 4 Nov 2004 22:53:44 +0000 Subject: [PATCH] * lily/beam.cc (rest_collision_callback): use local beam multiplicity. * input/regression/stem-stemlet.ly: new file. * lily/stem.cc (add_head): store rests as well. * scm/define-grob-properties.scm (all-user-grob-properties): add stemlet-length * lily/stem.cc: store rests as well. --- ChangeLog | 16 +++++ Documentation/topdocs/NEWS.texi | 8 +++ VERSION | 2 +- input/regression/stem-stemlet.ly | 14 ++++ lily/beam.cc | 10 ++- lily/stem.cc | 114 ++++++++++++++++++++----------- scm/define-grob-properties.scm | 2 + 7 files changed, 123 insertions(+), 43 deletions(-) create mode 100644 input/regression/stem-stemlet.ly diff --git a/ChangeLog b/ChangeLog index 12289c3da0..81132e82fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2004-11-04 Han-Wen Nienhuys + + * lily/beam.cc (rest_collision_callback): use local beam + multiplicity. + + * input/regression/stem-stemlet.ly: new file. + + * lily/stem.cc (add_head): store rests as well. + + * scm/define-grob-properties.scm (all-user-grob-properties): add + stemlet-length + + * lily/stem.cc: store rests as well. + + * input/regression/new-slur.ly: mention forcing. + 2004-11-04 Werner Lemberg * Documentation/user/*: A new round of layout fixes and document diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index 4b6390bd57..a3fc5a9c34 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -4,6 +4,14 @@ @node Top, , , @top +@unnumbered New features in 2.5 since 2.4 + +@itemize @bullet +@item Stemlets, short stems over beamed rests, have been added. + +@end itemize + + @unnumbered New features in 2.4 since 2.2 @itemize @bullet diff --git a/VERSION b/VERSION index 7395742c6f..7a3bd85580 100644 --- a/VERSION +++ b/VERSION @@ -2,5 +2,5 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=5 PATCH_LEVEL=0 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=hwn1 diff --git a/input/regression/stem-stemlet.ly b/input/regression/stem-stemlet.ly new file mode 100644 index 0000000000..72c7433603 --- /dev/null +++ b/input/regression/stem-stemlet.ly @@ -0,0 +1,14 @@ +\header { + + texidoc = "Stemlets are small stems under beams over rests. Their +length can be set with @code{stemlet-length}." + +} + +\version "2.5.0" +\layout { raggedright = ##t } + +\relative { + \override Stem #'stemlet-length = #0.75 + c8[ r8 c16 r16 c8] +} diff --git a/lily/beam.cc b/lily/beam.cc index dcf2e1893a..b8d5018927 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -1350,8 +1350,13 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) Real beam_translation = get_beam_translation (beam); Real beam_thickness = Beam::get_thickness (beam); + + /* + TODO: this is not strictly correct for 16th knee beams. + */ + int beam_count = + Stem::beam_multiplicity (stem).length() + 1; - int beam_count = get_direction_beam_count (beam, d); Real height_of_my_beams = beam_thickness / 2 + (beam_count - 1) * beam_translation; Real beam_y = stem_y - d * height_of_my_beams; @@ -1360,7 +1365,8 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis) Real rest_dim = rest->extent (common_y, Y_AXIS)[d]; Real minimum_distance = - staff_space * robust_scm2double (rest->get_property ("minimum-distance"), 0.0); + + staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0) + + robust_scm2double (rest->get_property ("minimum-distance"), 0.0)); Real shift = d * ( ((beam_y - d * minimum_distance) - rest_dim) * d @@ -179,9 +180,7 @@ Stem::extremal_heads (Grob *me) extpos[DOWN] = inf; extpos[UP] = -inf; - Drul_array exthead; - exthead[LEFT] = exthead[RIGHT] =0; - + Drul_array exthead (0, 0); for (SCM s = me->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s)) { @@ -202,7 +201,7 @@ Stem::extremal_heads (Grob *me) } static int -icmp (int const &a, int const &b) +integer_compare (int const &a, int const &b) { return a - b; } @@ -221,7 +220,7 @@ Stem::note_head_positions (Grob *me) ps.push (p); } - ps.sort (icmp); + ps.sort (integer_compare); return ps; } @@ -231,15 +230,20 @@ Stem::add_head (Grob *me, Grob *n) n->set_property ("stem", me->self_scm ()); n->add_dependency (me); - /* TODO: why not store Rest pointers? */ if (Note_head::has_interface (n)) Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-heads"), n); + else if (Rest::has_interface (n)) + Pointer_group_interface::add_grob (me, ly_symbol2scm ("rests"), n); } bool Stem::is_invisible (Grob *me) { - return !(head_count (me) + Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"), + 0.0); + + return !((head_count (me) + || stemlet_length > 0.0) && scm_to_int (me->get_property ("duration-log")) >= 1); } @@ -357,7 +361,7 @@ Stem::get_default_stem_end_position (Grob *me) /* Very gory: add myself to the X-support of the parent, which should be a dot-column. */ - if (dir * (st + flagy - dp) < 0.5) + if (dir * (st + flagy - dp) < 0.5) { Grob *par = dots->get_parent (X_AXIS); @@ -479,8 +483,6 @@ Stem::before_line_breaking (SCM smob) stem_end_position (me); // ugh. Trigger direction calc. position_noteheads (me); } - else - me->set_property ("print-function", SCM_EOL); return SCM_UNSPECIFIED; } @@ -633,24 +635,47 @@ Stem::print (SCM smob) Stencil mol; Direction d = get_direction (me); + Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"), + 0.0); + bool stemlet = stemlet_length > 0.0; + /* TODO: make the stem start a direction ? This is required to avoid stems passing in tablature chords. */ - Grob *lh = to_boolean (me->get_property ("avoid-note-head")) - ? last_head (me) : lh = first_head (me); + Grob *lh = + to_boolean (me->get_property ("avoid-note-head")) + ? last_head (me) + : lh = first_head (me); + Grob *beam = get_beam (me); - if (!lh) + if (!lh && !stemlet) return SCM_EOL; + if (stemlet && !beam) + return SCM_EOL; + if (is_invisible (me)) return SCM_EOL; - Real y1 = Staff_symbol_referencer::get_position (lh); Real y2 = stem_end_position (me); + Real y1 = y2; + Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5; - Interval stem_y (y1 ? y1); - // dy? - Real dy = Staff_symbol_referencer::staff_space (me) * 0.5; + if (lh) + y2 = Staff_symbol_referencer::get_position (lh); + else if (stemlet) + { + Real beam_translation = Beam::get_beam_translation (beam); + Real beam_thickness = Beam::get_thickness (beam); + int beam_count = beam_multiplicity (me).length () + 1; + + y2 -= d + * (0.5 * beam_thickness + + beam_translation * (0 >? (beam_count - 1)) + + stemlet_length) / half_space; + } + + Interval stem_y (y1 ? y1); if (Grob *hed = support_head (me)) { @@ -661,7 +686,7 @@ Stem::print (SCM smob) Real y_attach = Note_head::stem_attachment_coordinate (hed, Y_AXIS); y_attach = head_height.linear_combination (y_attach); - stem_y[Direction (-d)] += d * y_attach/dy; + stem_y[Direction (-d)] += d * y_attach/half_space; } @@ -671,7 +696,7 @@ Stem::print (SCM smob) me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); Box b = Box (Interval (-stem_width/2, stem_width/2), - Interval (stem_y[DOWN]*dy, stem_y[UP]*dy)); + Interval (stem_y[DOWN]*half_space, stem_y[UP]*half_space)); Stencil ss = Lookup::round_filled_box (b, blot); mol.add_stencil (ss); @@ -679,7 +704,7 @@ Stem::print (SCM smob) if (!get_beam (me) && abs (duration_log (me)) > 2) { Stencil fl = flag (me); - fl.translate_axis (stem_y[d]*dy - d * blot/2, Y_AXIS); + fl.translate_axis (stem_y[d]*half_space - d * blot/2, Y_AXIS); fl.translate_axis (stem_width/2, X_AXIS); mol.add_stencil (fl); } @@ -697,28 +722,36 @@ Stem::off_callback (SCM element_smob, SCM) Grob *me = unsmob_grob (element_smob); Real r = 0.0; - if (head_count (me)) - if (Grob *f = first_head (me)) - { - Interval head_wid = f->extent (f, X_AXIS); - Real attach = 0.0; + if (Grob *f = first_head (me)) + { + Interval head_wid = f->extent (f, X_AXIS); + Real attach = 0.0; - if (is_invisible (me)) - attach = 0.0; - else + if (is_invisible (me)) + attach = 0.0; + else attach = Note_head::stem_attachment_coordinate (f, X_AXIS); - Direction d = get_direction (me); - Real real_attach = head_wid.linear_combination (d * attach); - r = real_attach; + Direction d = get_direction (me); + Real real_attach = head_wid.linear_combination (d * attach); + r = real_attach; - /* If not centered: correct for stem thickness. */ - if (attach) - { - Real rule_thick = thickness (me); - r += - d * rule_thick * 0.5; - } - } + /* If not centered: correct for stem thickness. */ + if (attach) + { + Real rule_thick = thickness (me); + r += - d * rule_thick * 0.5; + } + } + else if (scm_is_number (me->get_property ("stemlet-length"))) + { + SCM rests = me->get_property ("rests"); + if (scm_is_pair (rests)) + { + Grob * rest = unsmob_grob (scm_car (rests)); + r = rest->extent (rest, X_AXIS).center (); + } + } return scm_make_real (r); } @@ -880,6 +913,7 @@ ADD_INTERFACE (Stem, "stem-interface", "Rests and whole notes have invisible stems.", "tremolo-flag french-beaming " "avoid-note-head thickness " + "stemlet-length rests " "stem-info beamed-lengths beamed-minimum-free-lengths " "beamed-extreme-minimum-free-lengths lengths beam stem-shorten " "duration-log beaming neutral-direction stem-end-position " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 0740f9ece4..e58197fe78 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -417,6 +417,7 @@ expressed in global staffspace.") staff spaces, counted from the middle line.") (staffline-clearance ,ly:dimension? "How far away ties keep from staff lines.") + (stemlet-length ,number? "How long should a stem over a rest be?") (stem-attachment-function ,procedure? "A function that calculates where a stem attaches to the note head? This is a fallback when this information is not specified in the font. The function takes a grob @@ -534,6 +535,7 @@ set, which grob to get the direction from .") (tie ,ly:grob? "") (staff-symbol ,ly:grob? "the staff symbol grob that we're in.") (rest ,ly:grob? "the staff symbol grob that we're in.") + (rests ,grob-list? "A list of rest objects.") (rest-collision ,ly:grob? "rest collision that a rest is in.") (accidental-grob ,ly:grob? "Accidental for this note.") (bars ,grob-list? "list of bar line pointers.") -- 2.39.5