]> git.donarmstrong.com Git - lilypond.git/commitdiff
(context_prop_spec): check grob name for
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 14 Jul 2004 22:23:02 +0000 (22:23 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 14 Jul 2004 22:23:02 +0000 (22:23 +0000)
alphanumericness..

ChangeLog
input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly
input/test/new-slur.ly
lily/new-slur.cc

index 576adb96f641190d2ef3962e7f46d2f69a0c6fdf..5c05f0d1d0c0d0bfba3870b7a45c97dcf20e3079 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
+2004-07-15  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/new-slur.cc (score_slopes): strong sloping score only when
+       stems point in same dir. 
+
 2004-07-14  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * input/mutopia/W.A.Mozart/mozart-hrn3-rondo.ly (rondo): bugfix
+       for beam start.
+
        * lily/parser.yy (context_prop_spec): check grob name for
        alphanumericness..
 
index 263cb0caeb28088a6f3ef4470bf14ea79453898b..31503fd4d7e82303df1feab0cf01bf10b583564e 100644 (file)
@@ -164,7 +164,7 @@ rondo =     \relative c'
        \cresc g'2.  bes,2.
        a4.  b16[ c d e f g]
        a4. f4 d8
-       [\endcresc c8\f g' e]  c[ g e]
+       \endcresc c8[\f g' e]  c[ g e]
         c[ e' c]   g[ e c]
        g4 r8  g''8[ e c]
 
index e61cc49983ab0d86568df21da1d2c96014f28544..8b674c76d05058c35829cb485c0232d57121d662 100644 (file)
@@ -8,8 +8,7 @@
     \override Slur #'print-function = #New_slur::print     
     \override Slur #'height = ##f
 
-    f'=''16( e)
-    d( c)
+    f'=''16( e)    d( c)
     c'=''2(~c8 d16 c b8 a)
     f='4
     <c g>4 ( f <g b>)
@@ -21,5 +20,6 @@
     <g b>_( \stemDown g \stemBoth  <b d>)
     c,^( c'' c) 
     c,,^( c'')
-    c,,^( c') 
+    c,,^( c')
+    
 }
index 100dd6d92e10ee606614684728714b241c170fb7..4a6234339f8aaa114e098feeab3b74153b75d1ba 100644 (file)
@@ -23,6 +23,7 @@
 #include "slur.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
+#include "staff-symbol.hh"
 #include "stem.hh"
 #include "stencil.hh"
 #include "warn.hh"
@@ -66,7 +67,9 @@ const Real HEAD_STRICT_FREE_SPACE = 0.2;
 
 struct Slur_score {
   Drul_array<Offset> attachment_;
-  Real  score_;
+  Real score_;
+  Bezier curve_;
+
 #if DEBUG_SLUR_QUANTING
   String score_card_;
 #endif
@@ -90,7 +93,7 @@ public:
   static bool  has_interface (Grob*);
   static Array<Offset> get_encompass_offsets (Grob *me);
   static Bezier get_curve (Grob *me);
-  static Bezier get_bezier (Grob *me, Drul_array<Offset>);
+  static Bezier get_bezier (Grob *me, Drul_array<Offset>,Real,Real);
   static Direction get_default_dir (Grob *me);
   DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
   DECLARE_SCHEME_CALLBACK (height, (SCM,SCM));
@@ -111,7 +114,7 @@ New_slur::set_interface (Grob*me)
 {
   /* Copy to mutable list. */
   me->set_property ("attachment",
-                        ly_deep_copy (me->get_property ("attachment")));
+                   ly_deep_copy (me->get_property ("attachment")));
 }
 
 void
@@ -212,16 +215,10 @@ New_slur::after_line_breaking (SCM smob)
 }
 
 Bezier
-New_slur::get_bezier (Grob *me,  Drul_array<Offset> extremes)
+New_slur::get_bezier (Grob *me, Drul_array<Offset> extremes,
+                     Real r_0,
+                     Real h_inf)
 {
-  //  SCM details = me->get_property ("details");
-  SCM h_inf_scm = me->get_property ("height-limit");
-  SCM r_0_scm = me->get_property ("ratio");
-  Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
-
-  Real r_0 = robust_scm2double (r_0_scm, 1);
-  Real h_inf = staff_space * ly_scm2double (h_inf_scm);
-
   Array<Offset> encompasses;
   encompasses.push (extremes[LEFT]);
   encompasses.push (extremes[RIGHT]);
@@ -275,17 +272,33 @@ New_slur::set_end_points (Grob *me)
       Grob *stem = Note_column::get_stem (extremes[d]);
       Grob * h = Stem::extremal_heads (stem)[dir];
      
-      Real y = h->extent (common[Y_AXIS], Y_AXIS)[dir];
+      Real y;
+
+      if (stem
+       && get_grob_direction (stem) == dir
+       && Stem::get_beam (stem))
+       {
+         y = stem->extent (common[Y_AXIS], Y_AXIS)[dir];
+       }
+      else
+       {
+         y = h->extent (common[Y_AXIS], Y_AXIS)[dir];
+       }
 
       y += dir * 0.5 * staff_space;
-      int p = Staff_symbol_referencer::get_position (h) + 2*dir;
+
+      Grob * staff = Staff_symbol_referencer::get_staff_symbol (h);
+      Real pos = 2.0 * (y - staff->relative_coordinate (common[Y_AXIS], Y_AXIS)) / Staff_symbol::staff_space (staff);
+
+      
+           /*
+             start off staffline.
+           */
+      if (fabs (pos - round (pos)) < 0.2
+         && Staff_symbol_referencer::on_staffline (h, (int) rint (pos)))
+           y += staff_space * dir / 10 ;         
 
       
-      if (Staff_symbol_referencer::on_staffline (h, p))
-       /*
-         start off staffline.
-        */
-       y += staff_space * dir / 10 ;
       
       Grob * fh = Note_column::first_head (extremes[d]);
       Real x = fh->extent (common[X_AXIS],  X_AXIS).linear_combination (CENTER);
@@ -342,7 +355,16 @@ New_slur::set_end_points (Grob *me)
       os[LEFT][Y_AXIS] += incr;          
     }
   
-
+  {
+    Real r_0 = robust_scm2double (me->get_property ("ratio"), 1);
+    Real h_inf = staff_space * ly_scm2double (me->get_property ("height-limit"));
+    for (int i = scores.size(); i-- ;)
+      {
+       scores[i].curve_ = get_bezier (me, scores[i].attachment_,
+                                      r_0, h_inf);
+      }
+  }
+  
   score_encompass (me, common, base_attachment, &scores);
   score_slopes (me, common, base_attachment, &scores);
 
@@ -357,7 +379,7 @@ New_slur::set_end_points (Grob *me)
        }
     }
   
-  Bezier b (get_bezier (me, scores.size () ? scores[opt_idx].attachment_ : base_attachment));
+  Bezier const &b =  scores[opt_idx].curve_;
   
   SCM controls = SCM_EOL;
   for (int i = 4; i--;)
@@ -399,7 +421,7 @@ New_slur::score_encompass (Grob * me,  Grob *common[], Drul_array<Offset> base_a
   
   for (int i =0 ; i < scores->size (); i++)
     {
-      Bezier bez (get_bezier (me, scores->elem (i).attachment_));
+      Bezier const &bez (scores->elem (i).curve_);
       Real demerit =0.;
       for (int j = 0; j < infos.size(); j++)
        {
@@ -455,17 +477,17 @@ New_slur::score_slopes (Grob * me,  Grob *common[], Drul_array<Offset> base_atta
   Drul_array<Real> ys;
 
   Direction d = LEFT;
+  Drul_array<Direction> stem_dirs;
   do {
     Grob *stem = Note_column::get_stem (extremes [d]);
     ys[d] = Stem::extremal_heads (stem)[Direction (dir)]
       ->relative_coordinate (common[Y_AXIS], Y_AXIS);
+
+    stem_dirs[d] = get_grob_direction (stem);
   } while (flip (&d) != LEFT);
 
 
   Real dy = ys[RIGHT] - ys[LEFT];
-
   for (int i =0 ; i < scores->size (); i++)
     {
       Real slur_dy = (*scores)[i].attachment_[RIGHT][Y_AXIS]
@@ -473,14 +495,21 @@ New_slur::score_slopes (Grob * me,  Grob *common[], Drul_array<Offset> base_atta
 
       Real demerit = 0.0;
 
-      demerit += STEEPER_SLOPE_FACTOR *  (dir * (fabs (slur_dy) - fabs (dy)) >? 0);
+
+      if (stem_dirs[LEFT] == stem_dirs[RIGHT])
+       demerit += STEEPER_SLOPE_FACTOR *  (dir * (fabs (slur_dy) - fabs (dy)) >? 0);
       if (sign (dy) == 0 &&
          sign (slur_dy) != 0)
        demerit += NON_HORIZONTAL_PENALTY;
+
+       
+
       if (sign (dy)
          && sign (slur_dy)
          && sign (slur_dy) != sign (dy))
-       demerit += SAME_SLOPE_PENALTY;
+       demerit +=
+         (stem_dirs[LEFT] * stem_dirs[RIGHT] == -1)
+         ? SAME_SLOPE_PENALTY/10 : SAME_SLOPE_PENALTY;
       
 #if DEBUG_SLUR_QUANTING
       (*scores)[i].score_card_ += to_string ("S%.2f",d);