]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest.cc
release: 1.3.80
[lilypond.git] / lily / rest.cc
index 14e10a35379f5b667f2c8e14857db126070e4785..dcff3064226b85e6e345e2a6635674194fc627b2 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 "paper-score.hh"
+#include "staff-symbol-referencer.hh"
 
-void
-Rest::do_add_processing ()
+// -> offset callback
+MAKE_SCHEME_CALLBACK(Rest,after_line_breaking);
+SCM
+Rest::after_line_breaking (SCM smob)
 {
-  if (balltype_i_ == 0)
-    position_i_ += 2;
-
-  Rhythmic_head::do_add_processing ();
-}
+  Score_element *me = unsmob_element (smob);
+  int bt = gh_scm2int (me->get_elt_property ("duration-log"));
+  if (bt == 0)
+    {
+      me->translate_axis (Staff_symbol_referencer::staff_space (me) , Y_AXIS);
+    }
 
-void
-Rest::do_post_processing ()
-{
-  Rhythmic_head::do_post_processing ();
-  if (dots_l_ && balltype_i_ > 4)
+  Score_element * d = unsmob_element (me->get_elt_property ("dot"));
+  if (d && bt > 4) // UGH.
     {
-      dots_l_->position_i_ += 3;
-      if (balltype_i_ == 7)
-       dots_l_->position_i_++;
+      d->set_elt_property ("staff-position",
+                          gh_int2scm ((bt == 7) ? 4 : 3));
     }
-}
 
-Rest::Rest ()
-{
-  position_i_ =0;
+  return SCM_UNSPECIFIED;
 }
 
-Molecule *
-Rest::do_brew_molecule_p () const
+
+MAKE_SCHEME_CALLBACK(Rest,brew_molecule)
+SCM 
+Rest::brew_molecule (SCM smob) 
 {
+  Score_element* me = unsmob_element (smob);
+  
   bool ledger_b =false;
 
-  if (balltype_i_ == 0 || balltype_i_ == 1)
-    ledger_b = abs(position_f ()  - (2* balltype_i_ - 1)) > lines_i (); 
-      
-
+  SCM balltype = me->get_elt_property ("duration-log");
   
-  String style; 
-  SCM style_sym =get_elt_property (style_scm_sym);
-  if (balltype_i_ >= 2 && style_sym != SCM_BOOL_F)
+  if (balltype == gh_int2scm (0) || balltype == gh_int2scm (1))
     {
-      style = ly_scm2string (SCM_CDR(style_sym));
+      int sz = Staff_symbol_referencer::line_count (me);
+      Real dif = abs(Staff_symbol_referencer::position_f (me)  - (2* gh_scm2int (balltype) - 1)); 
+      ledger_b = dif > sz;
     }
   
-  Molecule s(lookup_l ()->rest (balltype_i_, ledger_b, style));
-  Molecule * m = new Molecule ( Molecule (s));
+  String style; 
+  SCM style_sym =me->get_elt_property ("style");
+  if (gh_scm2int (balltype) >= 2 && gh_string_p (style_sym))
+    {
+      style = ly_scm2string (style_sym);
+    }
+
+  String idx =  ("rests-") + to_str (gh_scm2int (balltype))
+    + (ledger_b ? "o" : "") + style;
 
-  return m;
+  return me-> lookup_l ()->afm_find (idx).create_scheme();
 }
 
 
+bool
+Rest::has_interface (Score_element*m)
+{
+  return m && m->has_interface (ly_symbol2scm ("rest-interface"));
+}