]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
patch::: 1.3.48.jcn1
[lilypond.git] / lily / stem.cc
index 18889df2d9723ec02c0a6085d5c197c5e0fcc5a8..22344c6099bad318a42127d60c679cabc8ff9867 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 
   TODO: This is way too hairy
@@ -25,7 +25,7 @@
 #include "group-interface.hh"
 #include "cross-staff.hh"
 #include "staff-symbol-referencer.hh"
-#include "lily-guile.icc"
+
 
 
 void
@@ -63,8 +63,8 @@ Stem::head_positions () const
   
   Drul_array<Note_head*> e (extremal_heads ());
 
-  return Interval (staff_symbol_referencer_interface (e[DOWN]).position_f (),
-                  staff_symbol_referencer_interface( e[UP]).position_f ()); 
+  return Interval (staff_symbol_referencer (e[DOWN]).position_f (),
+                  staff_symbol_referencer( e[UP]).position_f ()); 
 }
 
 
@@ -101,6 +101,7 @@ Stem::get_direction () const
     {
        Stem * me = (Stem*) this;
        d = get_default_dir ();
+       // urg, AAARGH!
        directional_element (me).set (d);
     }
   return d ;
@@ -218,7 +219,7 @@ Stem::Stem ()
   set_elt_property ("heads", SCM_EOL);
   set_elt_property ("rests", SCM_EOL);
 
-  dim_cache_[X_AXIS]->off_callbacks_.push ( &Stem::off_callback);
+  add_offset_callback ( &Stem::off_callback, X_AXIS);
 }
 
 bool
@@ -251,6 +252,11 @@ Stem::get_default_dir () const
   return Direction (int(paper_l ()->get_var ("stem_default_neutral_direction")));
 }
 
+/*
+  ugh. A is used for different purposes. This functionality should be
+  moved into scheme at some point to get rid of the silly
+  conversions. (but lets wait till we have namespaces in SCM)
+ */
 Real
 Stem::get_default_stem_end_position () const
 {
@@ -267,15 +273,20 @@ Stem::get_default_stem_end_position () const
     }
   else
     {
-      s = ly_eval_str (type_str + "stem-length");
-      scm_to_array (s, &a);
+      s = scm_eval (ly_symbol2scm ((type_str + "stem-length").ch_C()));
+      for (SCM q = s; q != SCM_EOL; q = gh_cdr (q))
+       a.push (gh_scm2double (gh_car (q)));
+               
       // stem uses half-spaces
       length_f = a[((flag_i () - 2) >? 0) <? (a.size () - 1)] * 2;
     }
 
 
-  s = ly_eval_str (type_str + "stem-shorten");
-  scm_to_array (s, &a);
+  a.clear ();
+  s = scm_eval (ly_symbol2scm ((type_str + "stem-shorten").ch_C()));
+  for (SCM q = s; q != SCM_EOL; q = gh_cdr (q))
+    a.push (gh_scm2double (gh_car (q)));
+
 
   // stem uses half-spaces
 
@@ -366,7 +377,7 @@ Stem::position_noteheads ()
 }
 
 void
-Stem::do_pre_processing ()
+Stem::before_line_breaking ()
 {
   stem_end_position ();        // ugh. Trigger direction calc.
   position_noteheads ();
@@ -374,8 +385,8 @@ Stem::do_pre_processing ()
   if (invisible_b ())
     {
       set_elt_property ("transparent", SCM_BOOL_T);
-      set_empty (Y_AXIS);      
-      set_empty (X_AXIS);      
+      set_extent_callback (0, Y_AXIS);      
+      set_extent_callback (0, X_AXIS);      
     }
 
   set_spacing_hints ();
@@ -444,10 +455,10 @@ Stem::dim_callback (Dimension_cache const* c)
 
 const Real ANGLE = 20* (2.0*M_PI/360.0); // ugh!
 
-Molecule*
-Stem::do_brew_molecule_p () const
+Molecule 
+Stem::do_brew_molecule () const
 {
-  Molecule *mol_p =new Molecule;
+  Molecule mol;
 
   Staff_symbol_referencer_interface si (first_head ());
   
@@ -457,9 +468,7 @@ Stem::do_brew_molecule_p () const
   Interval stem_y(y1,y2);
   stem_y.unite (Interval (y2,y1));
 
-  Real dy = staff_symbol_referencer_interface (this)
-    .staff_space ()/2.0;
-
+  Real dy = staff_symbol_referencer (this).staff_space ()/2.0;
   Real head_wid = 0;
   if (support_head ())
     head_wid = support_head ()->extent (X_AXIS).length ();
@@ -470,17 +479,17 @@ Stem::do_brew_molecule_p () const
       Real stem_width = paper_l ()->get_var ("stemthickness");
       Molecule ss =lookup_l ()->filledbox (Box (Interval (-stem_width/2, stem_width/2),
                                                 Interval (stem_y[DOWN]*dy, stem_y[UP]*dy)));
-      mol_p->add_molecule (ss);
+      mol.add_molecule (ss);
     }
 
   if (!beam_l () && abs (flag_i ()) > 2)
     {
       Molecule fl = flag ();
       fl.translate_axis(stem_y[get_direction ()]*dy, Y_AXIS);
-      mol_p->add_molecule (fl);
+      mol.add_molecule (fl);
     }
 
-  return mol_p;
+  return mol;
 }
 
 Real
@@ -546,12 +555,19 @@ Stem::calc_stem_info () const
   SCM s;
   String type_str = grace_b ? "grace-" : "";
   
-  s = ly_eval_str (type_str + "beamed-stem-minimum-length");
-  scm_to_array (s, &a);
+  s = scm_eval (ly_symbol2scm ((type_str + "beamed-stem-minimum-length").ch_C()));
+  a.clear ();
+  for (SCM q = s; q != SCM_EOL; q = gh_cdr (q))
+    a.push (gh_scm2double (gh_car (q)));
+
+
   Real minimum_length = a[multiplicity <? (a.size () - 1)] * staff_space;
+  s = scm_eval (ly_symbol2scm ((type_str + "beamed-stem-length").ch_C()));
+
+  a.clear();
+  for (SCM q = s; q != SCM_EOL; q = gh_cdr (q))
+    a.push (gh_scm2double (gh_car (q)));
 
-  s = ly_eval_str (type_str + "beamed-stem-length");
-  scm_to_array (s, &a);
   Real stem_length =  a[multiplicity <? (a.size () - 1)] * staff_space;
 
   if (!beam_dir || (beam_dir == directional_element (this).get ()))