(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"
#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)
}
-/*
- 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");
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));
}
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);
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);
}