]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Aug 2005 12:34:52 +0000 (12:34 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Aug 2005 12:34:52 +0000 (12:34 +0000)
ChangeLog
input/regression/tie-single.ly [new file with mode: 0644]
lily/include/stem.hh
lily/stem.cc
lily/tie.cc
scm/define-grobs.scm

index 38db59262265ff39ef8fa498bb7e90295092c28f..aa26e9e6d48737541b6c0c4eb3647aceb932709a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
 
 2005-08-21  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * 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 (file)
index 0000000..e71b9b8
--- /dev/null
@@ -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
+  
+}
index 6c97b11311dc37e4a26c213a219df7c89d775d6a..3e498c2a369bc980f7b3fd9ae416f984efebb5a7 100644 (file)
@@ -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 *);
 
index c1ecd82d8573cb409e2b3db427d82763fec97c4b..bd42bbb1e93e95b771158f1aa091a1b7f2accb48 100644 (file)
@@ -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.
 */
index 36e97842f5745236527b49229e04b9aa13c1881d..78caff41885fd3de965bc0941acc35b8de4c36fb 100644 (file)
@@ -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<Real> 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)
index 12e2b78244e24229b708d168653aedc1e8df87e7..561c4d8832e5ae1bc0b418307f02471744b74666 100644 (file)
        (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)