]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slur.cc
($(outdir)/%.pdf): add DVIPS_FLAGS. This will
[lilypond.git] / lily / slur.cc
index c3d7b1e2c1cc8fff4c6c3ca049787d04abb501dc..9868d30b9c5cdf2d05a1df6422735124c00cf052 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -29,7 +29,7 @@
 #include "note-column.hh"
 #include "stem.hh"
 #include "paper-column.hh"
-#include "molecule.hh"
+#include "stencil.hh"
 #include "warn.hh"
 #include "slur-bezier-bow.hh"
 #include "main.hh"
@@ -160,7 +160,7 @@ Slur::check_slope (Grob *me)
          o[RIGHT] = ly_scm2offset (index_get_cell (a, RIGHT));
          o[d][Y_AXIS] -= (limit - slope) * dx * dir / staff_space;
 
-         o[d][Y_AXIS] *= Directional_element_interface::get (me);
+         o[d][Y_AXIS] *= get_grob_direction (me);
 
          me->set_grob_property ("attachment-offset",
                                gh_cons (ly_offset2scm (o[LEFT]),
@@ -176,8 +176,8 @@ Slur::check_slope (Grob *me)
 SCM
 Slur::set_extremities (Grob *me)
 {
-  if (!Directional_element_interface::get (me))
-    Directional_element_interface::set (me, get_default_dir (me));
+  if (!get_grob_direction (me))
+    set_grob_direction (me, get_default_dir (me));
 
   SCM att = me->get_grob_property ("attachment");
       /*
@@ -348,9 +348,7 @@ Slur::get_attachment (Grob *me, Direction dir,
              /*
                Default position is on stem X, at stem end Y
               */
-             Real stem_thickness =
-               gh_scm2double (stem->get_grob_property ("thickness"))
-               * stem->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
+             Real stem_thickness = Stem::thickness (stem);
              o += Offset (0.5 *
                           x_extent * (1 + Stem::get_direction (stem))
                           - ((dir + 1)/2) * stem_thickness
@@ -415,7 +413,7 @@ Slur::encompass_offset (Grob*me,
   Offset o;
   Grob* stem = unsmob_grob (col->get_grob_property ("stem"));
   
-  Direction dir = Directional_element_interface::get (me);
+  Direction dir = get_grob_direction (me);
   
   if (!stem)
     {
@@ -424,7 +422,7 @@ Slur::encompass_offset (Grob*me,
       o[Y_AXIS] = col->relative_coordinate (common[Y_AXIS], Y_AXIS);
       return o;  
     }
-  Direction stem_dir = Directional_element_interface::get (stem);
+  Direction stem_dir = get_grob_direction (stem);
   o[X_AXIS] = stem->relative_coordinate (0, X_AXIS);
 
   /*
@@ -438,7 +436,7 @@ Slur::encompass_offset (Grob*me,
   o[X_AXIS] -= 0.5 * stem_dir * x_extent;
 
   if ((stem_dir == dir)
-      && !stem->extent (stem, Y_AXIS).empty_b ())
+      && !stem->extent (stem, Y_AXIS).is_empty ())
     {
       o[Y_AXIS] = stem->extent (common[Y_AXIS], Y_AXIS)[dir];
     }
@@ -450,7 +448,7 @@ Slur::encompass_offset (Grob*me,
   /*
    leave a gap: slur mustn't touch head/stem
    */
-  o[Y_AXIS] += dir * gh_scm2double (me->get_grob_property ("y-free")) *
+  o[Y_AXIS] += dir * robust_scm2double (me->get_grob_property ("y-free"), 0) *
     1.0;
   return o;
 }
@@ -530,16 +528,19 @@ Slur::height (SCM smob, SCM ax)
   Grob * me = unsmob_grob (smob);
   assert (a == Y_AXIS);
 
-  SCM mol = me->get_uncached_molecule ();
-  return ly_interval2scm (unsmob_molecule (mol)->extent (a));
+  SCM mol = me->get_uncached_stencil ();
+  Interval ext;
+  if (Stencil * m = unsmob_stencil (mol))
+    ext = m->extent (a);
+  return ly_interval2scm (ext);
 }
 
 /*
   Ugh should have dash-length + dash-period
  */
-MAKE_SCHEME_CALLBACK (Slur, brew_molecule,1);
+MAKE_SCHEME_CALLBACK (Slur, print,1);
 SCM
-Slur::brew_molecule (SCM smob)
+Slur::print (SCM smob)
 {
   Grob * me = unsmob_grob (smob);
   if (!scm_ilength (me->get_grob_property ("note-columns")))
@@ -548,20 +549,23 @@ Slur::brew_molecule (SCM smob)
       return SCM_EOL;
     }
 
-  Real thick = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")) *
-    gh_scm2double (me->get_grob_property ("thickness"));
+  Real base_thick = robust_scm2double (me->get_grob_property ("thickness"), 1);
+  Real thick = base_thick * Staff_symbol_referencer::line_thickness (me);
+
+  Real ss = Staff_symbol_referencer::staff_space (me);
   Bezier one = get_curve (me);
 
   // get_curve may suicide
   if (!scm_ilength (me->get_grob_property ("note-columns")))
     return SCM_EOL;
 
-  Molecule a;
+  Stencil a;
   SCM d =  me->get_grob_property ("dashed");
   if (gh_number_p (d))
-    a = Lookup::dashed_slur (one, thick, thick * gh_scm2double (d));
+    a = Lookup::dashed_slur (one, thick, thick * robust_scm2double (d, 0));
   else
-    a = Lookup::slur (one, Directional_element_interface::get (me) * thick, thick);
+    a = Lookup::slur (one, get_grob_direction (me) * base_thick * ss / 10.0,
+                     thick);
 
   return a.smobbed_copy ();
 }
@@ -575,11 +579,11 @@ Slur::set_control_points (Grob*me)
   SCM h_inf_scm = me->get_grob_property ("height-limit");
   SCM r_0_scm = me->get_grob_property ("ratio");
 
-  Real r_0 = gh_scm2double (r_0_scm);
+  Real r_0 = robust_scm2double (r_0_scm, 1);
   Real h_inf = staff_space * gh_scm2double (h_inf_scm);
   
   Slur_bezier_bow bb (get_encompass_offsets (me),
-                     Directional_element_interface::get (me),
+                     get_grob_direction (me),
                      h_inf, r_0);
 
 
@@ -646,7 +650,7 @@ Slur::get_curve (Grob*me)
     attach = set_extremities(me);
 
   
-  if (!Directional_element_interface::get (me)
+  if (!get_grob_direction (me)
       || ! gh_symbol_p (index_get_cell (attach, LEFT))
       || ! gh_symbol_p (index_get_cell (attach, RIGHT)))
     set_extremities (me);
@@ -665,7 +669,7 @@ Slur::get_curve (Grob*me)
     }
 
   Array<Offset> enc (get_encompass_offsets (me));
-  Direction dir = Directional_element_interface::get (me);
+  Direction dir = get_grob_direction (me);
   
   Real x1 = enc[0][X_AXIS];
   Real x2 = enc.top ()[X_AXIS];