]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/tie.cc: remove minimum-length
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Aug 2005 21:47:18 +0000 (21:47 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Aug 2005 21:47:18 +0000 (21:47 +0000)
* lily/tie.cc (get_control_points): rewrite. Put short ties in
staff-spaces, make long ties cross staff lines. Avoid flags and dots.

lily/include/tie.hh
lily/tie-column.cc
lily/tie.cc

index d7c4312e7bae442e8ebd2a2d2f4b77c9b2af9f8d..bb6066a53933e58b4d1cec0bdb2279aac5aae8dc 100644 (file)
 #include "lily-guile.hh"
 #include "lily-proto.hh"
 
+
+struct Tie_configuration
+{
+  int position_;
+  Direction dir_;
+  Interval attachment_x_;
+  Real edge_y_;
+  
+  Tie_configuration ()
+  {
+    dir_ = CENTER;
+    position_ = 0;
+  }
+  
+  static int compare (Tie_configuration const &a,
+                     Tie_configuration const &b);
+};
+
 class Tie
 {
 public:
@@ -24,8 +42,10 @@ public:
   static Real get_position (Grob *);
   static Direction get_default_dir (Grob *);
   static SCM get_control_points (SCM);
+  static SCM get_configuration (SCM);
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
 };
 
+
 #endif // TIE_HH
index 082cc619df1afa89917eda3ced56ae6762827601..31e1daf1f8f4570336d04c32a7dfcfc97219d053 100644 (file)
@@ -51,6 +51,7 @@ tie_compare (Grob *const &s1,
   return sign (Tie::get_position (s1) - Tie::get_position (s2));
 }
 
+#if 0
 /*
   Werner:
 
@@ -133,6 +134,7 @@ Tie_column::werner_directions (Grob *me)
 
   return;
 }
+#endif
 
 MAKE_SCHEME_CALLBACK (Tie_column, after_line_breaking, 1);
 SCM
@@ -169,3 +171,4 @@ ADD_INTERFACE (Tie_column, "tie-column-interface",
               "Object that sets directions of multiple ties in a tied chord",
               "direction");
 
+
index f596a7c71e027e808f6c2dd54fc4b77431d759a4..0a968718c181d0631cc1c52c78f2b7f1da6fc857 100644 (file)
@@ -126,9 +126,12 @@ Tie::set_direction (Grob *me)
 
 
 SCM
-Tie::get_control_points (SCM smob)
+Tie::get_configuration (Grob *me_grob,
+                       Grob **common,
+                       Tie_configuration *conf)
 {
-  Spanner *me = unsmob_spanner (smob);
+  Spanner *me = dynamic_cast<Spanner*> (me_grob);
+  
   if (!head (me, LEFT) && !head (me, RIGHT))
     {
       programming_error ("tie without heads");
@@ -144,16 +147,6 @@ Tie::get_control_points (SCM smob)
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Real staff_position = tie_position;
 
-  Grob *common[NO_AXES];
-  for (int a = X_AXIS; a < NO_AXES; a++)
-    {
-      Axis ax ((Axis) a); 
-      common[ax] = me->get_bound (LEFT)->common_refpoint (me, ax); 
-      common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); 
-    }
-
-  Interval attachments;
-
   Direction d = LEFT;
   Real gap = robust_scm2double (me->get_property ("x-gap"), 0.2);
   do
@@ -296,15 +289,15 @@ Tie::get_control_points (SCM smob)
          Offset edge = b.curve_point (0.0);
 
          Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0;
-         b.translate (Offset (0,
-                              staff_position * staff_space * 0.5
-                              - center));
+
+         conf->edge_y_ = staff_position * staff_space * 0.5
+           - center;
        }
       else
        {
-         b.translate (Offset (0,
-                              (staff_position - dir) * staff_space * 0.5
-                              + dir * 0.2 * staff_space));
+         conf->edge_y_ = 
+           (staff_position - dir) * staff_space * 0.5
+           + dir * 0.2 * staff_space;
        }
     }
   else
@@ -312,20 +305,59 @@ Tie::get_control_points (SCM smob)
       Real where = 0.5 * dir;
       
       Real rounding_dy = (where - middle[Y_AXIS]);
-      b.translate (Offset (0,
-                          0.5 * staff_position * staff_space + rounding_dy));
+      conf->edge_y_ = 0.5 * staff_position * staff_space + rounding_dy;
 
       if (dir * b.curve_point (0.0)[Y_AXIS] <
          dir * tie_position * 0.5 * staff_space)
-       b.translate (Offset (0, staff_space * dir))
+       conf->edge_y_ +=  staff_space * dir
     }
+
+  conf->position_ = staff_position;
+  conf->dir_ = dir;
+  conf->attachment_x_ = attachments;
+}
+
+
+SCM
+Tie::get_control_points (SCM smob)
+{
+  Spanner *me = unsmob_spanner (smob);
+
+  Grob *common[NO_AXES] = {
+    0, 0
+  };
+  for (int a = X_AXIS; a < NO_AXES; a++)
+    {
+      Axis ax ((Axis) a); 
+      common[ax] = me->get_bound (LEFT)->common_refpoint (me, ax); 
+      common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); 
+    }
+  
+  Tie_configuration conf;
+  get_configuration (me, common, &conf);
   
-  b.translate (Offset (attachments[LEFT]
+  SCM details = me->get_property ("details");
+  SCM limit
+    = scm_assq (ly_symbol2scm ("height-limit"), details);
+
+  Real h_inf = robust_scm2double (scm_cdr (limit), 0.75) * staff_space;
+  Real r_0 = robust_scm2double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"),
+                                                  details)),
+                               .333);
+
+  Bezier b = slur_shape (conf->attachment_x_.length(),
+                        h_inf, r_0);
+  b.scale (1, conf->dir_);
+  
+  Bezier b;
+  
+  b.translate (Offset (conf->attachment_x_[LEFT]
                       - me->relative_coordinate (common[X_AXIS], X_AXIS), 0));
   
   SCM controls = SCM_EOL;
   for (int i = 4; i--;)
     controls = scm_cons (ly_offset2scm (b.control_[i]), controls);
+
   return controls;
 }
 
@@ -388,3 +420,6 @@ ADD_INTERFACE (Tie,
               "head-pair "
               "thickness "
               "x-gap ");
+
+
+