]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/self-aligment-interface.cc
* make/lilypond.fedora.spec.in (Group): add lilypond-internals to
[lilypond.git] / lily / self-aligment-interface.cc
index badd4899a9e0ea94d8e5bb049d2d4a5b249ed9e5..c3ef66b54f535923ab26d1a379a02779e33ef58f 100644 (file)
@@ -1,12 +1,13 @@
 /*
   self-alignment-interface.cc
-  
+
   source file of the GNU LilyPond music typesetter
-  
-  (c) 2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+  (c) 2004--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "self-alignment-interface.hh"
+
 #include "warn.hh"
 
 /* Position centered on parent.  */
@@ -18,8 +19,8 @@ Self_alignment_interface::centered_on_parent (SCM element_smob, SCM axis)
   Axis a = (Axis) scm_to_int (axis);
   Grob *him = me->get_parent (a);
   Interval he = him->extent (him, a);
-  
-  return  scm_make_real (he.is_empty () ? 0.0 : he.center ());
+
+  return scm_from_double (he.is_empty () ? 0.0 : he.center ());
 }
 
 MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_parent, 2);
@@ -30,41 +31,41 @@ Self_alignment_interface::aligned_on_parent (SCM element_smob, SCM axis)
   Axis a = (Axis) scm_to_int (axis);
   Grob *him = me->get_parent (a);
   Interval he = him->extent (him, a);
-  
-  SCM sym= (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
+
+  SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
     : ly_symbol2scm ("self-alignment-Y");
   SCM align_prop (me->internal_get_property (sym));
 
-  if (!ly_c_number_p (align_prop))
-    return scm_int2num (0);
+  if (!scm_is_number (align_prop))
+    return scm_from_int (0);
 
   Real x = 0.0;
-  Real align = ly_scm2double (align_prop);
-      
+  Real align = scm_to_double (align_prop);
+
   Interval ext (me->extent (me, a));
   if (ext.is_empty ())
-    programming_error ("I'm empty. Can't align on self");
+    programming_error ("can't align on self: empty element");
   else
-    x -= ext.linear_combination (align) ;
+    x -= ext.linear_combination (align);
 
   if (!he.is_empty ())
     x += he.linear_combination (align);
 
-  return scm_make_real (x);
+  return scm_from_double (x);
 }
 
 /* Position centered on parent. */
 MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_other_axis_parent, 2);
 SCM
-Self_alignment_interface::centered_on_other_axis_parent (SCM element_smob, 
+Self_alignment_interface::centered_on_other_axis_parent (SCM element_smob,
                                                         SCM axis)
 {
   Grob *me = unsmob_grob (element_smob);
   Axis a = (Axis) scm_to_int (axis);
   Grob *him = me->get_parent (other_axis (a));
   Interval he = him->extent (him, a);
-  
-  return  scm_make_real (he.is_empty () ? 0.0 : he.center ());
+
+  return scm_from_double (he.is_empty () ? 0.0 : he.center ());
 }
 
 /** callback that centers the element on itself
@@ -76,22 +77,21 @@ Self_alignment_interface::aligned_on_self (SCM element_smob, SCM axis)
   Grob *me = unsmob_grob (element_smob);
   Axis a = (Axis) scm_to_int (axis);
 
-  SCM sym= (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
+  SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
     : ly_symbol2scm ("self-alignment-Y");
-  
+
   SCM align (me->internal_get_property (sym));
-  if (ly_c_number_p (align))
+  if (scm_is_number (align))
     {
       Interval ext (me->extent (me, a));
       if (ext.is_empty ())
-       programming_error ("I'm empty. Can't align on self");
+       programming_error ("can't align on self: empty element");
       else
-       return scm_make_real (- ext.linear_combination (ly_scm2double (align)));
+       return scm_from_double (- ext.linear_combination (scm_to_double (align)));
     }
-  return scm_make_real (0.0);
+  return scm_from_double (0.0);
 }
 
-
 ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
               "Position this object on itself and/or on its parent. To this end, the following functions "
               " are provided: \n"
@@ -105,6 +105,6 @@ ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
               " extent of the parent \n"
               "@item Self_alignment_interface::centered_on_other_axis_parent\n"
               " For X-axis, center on the Y-parent, and vice versa.\n "
-              "@end table\n", 
+              "@end table\n",
               "self-alignment-X self-alignment-Y");