]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
patch::: 1.5.3.jcn1
[lilypond.git] / lily / beam.cc
index 901d56ab21bbb24f1e04b63c9745dbeacdf84ed8..48c81d14cf764266d1db2665f99b643dbf370376 100644 (file)
 /*
   [TODO]
 
-  * shorter! (now +- 1000 lines)
-  * less hairy code
+  -* shorter! (now +- 1000 lines)
+  
+  -* less hairy code
+  
   */
 
 
@@ -135,7 +137,7 @@ Beam::get_default_dir (Grob*me)
   /*
     If dir is not determined: get default
   */
-  return to_dir (me->get_grob_property ("default-neutral-direction"));
+  return to_dir (me->get_grob_property ("neutral-direction"));
 }
 
 
@@ -495,7 +497,7 @@ Beam::user_override (SCM smob)
   SCM s = me->get_grob_property ("staff-position");
   if (gh_number_p (s))
     {
-      Real y = gh_scm2double (s) * staff_space;
+      Real y = gh_scm2double (s) * staff_space * 0.5;
       me->set_grob_property ("y", gh_double2scm (y));
     }
 
@@ -503,7 +505,7 @@ Beam::user_override (SCM smob)
   s = me->get_grob_property ("height");
   if (gh_number_p (s))
     {
-      Real dy = gh_scm2double (s) * staff_space;
+      Real dy = gh_scm2double (s) * staff_space * 0.5;
       me->set_grob_property ("dy", gh_double2scm (dy));
     }
   
@@ -668,6 +670,13 @@ Beam::set_stem_lengths (Grob *me)
 
       Real stem_y = calc_stem_y_f (me, s, y, dy);
 
+      // doesn't play well with dvips
+      if (scm_definedp (ly_symbol2scm ("ps-testing"), SCM_UNDEFINED)
+         == SCM_BOOL_T)
+       if (Stem::get_direction (s) == Directional_element_interface::get (me))
+         stem_y += Stem::get_direction (s)
+           * gh_scm2double (me->get_grob_property ("thickness")) / 2;
+      
       /* caution: stem measures in staff-positions */
       Real id = me->relative_coordinate (common, Y_AXIS)
        - stems[i]->relative_coordinate (common, Y_AXIS);
@@ -760,7 +769,6 @@ Beam::stem_beams (Grob*me,Item *here, Item *next, Item *prev,
  (prev && ! (prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS))))
       programming_error ("Beams are not left-to-right");
 
-  Real staffline_f = me->paper_l ()->get_var ("stafflinethickness");
   int multiplicity = get_multiplicity (me);
 
   SCM space_proc = me->get_grob_property ("space-function");
@@ -770,13 +778,14 @@ Beam::stem_beams (Grob*me,Item *here, Item *next, Item *prev,
   Real interbeam_f = gh_scm2double (space) ;
     
   Real bdy = interbeam_f;
-  Real stemdx = staffline_f;
-
+  
+#if 0
     // ugh -> use commonx
   Real dx = visible_stem_count (me) ?
     last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS)
     : 0.0;
-
+#endif
+  
   Molecule leftbeams;
   Molecule rightbeams;
 
@@ -794,6 +803,10 @@ Beam::stem_beams (Grob*me,Item *here, Item *next, Item *prev,
 
   Direction dir = Directional_element_interface::get (me);
   
+  /* [Tremolo] beams on whole notes may not have direction set? */
+ if (dir == CENTER)
+    dir = Directional_element_interface::get (here);
+  
   /* half beams extending to the left. */
   if (prev)
     {
@@ -803,12 +816,20 @@ Beam::stem_beams (Grob*me,Item *here, Item *next, Item *prev,
        Half beam should be one note-width, 
        but let's make sure two half-beams never touch
        */
-      Real w = here->relative_coordinate (0, X_AXIS) - prev->relative_coordinate (0, X_AXIS);
+
+      // FIXME: TODO (check) stem width / sloped beams
+      Real w = here->relative_coordinate (0, X_AXIS)
+       - prev->relative_coordinate (0, X_AXIS);
+      Real stem_w = gh_scm2double (prev->get_grob_property ("thickness"))
+       // URG
+       * me->paper_l ()->get_var ("stafflinethickness");
+
       w = w/2 <? nw_f;
       Molecule a;
       if (lhalfs)              // generates warnings if not
-       a =  Lookup::beam (dydx, w, thick);
+       a =  Lookup::beam (dydx, w + stem_w, thick);
       a.translate (Offset (-w, -w * dydx));
+      a.translate_axis (-stem_w/2, X_AXIS);
       for (int j = 0; j  < lhalfs; j++)
        {
          Molecule b (a);
@@ -819,15 +840,23 @@ Beam::stem_beams (Grob*me,Item *here, Item *next, Item *prev,
 
   if (next)
     {
-      int rhalfs  = Stem::beam_count (here,RIGHT) - Stem::beam_count (next,LEFT);
-      int rwholebeams= Stem::beam_count (here,RIGHT) <? Stem::beam_count (next,LEFT) ;
+      int rhalfs  = Stem::beam_count (here,RIGHT)
+       - Stem::beam_count (next,LEFT);
+      int rwholebeams= Stem::beam_count (here,RIGHT)
+       <? Stem::beam_count (next,LEFT) ;
+
+      Real w = next->relative_coordinate (0, X_AXIS)
+       - here->relative_coordinate (0, X_AXIS);
 
-      Real w = next->relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS);
-      Molecule a = Lookup::beam (dydx, w + stemdx, thick);
-      a.translate_axis (- stemdx/2, X_AXIS);
+      Real stem_w = gh_scm2double (next->get_grob_property ("thickness"))
+       // URG
+       * me->paper_l ()->get_var ("stafflinethickness");
+
+      Molecule a = Lookup::beam (dydx, w + stem_w, thick);
+      a.translate_axis (- stem_w/2, X_AXIS);
       int j = 0;
       Real gap_f = 0;
-
+      
       SCM gap = me->get_grob_property ("gap");
       if (gh_number_p (gap))
        {
@@ -840,16 +869,24 @@ Beam::stem_beams (Grob*me,Item *here, Item *next, Item *prev,
              b.translate_axis (-dir  * bdy * j, Y_AXIS);
              rightbeams.add_molecule (b);
            }
-         // TODO: notehead widths differ for different types
-         gap_f = nw_f / 2;
+         if (Stem::invisible_b (here))
+           gap_f = nw_f;
+         else
+           gap_f = nw_f / 2;
          w -= 2 * gap_f;
-         a = Lookup::beam (dydx, w + stemdx, thick);
+         a = Lookup::beam (dydx, w + stem_w, thick);
        }
 
       for (; j  < rwholebeams; j++)
        {
          Molecule b (a);
-         b.translate (Offset (Stem::invisible_b (here) ? 0 : gap_f, -dir * bdy * j));
+         Real tx = 0;
+         if (Stem::invisible_b (here))
+           // ugh, see chord-tremolo.ly
+           tx = (-dir + 1) / 2 * nw_f * 1.5 + gap_f/4;
+         else
+           tx = gap_f;
+         b.translate (Offset (tx, -dir * bdy * j));
          rightbeams.add_molecule (b);
        }