]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest.cc
release: 1.3.110
[lilypond.git] / lily / rest.cc
index e3a1de5043fa22e73324a9f7d382d89436f8af6e..149c45ba76f44fb908ef8c0db1076c8d0730c4bd 100644 (file)
@@ -8,29 +8,28 @@
 
 #include "molecule.hh"
 #include "paper-def.hh"
-#include "lookup.hh"
+#include "font-interface.hh"
 #include "rest.hh"
 #include "dots.hh"
 #include "paper-score.hh"
 #include "staff-symbol-referencer.hh"
 
 // -> offset callback
-MAKE_SCHEME_CALLBACK(Rest,after_line_breaking);
+MAKE_SCHEME_CALLBACK(Rest,after_line_breaking,1);
 SCM
 Rest::after_line_breaking (SCM smob)
 {
-  Score_element *me = unsmob_element (smob);
-  int bt = gh_scm2int (me->get_elt_property ("duration-log"));
+  Grob *me = unsmob_grob (smob);
+  int bt = gh_scm2int (me->get_grob_property ("duration-log"));
   if (bt == 0)
     {
-
       me->translate_axis (Staff_symbol_referencer::staff_space (me) , Y_AXIS);
     }
 
-  Score_element * d = unsmob_element (me->get_elt_property ("dot"));
+  Grob * d = unsmob_grob (me->get_grob_property ("dot"));
   if (d && bt > 4) // UGH.
     {
-      d->set_elt_property ("staff-position",
+      d->set_grob_property ("staff-position",
                           gh_int2scm ((bt == 7) ? 4 : 3));
     }
 
@@ -38,15 +37,16 @@ Rest::after_line_breaking (SCM smob)
 }
 
 
-MAKE_SCHEME_CALLBACK(Rest,brew_molecule)
-SCM 
-Rest::brew_molecule (SCM smob) 
+MAKE_SCHEME_CALLBACK(Rest,brew_molecule,1);
+
+SCM
+Rest::brew_internal_molecule (SCM smob)
 {
-  Score_element* me = unsmob_element (smob);
+  Grob* me = unsmob_grob (smob);
   
   bool ledger_b =false;
 
-  SCM balltype = me->get_elt_property ("duration-log");
+  SCM balltype = me->get_grob_property ("duration-log");
   
   if (balltype == gh_int2scm (0) || balltype == gh_int2scm (1))
     {
@@ -56,21 +56,37 @@ Rest::brew_molecule (SCM smob)
     }
   
   String style; 
-  SCM style_sym =me->get_elt_property ("style");
-  if (gh_scm2int (balltype) >= 2 && gh_string_p (style_sym))
+  SCM style_sym =me->get_grob_property ("style");
+  if (gh_scm2int (balltype) >= 2 && gh_symbol_p (style_sym))
     {
-      style = ly_scm2string (style_sym);
+      style = ly_scm2string (scm_symbol_to_string (style_sym));
     }
 
   String idx =  ("rests-") + to_str (gh_scm2int (balltype))
     + (ledger_b ? "o" : "") + style;
 
-  return me-> lookup_l ()->afm_find (idx).create_scheme();
+  return Font_interface::get_default_font (me)->find_by_name (idx).smobbed_copy();
 }
 
+SCM 
+Rest::brew_molecule (SCM smob) 
+{
+  return brew_internal_molecule (smob);
+}
+MAKE_SCHEME_CALLBACK(Rest,extent_callback,2);
+/*
+  We need the callback. The real molecule has ledgers depending on
+  Y-position. The Y-position is known only after line breaking.  */
+SCM
+Rest::extent_callback (SCM smob, SCM ax)
+{
+  Axis a = (Axis) gh_scm2int (ax);
+  SCM m = brew_internal_molecule (smob);
+  return ly_interval2scm (unsmob_molecule (m)->extent (a));
+}
 
 bool
-Rest::has_interface (Score_element*m)
+Rest::has_interface (Grob*m)
 {
   return m && m->has_interface (ly_symbol2scm ("rest-interface"));
 }