]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/side-position-interface.cc
* scm/stencil.scm (stack-lines): return empty-stencil if argument
[lilypond.git] / lily / side-position-interface.cc
index 7ff38d6e4e686a1e03159a4594f62921cbde8f69..deaaf5f3aae4b941a1edfce62f8a0277a2c6f250 100644 (file)
@@ -6,10 +6,12 @@
   (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
-#include <math.h>              // ceil.
 
-#include "note-head.hh"
 #include "side-position-interface.hh"
+
+#include <cmath>               // ceil.
+
+#include "note-head.hh"
 #include "warn.hh"
 #include "warn.hh"
 #include "dimensions.hh"
@@ -17,6 +19,7 @@
 #include "group-interface.hh"
 #include "directional-element-interface.hh"
 #include "staff-symbol-referencer.hh"
+#include "string-convert.hh"
 
 void
 Side_position_interface::add_support (Grob*me, Grob*e)
@@ -60,12 +63,10 @@ Side_position_interface::aligned_on_support_extents (SCM element_smob, SCM axis)
 }
 
 
-/*
- Puts the element next to the support, optionally taking in
- account the extent of the support.
-*/
+/* Put the element next to the support, optionally taking in
+   account the extent of the support.  */
 SCM
-Side_position_interface::general_side_position (Grob * me, Axis a, bool use_extents)
+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");
@@ -84,7 +85,7 @@ Side_position_interface::general_side_position (Grob * me, Axis a, bool use_exte
     
   for (SCM s = support; s != SCM_EOL; s = scm_cdr (s))
     {
-      Grob * e  = unsmob_grob (scm_car (s));
+      Grob *e = unsmob_grob (scm_car (s));
       if (e)
        if (use_extents)
          dim.unite (e->extent (common, a));
@@ -96,14 +97,12 @@ Side_position_interface::general_side_position (Grob * me, Axis a, bool use_exte
     }
 
   if (dim.is_empty ())
-    {
-      dim = Interval (0,0);
-    }
+    dim = Interval (0, 0);
 
   Direction dir = Side_position_interface::get_direction (me);
     
-  Real off =  me->get_parent (a)->relative_coordinate (common, a);
-  Real  minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"),  -1);
+  Real off = me->get_parent (a)->relative_coordinate (common, a);
+  Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"),  -1);
 
   Real total_off = dim.linear_combination (dir) - off;
   total_off += dir * ss * robust_scm2double (me->get_property ("padding"), 0);
@@ -111,16 +110,18 @@ Side_position_interface::general_side_position (Grob * me, Axis a, bool use_exte
   if (minimum_space >= 0
       && dir
       && total_off * dir < minimum_space)
-    {
-      total_off = minimum_space * dir;
-    }
+    total_off = minimum_space * dir;
 
+  /* FIXME: 100CM should relate to paper size.  */
   if (fabs (total_off) > 100 CM)
-    programming_error ("Huh ? Improbable staff side dim.");
-
-
-  
-  
+    {
+      String msg
+       =  String_convert::form_string ("Improbable offset for grob %s: %f%s",
+                                       me->name ().to_str0 (), total_off,
+                                       INTERNAL_UNIT);
+      
+      programming_error (msg);
+    }
   return scm_make_real (total_off);
 }