]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-head.cc
release: 1.3.25
[lilypond.git] / lily / note-head.cc
index 70834c191b000fbd06c16c05bb9d009806b04c02..d7da247660a90f0b37a419021e636ae9bbe7b97f 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "misc.hh"
 
 
 
+/*
+  build a ledger line for small pieces.
+ */
+Molecule
+Note_head::ledger_line (Interval xwid) const
+{
+  Drul_array<Molecule> endings;
+  endings[LEFT] = lookup_l()->afm_find ("noteheads-ledgerending");
+  Molecule * e = &endings[LEFT];
+  endings[RIGHT] = *e;
+  
+  Real thick = e->dim_[Y_AXIS].length();
+  Real len = e->dim_[X_AXIS].length () - thick;
+
+  Molecule total;
+  Direction d = LEFT;
+  do {
+    endings[d].translate_axis (xwid[d] - endings[d].dim_[X_AXIS][d], X_AXIS);
+    total.add_molecule (endings[d]);    
+  } while ((flip(&d)) != LEFT);
+
+  Real xpos = xwid [LEFT] + len;
+
+  while (xpos + len + thick /2 <= xwid[RIGHT])
+    {
+      e->translate_axis (len, X_AXIS);
+      total.add_molecule (*e);
+      xpos += len;
+    }
+
+  return total;
+}
+
 
 void
 Note_head::do_pre_processing ()
@@ -51,8 +84,8 @@ Note_head::do_brew_molecule_p() const
 {
   Staff_symbol_referencer_interface si (this);
   
-  Real inter_f = si.staff_line_leading_f ()/2;
-  int sz = si.lines_i ()-1;
+  Real inter_f = si.staff_space ()/2;
+  int sz = si.line_count ()-1;
   Real p = si.position_f ();
   int streepjes_i = abs (p) < sz 
     ? 0
@@ -60,7 +93,7 @@ Note_head::do_brew_molecule_p() const
 
  String type; 
   SCM style  = get_elt_property ("style");
-  if (style != SCM_UNDEFINED)
+  if (gh_string_p (style))
     {
       type = ly_scm2string (style);
     }
@@ -76,9 +109,8 @@ Note_head::do_brew_molecule_p() const
       Interval hd = out->dim_[X_AXIS];
       Real hw = hd.length ()/4;
       
-      Molecule ledger
-       = lookup_l ()->ledger_line  (Interval (hd[LEFT] - hw,
-                                              hd[RIGHT] + hw));
+      Molecule ledger (ledger_line  (Interval (hd[LEFT] - hw,
+                                              hd[RIGHT] + hw)));
       
       int parity =  abs(int (p)) % 2;