]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest.cc
release: 1.3.50
[lilypond.git] / lily / rest.cc
index b737dea036fa772709d0e1a678d53de65627132f..89c2d1a9e0ad51c65007809668fffb08652bab00 100644 (file)
@@ -1,9 +1,9 @@
 /*
 rest.cc -- implement Rest
+ rest.cc -- implement Rest
 
   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 "molecule.hh"
 #include "lookup.hh"
 #include "rest.hh"
 #include "dots.hh"
-#include "axis-group-element.hh"
-#include "p-score.hh"
+#include "paper-score.hh"
+#include "staff-symbol-referencer.hh"
+
 
 void
-Rest::do_add_processing ()
+Rest::after_line_breaking ()
 {
-  if (balltype_i_ > 1)
-    position_i_ -= 4;
-  else if (balltype_i_ == 0)
-    position_i_ += 2;
-
-  Rhythmic_head::do_add_processing ();
-  if (dots_l_ && balltype_i_ > 1)
+  if (balltype_i () == 0)
     {
-      dots_l_->position_i_ = position_i_ + 4;
+      Staff_symbol_referencer_interface si (this);
+      si.set_position (si.position_f () + 2);
+    }
+  
+  Dots * d = dots_l ();
+  if (d && balltype_i () > 4) // UGH.
+    {
+      /*
+       UGH. 
+       */
+      staff_symbol_referencer (d)
+       .set_position ((balltype_i () == 7) ? 4 : 3);
     }
 }
 
-Rest::Rest ()
-{
-  position_i_ =0;
-}
 
-Molecule *
-Rest::do_brew_molecule_p () const
+Molecule 
+Rest::do_brew_molecule () const
 {
-  bool streepjes_b = abs(position_i_) > lines_i () / 2 &&  
-    (balltype_i_ == 0 || balltype_i_ == 1);
+  bool ledger_b =false;
+
+  if (balltype_i () == 0 || balltype_i () == 1)
+    {
+      Staff_symbol_referencer_interface si(this);
+      ledger_b = abs(si.position_f ()  - (2* balltype_i () - 1))
+       > si.line_count (); 
+    }
   
   String style; 
-  SCM style_sym =get_elt_property (style_scm_sym);
-  if (style_sym != SCM_BOOL_F)
+  SCM style_sym =get_elt_property ("style");
+  if (balltype_i () >= 2 &&gh_string_p ( style_sym))
     {
-      style = ly_scm2string (SCM_CDR(style_sym));
+      style = ly_scm2string (style_sym);
     }
-  
-  Molecule s(lookup_l ()->rest (balltype_i_, streepjes_b, style));
-  Molecule * m = new Molecule ( Molecule (s));
-  m->translate_axis (position_i_ *  staff_line_leading_f ()/2.0, Y_AXIS);
-  return m;
+
+  String idx =  ("rests-") + to_str (balltype_i ()) + (ledger_b ? "o" : "") + style;
+
+  return lookup_l ()->afm_find (idx);
 }
 
 
+