]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/staff-symbol-referencer.cc
remove ly_scm2str0.
[lilypond.git] / lily / staff-symbol-referencer.cc
index ecdcc3cd0edcdb03e9b2ab674a092467c228f8b7..9fbe6f8b4387c9f8838f4bcea2006447d9d9bd54 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "staff-symbol-referencer.hh"
 #include "staff-symbol.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "libc-extension.hh"
 
 
@@ -27,6 +27,10 @@ Staff_symbol_referencer::on_staffline (Grob *me)
   return on_staffline (me, (int) rint (get_position (me)));
 }
 
+/*
+  This does not take size into account.
+  maybe rename: on_virtual_staffline, on_staff_or_ledger_line?
+ */
 bool
 Staff_symbol_referencer::on_staffline (Grob *me, int pos)
 {
@@ -37,6 +41,9 @@ Staff_symbol_referencer::on_staffline (Grob *me, int pos)
 Grob*
 Staff_symbol_referencer::get_staff_symbol (Grob *me)
 {
+  if (Staff_symbol::has_interface (me))
+    return me;
+  
   SCM st = me->get_property ("staff-symbol");
   return unsmob_grob (st);
 }
@@ -73,7 +80,10 @@ Staff_symbol_referencer::get_position (Grob *me)
       p += 2.0 * y / Staff_symbol::staff_space (st);
       return p;
     }
-
+  else if (!st)
+    {
+      return me->relative_coordinate (me->get_parent (Y_AXIS), Y_AXIS) * 2;
+    }
   return robust_scm2double (me->get_property ("staff-position"), p);
 }
 
@@ -108,7 +118,7 @@ Staff_symbol_referencer::callback (SCM element_smob, SCM)
 
   SCM pos = me->get_property ("staff-position");
   Real off = 0.0;
-  if (is_number (pos))
+  if (ly_c_number_p (pos))
     {
       Real space = Staff_symbol_referencer::staff_space (me);
       off = ly_scm2double (pos) * space / 2.0;
@@ -120,7 +130,7 @@ Staff_symbol_referencer::callback (SCM element_smob, SCM)
 
 /*  This sets the position relative to the center of the staff symbol.
 
-The function is hairy, because it can be callled in two situations:
+The function is hairy, because it can be called in two situations:
 
 1. There is no staff yet; we must set staff-position
 
@@ -142,9 +152,7 @@ Staff_symbol_referencer::set_position (Grob *me, Real p)
   else
     me->set_property ("staff-position", scm_make_real (p));
 
-  if (!me->has_offset_callback (Staff_symbol_referencer::callback_proc,
-                               Y_AXIS))
-    me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS);
+  me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS);
 }
 
 /* Half of the height, in staff space, i.e. 2.0 for a normal staff. */