]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest.cc
catch GUILE errors
[lilypond.git] / lily / rest.cc
index c29f77765268248cc68ae6090fe12e509c925dfa..7375e107f5f4e195ba9301f0d3102a44929c5776 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "molecule.hh"
@@ -21,7 +21,7 @@ Rest::after_line_breaking (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   int bt = gh_scm2int (me->get_grob_property ("duration-log"));
-  if (bt == 0)
+  if (bt == 0 && Staff_symbol_referencer::line_count (me) > 1)
     {
       me->translate_axis (Staff_symbol_referencer::staff_space (me) , Y_AXIS);
     }
@@ -48,7 +48,7 @@ Rest::glyph_name (Grob * me, int balltype, String style)
   if (balltype == 0 || balltype == 1)
     {
       Real rad = Staff_symbol_referencer::staff_radius (me) * 2.0;
-      Real pos = Staff_symbol_referencer::position_f (me);
+      Real pos = Staff_symbol_referencer::get_position (me);
 
       /*
        Figure out when the rest is far enough outside the staff. This
@@ -60,8 +60,8 @@ Rest::glyph_name (Grob * me, int balltype, String style)
       ledger_b = ledger_b || (balltype == 1 &&
                              (pos  <= -rad -2 || pos > rad));
     }
-  
-  return ("rests-") + to_str (balltype)
+
+  return ("rests-") + to_string (balltype)
     + (ledger_b ? "o" : "") + style;
 }
 
@@ -78,6 +78,7 @@ Rest::brew_internal_molecule (SCM smob)
   SCM balltype_scm = me->get_grob_property ("duration-log");
   if (!gh_number_p (balltype_scm))
     return Molecule ().smobbed_copy ();
+
   int balltype = gh_scm2int (balltype_scm);
   
   String style; 
@@ -87,8 +88,14 @@ Rest::brew_internal_molecule (SCM smob)
       style = ly_scm2string (scm_symbol_to_string (style_sym));
     }
 
-  String idx = glyph_name (me, balltype, style);
-  return Font_interface::get_default_font (me)->find_by_name (idx).smobbed_copy ();
+  for(;;) {
+    String idx = glyph_name (me, balltype, style);
+    Molecule res = Font_interface::get_default_font (me)->find_by_name (idx);
+    if(res.empty_b() && style!="")
+      style="";
+    else             
+      return res.smobbed_copy();
+  }
 }
 
 SCM 
@@ -108,8 +115,9 @@ Rest::extent_callback (SCM smob, SCM ax)
   return ly_interval2scm (unsmob_molecule (m)->extent (a));
 }
 
-bool
-Rest::has_interface (Grob*m)
-{
-  return m && m->has_interface (ly_symbol2scm ("rest-interface"));
-}
+
+
+ADD_INTERFACE (Rest,"rest-interface",
+  "a rest",
+  "style minimum-beam-collision-distance");
+