]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/self-aligment-interface.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / self-aligment-interface.cc
index 17ec37b91f9562bbeaed31438f5ac55f7913469d..4c63ce73d2ee24dc6d70eb53904b27847ce2ffca 100644 (file)
@@ -3,11 +3,12 @@
  
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "self-alignment-interface.hh"
 #include "warn.hh"
+#include "grob.hh"
 
 MAKE_SCHEME_CALLBACK (Self_alignment_interface, y_aligned_on_self, 1);
 SCM
@@ -43,12 +44,18 @@ Self_alignment_interface::aligned_on_self (Grob *me, Axis a)
 
 
 
+SCM
+Self_alignment_interface::centered_on_object (Grob *him, Axis a)
+{
+  return scm_from_double (robust_relative_extent (him, him, a).center ());
+}
+
 
 MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_x_parent, 1);
 SCM
 Self_alignment_interface::centered_on_x_parent (SCM smob)
 {
-  return centered_on_parent (unsmob_grob (smob), X_AXIS);
+  return centered_on_object (unsmob_grob (smob)->get_parent (X_AXIS), X_AXIS);
 }
 
 
@@ -56,16 +63,15 @@ MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_y_parent, 1);
 SCM
 Self_alignment_interface::centered_on_y_parent (SCM smob)
 {
-  return centered_on_parent (unsmob_grob (smob), Y_AXIS);
+  return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), Y_AXIS);
 }
 
+
+MAKE_SCHEME_CALLBACK (Self_alignment_interface, x_centered_on_y_parent, 1);
 SCM
-Self_alignment_interface::centered_on_parent (Grob *me, Axis a)
+Self_alignment_interface::x_centered_on_y_parent (SCM smob)
 {
-  Grob *him = me->get_parent (a);
-  Interval he = him->extent (him, a);
-
-  return scm_from_double (he.is_empty () ? 0.0 : he.center ());
+  return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), X_AXIS);
 }
 
 MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_x_parent,1);
@@ -126,7 +132,7 @@ Self_alignment_interface::set_align_self (Grob *me, Axis a)
                       a);
 }
 
-ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
+ADD_INTERFACE (Self_alignment_interface,
               "Position this object on itself and/or on its parent. To this end, the following functions "
               " are provided: \n"
               "@table @code \n"
@@ -140,9 +146,7 @@ ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
               "@end table\n",
 
 
-              /* porperties */
+              /* properties */
               "self-alignment-X "
-              "self-X-offset "
-              "self-Y-offset "
               "self-alignment-Y ");