]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/side-position-interface.cc
* lily/script-engraver.cc (make_script_from_event): don't trigger callback.
[lilypond.git] / lily / side-position-interface.cc
index d9689abaaa5466af9a5bd5db4b7f5faac3ebf75f..3546bc2b763222bc1de7a159a0fd25406a66806b 100644 (file)
@@ -8,22 +8,20 @@
 
 #include "side-position-interface.hh"
 
-#include <math.h>              // ceil.
+#include <cmath>               // ceil.
 #include <algorithm>
-
+using namespace std;
 
 #include "note-head.hh"
 #include "warn.hh"
 #include "warn.hh"
 #include "dimensions.hh"
 #include "staff-symbol-referencer.hh"
-#include "group-interface.hh"
+#include "pointer-group-interface.hh"
 #include "directional-element-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "string-convert.hh"
 
-using namespace std;
-
 void
 Side_position_interface::add_support (Grob *me, Grob *e)
 {
@@ -33,23 +31,15 @@ Side_position_interface::add_support (Grob *me, Grob *e)
 Direction
 Side_position_interface::get_direction (Grob *me)
 {
-  SCM d = me->get_property ("direction");
-  if (is_direction (d) && to_dir (d))
-    return to_dir (d);
-
   Direction relative_dir = Direction (1);
   SCM reldir = me->get_property ("side-relative-direction");   // should use a lambda.
   if (is_direction (reldir))
-    {
-      relative_dir = to_dir (reldir);
-    }
+    relative_dir = to_dir (reldir);
 
-  SCM other_elt = me->get_property ("direction-source");
+  SCM other_elt = me->get_object ("direction-source");
   Grob *e = unsmob_grob (other_elt);
   if (e)
-    {
-      return (Direction) (relative_dir * get_grob_direction (e));
-    }
+    return (Direction) (relative_dir * get_grob_direction (e));
 
   return CENTER;
 }
@@ -70,8 +60,10 @@ SCM
 Side_position_interface::general_side_position (Grob *me, Axis a, bool use_extents)
 {
   Real ss = Staff_symbol_referencer::staff_space (me);
-  SCM support = me->get_property ("side-support-elements");
-  Grob *common = common_refpoint_of_list (support, me->get_parent (a), a);
+
+  extract_grob_set (me, "side-support-elements", support);
+
+  Grob *common = common_refpoint_of_array (support, me->get_parent (a), a);
   Grob *st = Staff_symbol_referencer::get_staff_symbol (me);
   bool include_staff = (st
                        && a == Y_AXIS
@@ -84,9 +76,9 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten
       dim = st->extent (common, Y_AXIS);
     }
 
-  for (SCM s = support; s != SCM_EOL; s = scm_cdr (s))
+  for (int i = 0; i < support.size (); i++)
     {
-      Grob *e = unsmob_grob (scm_car (s));
+      Grob *e = support[i];
       if (e)
        if (use_extents)
          dim.unite (e->extent (common, a));
@@ -100,7 +92,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten
   if (dim.is_empty ())
     dim = Interval (0, 0);
 
-  Direction dir = Side_position_interface::get_direction (me);
+  Direction dir = get_grob_direction (me);
 
   Real off = me->get_parent (a)->relative_coordinate (common, a);
   Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1);
@@ -123,7 +115,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten
 
       programming_error (msg);
     }
-  return scm_make_real (total_off);
+  return scm_from_double (total_off);
 }
 
 /*
@@ -160,7 +152,7 @@ Side_position_interface::quantised_position (SCM element_smob, SCM)
 {
   Grob *me = unsmob_grob (element_smob);
 
-  Direction d = Side_position_interface::get_direction (me);
+  Direction d = get_grob_direction (me);
 
   Grob *stsym = Staff_symbol_referencer::get_staff_symbol (me);
   if (stsym)
@@ -182,9 +174,9 @@ Side_position_interface::quantised_position (SCM element_smob, SCM)
          rp += d;
        }
 
-      return scm_make_real ((rp - p) * Staff_symbol_referencer::staff_space (me) / 2.0);
+      return scm_from_double ((rp - p) * Staff_symbol_referencer::staff_space (me) / 2.0);
     }
-  return scm_make_real (0.0);
+  return scm_from_double (0.0);
 }
 
 /*
@@ -197,8 +189,7 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis)
   Grob *me = unsmob_grob (element_smob);
   Axis a = (Axis) scm_to_int (axis);
 
-  Direction d = Side_position_interface::get_direction (me);
-
+  Direction d = get_grob_direction (me);
   Real o = scm_to_double (aligned_on_support_extents (element_smob, axis));
 
   Interval iv = me->extent (me, a);
@@ -233,7 +224,7 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis)
       o += d * max (diff, 0.0);
     }
 
-  return scm_make_real (o);
+  return scm_from_double (o);
 }
 
 void
@@ -259,5 +250,14 @@ ADD_INTERFACE (Side_position_interface, "side-position-interface",
               "victim object relative to the support (left or right, up or down?)\n\n "
               "The routine also takes the size the staff into account if "
               "@code{staff-padding} is set. If undefined, the staff symbol is ignored.",
-              "staff-padding side-support-elements direction-source "
-              "direction side-relative-direction minimum-space padding");
+
+              /* properties */
+              "direction "
+              "direction-source "
+              "minimum-space "
+              "padding "
+              "side-relative-direction "
+              "side-support-elements "
+              "slur-padding "
+              "staff-padding "
+              );