]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest.cc
release: 1.3.50
[lilypond.git] / lily / rest.cc
index 0028373cf5dfdd9ce5331ccc0d439ae9e78adff6..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 Han-Wen Nienhuys <hanwen@stack.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_ != 0 && 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)
+    {
+      Staff_symbol_referencer_interface si (this);
+      si.set_position (si.position_f () + 2);
+    }
+  
+  Dots * d = dots_l ();
+  if (d && balltype_i () > 4) // UGH.
     {
-      dots_l_->position_i_ = position_i_ + 4;
+      /*
+       UGH. 
+       */
+      staff_symbol_referencer (d)
+       .set_position ((balltype_i () == 7) ? 4 : 3);
     }
 }
 
-Rest::Rest ()
-{
-  position_i_ =0;
-}
 
-Molecule *
-Rest::brew_molecule_p () const
+Molecule 
+Rest::do_brew_molecule () const
 {
-  int staff_size_i_ = 8;
-  bool streepjes_b = abs(position_i_) > staff_size_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 (); 
+    }
   
-  Atom s(paper ()->lookup_l()->rest (balltype_i_, streepjes_b));
-  Molecule * m = new Molecule ( Atom (s));
-  m->translate_axis (position_i_ *  paper ()->internote_f (), Y_AXIS);
-  return m;
+  String style; 
+  SCM style_sym =get_elt_property ("style");
+  if (balltype_i () >= 2 &&gh_string_p ( style_sym))
+    {
+      style = ly_scm2string (style_sym);
+    }
+
+  String idx =  ("rests-") + to_str (balltype_i ()) + (ledger_b ? "o" : "") + style;
+
+  return lookup_l ()->afm_find (idx);
 }
 
-IMPLEMENT_IS_TYPE_B1(Rest, Rhythmic_head);
+
+