From 9ba3eee5fc2bb188896a621825188e9c4070c511 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 21 Aug 2005 12:34:52 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 4 + input/regression/tie-single.ly | 40 +++++++ lily/include/stem.hh | 1 + lily/stem.cc | 39 +++++-- lily/tie.cc | 188 --------------------------------- scm/define-grobs.scm | 2 +- 6 files changed, 75 insertions(+), 199 deletions(-) create mode 100644 input/regression/tie-single.ly diff --git a/ChangeLog b/ChangeLog index 38db592622..aa26e9e6d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,10 @@ 2005-08-21 Han-Wen Nienhuys + * input/regression/tie-single.ly: new file. + + * scm/define-grobs.scm (all-grob-descriptions): height limit .75 + * lily/midi-item.cc (name): new method. * lily/staff-performer.cc (acknowledge_audio_element): use diff --git a/input/regression/tie-single.ly b/input/regression/tie-single.ly new file mode 100644 index 0000000000..e71b9b89a3 --- /dev/null +++ b/input/regression/tie-single.ly @@ -0,0 +1,40 @@ +\header +{ + texidoc = "Formatting for isolated ties. + Things to note: + +@itemize @bullet +@item short ties are in spaces +@item long ties cross staff lines +@item ties avoid flags of left stems. +@item ties avoid dots of left notes. + +@item short ties are vertically centered in the space, as well those +that otherwise don't fit in a space + +@end itemize +" + +} +\layout { + indent = #0.0 + raggedright = ##t +} + +frag = +\relative c'' { + c16 c2...~ c16 ~ c2... | + c4~c8 c8~c16 c16~c32 c16.~[ c64]~ c64[ c8..] | +} + + +\new Staff \with { + \remove "Time_signature_engraver" +} { + \stemUp + + \frag \break + \transpose c d \frag\break + \transpose c e \frag + +} diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 6c97b11311..3e498c2a36 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -38,6 +38,7 @@ public: static void position_noteheads (Grob *); static Real stem_end_position (Grob *); static Stencil flag (Grob *); + static Stencil get_translated_flag (Grob*); static bool has_interface (Grob *); static void set_spacing_hints (Grob *); diff --git a/lily/stem.cc b/lily/stem.cc index c1ecd82d85..bd42bbb1e9 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -528,9 +528,15 @@ Stem::height (SCM smob, SCM ax) Stencil Stem::flag (Grob *me) { - /* TODO: maybe property stroke-style should take different values, - e.g. "" (i.e. no stroke), "single" and "double" (currently, it's - '() or "grace"). */ + int log = duration_log (me); + if (log < 3 + || unsmob_grob (me->get_object ("beam"))) + return Stencil (); + + /* + TODO: maybe property stroke-style should take different values, + e.g. "" (i.e. no stroke), "single" and "double" (currently, it's + '() or "grace"). */ String flag_style; SCM flag_style_scm = me->get_property ("flag-style"); @@ -566,7 +572,7 @@ Stem::flag (Grob *me) char dir = (get_direction (me) == UP) ? 'u' : 'd'; String font_char = flag_style - + to_string (dir) + staffline_offs + to_string (duration_log (me)); + + to_string (dir) + staffline_offs + to_string (log); Font_metric *fm = Font_interface::get_default_font (me); Stencil flag = fm->find_by_name ("flags." + font_char); if (flag.is_empty ()) @@ -694,17 +700,30 @@ Stem::print (SCM smob) Stencil ss = Lookup::round_filled_box (b, blot); mol.add_stencil (ss); - if (!get_beam (me) && abs (duration_log (me)) > 2) + mol.add_stencil (get_translated_flag (me)); + + return mol.smobbed_copy (); +} + +Stencil +Stem::get_translated_flag (Grob *me) +{ + Stencil fl = flag (me); + if (!fl.is_empty ()) { - Stencil fl = flag (me); - fl.translate_axis (stem_y[d] * half_space - d * blot / 2, Y_AXIS); + Direction d = get_direction (me); + Real blot + = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")); + Real stem_width = thickness (me); + Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5; + Real y2 = stem_end_position (me); + fl.translate_axis (y2 * half_space - d * blot / 2, Y_AXIS); fl.translate_axis (stem_width / 2, X_AXIS); - mol.add_stencil (fl); } - - return mol.smobbed_copy (); + return fl; } + /* move the stem to right of the notehead if it is up. */ diff --git a/lily/tie.cc b/lily/tie.cc index 36e97842f5..78caff4188 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -124,194 +124,6 @@ Tie::set_direction (Grob *me) } } -/* - TODO: we should also use thickness for computing the clearance - between head and tie. Very thick ties will now touch the note head. -*/ -SCM -Tie::get_control_points (SCM smob) -{ - Spanner *me = unsmob_spanner (smob); - Direction headdir = CENTER; - if (head (me, LEFT)) - headdir = LEFT; - else if (head (me, RIGHT)) - headdir = RIGHT; - else - { - programming_error ("tie without heads"); - me->suicide (); - return SCM_EOL; - } - - set_direction (me); - - Direction dir = get_grob_direction (me); - - Real staff_space = Staff_symbol_referencer::staff_space (me); - - Real x_gap_f = robust_scm2double (me->get_property ("x-gap"), 0); - - Grob *l = me->get_bound (LEFT); - Grob *r = me->get_bound (RIGHT); - - Grob *commonx = me->common_refpoint (l, X_AXIS); - commonx = me->common_refpoint (r, X_AXIS); - - Real left_x; - - /* - the tie has to be long enough to be visible, but should not go - through key sigs. In the 1.5 series the pref.matter - note - distance is fixed , so this won't be a problem anymore. - */ - Real lambda = 0.9; - - if (Note_head::has_interface (l)) - { - Real where = RIGHT; - - /* - This correction is due te the shape of the black note head. - */ - if (Rhythmic_head::duration_log (l) == 2) - where += dir * 0.2; - left_x = l->extent (l, X_AXIS).linear_combination (where) - + x_gap_f; - } - else - left_x = l->extent (l, X_AXIS).linear_combination (lambda); - - Real width; - if (Note_head::has_interface (l) && Note_head::has_interface (r)) - { - width - = + r->extent (commonx, X_AXIS)[LEFT] - - l->extent (commonx, X_AXIS)[RIGHT] - -2 * x_gap_f; - } - else - { - if (Note_head::has_interface (l)) - width = r->relative_coordinate (commonx, X_AXIS) - - l->extent (commonx, X_AXIS)[RIGHT] - - 2 * x_gap_f; - else - width - = -l->extent (commonx, X_AXIS).linear_combination (lambda) - + r->extent (commonx, X_AXIS)[LEFT] - - 2 * x_gap_f; - } - - SCM details = me->get_property ("details"); - - SCM lim // groetjes aan de chirurgendochter. - = scm_assq (ly_symbol2scm ("height-limit"), details); - - Real h_inf = scm_to_double (scm_cdr (lim)) * staff_space; - Real r_0 = scm_to_double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), details))); - - Bezier b = slur_shape (width, h_inf, r_0); - - /* - I think this better, particularly for small ties. It always allows - the user to move ties if they seem in the wrong place - - TODO: what if 2 heads have different size. - - */ - - Real ypos = Tie::get_position (me) * staff_space / 2 - + dir * scm_to_double (me->get_property ("y-offset"));; - - /* - Make sure we don't start on a dots - */ - if (Note_head::has_interface (l) && Rhythmic_head::get_dots (l)) - { - Grob *dots = Rhythmic_head::get_dots (l); - if (fabs (staff_space * Staff_symbol_referencer::get_position (dots) / 2 - - ypos) < 0.5) - ypos += 0.5 * dir; - } - - /* - todo: prevent ending / staffline collision. - - todo: tie / stem collision - */ - - b = slur_shape (width, h_inf, r_0); - b.scale (1, dir); - b.translate (Offset (left_x, ypos)); - - /* - Avoid colliding of the horizontal part with stafflines. - - - TODO: redo this, heuristic is half-baken, and ties often look ugly - as a result. - - TODO: doesn't work when on staff with even number of lines. - */ - Array horizontal (b.solve_derivative (Offset (1, 0))); - if (horizontal.size ()) - { - /* - ugh. Doesnt work for non-horizontal curves. - */ - Real y = b.curve_point (horizontal[0])[Y_AXIS]; - - Real ry = rint (y / staff_space) * staff_space; - Real diff = ry - y; - Real newy = y; - - Real clear = staff_space * scm_to_double (me->get_property ("staffline-clearance")); - - if (fabs (y) - <= Staff_symbol_referencer::staff_radius (me) * staff_space + clear - && fabs (diff) < clear) - { - Real y1 = ry + clear; - Real y2 = ry - clear; - - /* - ugh, we shove the 0.5 out of our sleeves. - - Any way. This test is to make sure that staffline - collision avoidance does not result in completely flat - ties. - */ - if (fabs (y1 - ypos) < 0.5) - y1 = y2; - else if (fabs (y2 - ypos) < 0.5) - y2 = y1; - - newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2; - - // newy = ry - 0.5 * staff_space * sign (diff) ; - - /* - we don't want horizontal ties - */ - if (fabs (newy - b.control_[0][Y_AXIS]) < 1e-2) - newy = newy + dir * staff_space; - } - - Real y0 = b.control_ [0][Y_AXIS]; - b.control_[2][Y_AXIS] - = b.control_[1][Y_AXIS] - = (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0; - } - else - programming_error ("tie is nowhere horizontal"); - - SCM controls = SCM_EOL; - for (int i = 4; i--;) - controls = scm_cons (ly_offset2scm (b.control_[i]), controls); - return controls; -} - MAKE_SCHEME_CALLBACK (Tie, print, 1); SCM Tie::print (SCM smob) diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 12e2b78244..561c4d8832 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1440,7 +1440,7 @@ (staffline-clearance . 0.35) (details . ((ratio . 0.333) (height-limit . 1.0))) (thickness . 1.0) - (x-gap . -0.1) +; (x-gap . -0.1) (y-offset . 0.6) (minimum-length . 2.5) (meta . ((class . Spanner) -- 2.39.2