]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
release: 1.3.147
[lilypond.git] / lily / stem.cc
index 13272bc71bc267c02e326d161dda42e9f02ae644..09c15b567969faf314cdc2b9474668ae94849610 100644 (file)
@@ -235,7 +235,7 @@ Stem::get_default_dir (Grob*me)
   if (sign (dd - du))
     return Direction (sign (dd -du));
 
-  return to_dir (me->get_grob_property ("default-neutral-direction"));
+  return to_dir (me->get_grob_property ("neutral-direction"));
 }
 
 Real
@@ -476,41 +476,16 @@ Stem::brew_molecule (SCM smob)
   stem_y.unite (Interval (y2,y1));
 
   Real dy = Staff_symbol_referencer::staff_space (me)/2.0;
-  Real head_wid = 0;
-
-  /*
-TODO:
-
-    I don't really get the idea of the attachment-angle.
-    It seems like that you attach the Stem to the NoteHead at point
-    (1,tan(aa)/2), making it still nessesary to have special CENTER-STEMS
-    option - and if I would like to attach stem i.e. here:
-
-      |
-      |
-      |
-    XXX
-   XXXXX
-   XXXXX
-    XXX
-
-   That would be impossible.
-   Why haven't you just made ATTACHMENT-COORDINATES as a pair of reals,
-   with (0 . 0) meaning CENTER, (1 . 1) upper right, etc...?
-   
--Rune
-
-  */
     
-  Real slope =0.0;
   if (Grob *hed = support_head (me))
     {
-      head_wid = hed->extent (hed,X_AXIS).length ();
+      Interval head_height = hed->extent (hed,Y_AXIS);
+      Real y_attach = Note_head::stem_attachment_coordinate ( hed, Y_AXIS);
 
-      slope = gh_scm2double (hed->get_grob_property ("attachment-slope"));
+      y_attach = head_height.linear_combination (y_attach);
+      stem_y[Direction (-d)] += d * 2*y_attach;
     }
-  stem_y[Direction (-d)] += d * head_wid * slope/ (2*dy);
+
   
   if (!invisible_b (me))
     {
@@ -542,14 +517,29 @@ Stem::off_callback (SCM element_smob, SCM)
   Real r=0;
   if (Grob * f = first_head (me))
     {
-      Interval head_wid (0, f->extent (f,X_AXIS).length ());
+      Interval head_wid = f->extent (f,X_AXIS);
+
+      Real attach =
+       Note_head::stem_attachment_coordinate(f, X_AXIS);
 
-      if (to_boolean (me->get_grob_property ("stem-centered")))
-       return gh_double2scm (head_wid.center ());
-      
-      Real rule_thick = gh_scm2double (me->get_grob_property ("thickness")) * me->paper_l ()->get_var ("stafflinethickness");
       Direction d = get_direction (me);
-      r = head_wid[d] - d * rule_thick * 0.5;
+
+      Real real_attach = head_wid.linear_combination (d * attach);
+
+      r = real_attach;
+
+      /*
+       If not centered: correct for stem thickness.
+       */
+      if (attach)
+       {
+         Real rule_thick
+           = gh_scm2double (me->get_grob_property ("thickness"))
+           * me->paper_l ()->get_var ("stafflinethickness");
+
+         
+         r += - d * rule_thick * 0.5;
+       }
     }
   return gh_double2scm (r);
 }