source file of the GNU LilyPond music typesetter
- (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "side-position-interface.hh"
#include "note-head.hh"
#include "warn.hh"
-#include "warn.hh"
-#include "dimensions.hh"
+#include "main.hh"
#include "staff-symbol-referencer.hh"
#include "pointer-group-interface.hh"
#include "directional-element-interface.hh"
void
Side_position_interface::add_support (Grob *me, Grob *e)
{
- Pointer_group_interface::add_grob (me, ly_symbol2scm ("side-support-elements"), e);
+ Pointer_group_interface::add_unordered_grob (me, ly_symbol2scm ("side-support-elements"), e);
}
Direction
dim.unite (staff_extents);
}
- for (int i = 0; i < support.size (); i++)
+ for (vsize i = 0; i < support.size (); i++)
{
Grob *e = support[i];
if (e)
&& total_off * dir < minimum_space)
total_off = minimum_space * dir;
- /* FIXME: 100CM should relate to paper size. */
- if (fabs (total_off) > 100 CM)
+ /* FIXME: 1000 should relate to paper size. */
+ if (fabs (total_off) > 1000)
{
- String msg
- = String_convert::form_string ("Improbable offset for grob %s: %f%s",
- me->name ().to_str0 (), total_off,
- INTERNAL_UNIT);
+ string msg
+ = String_convert::form_string ("Improbable offset for grob %s: %f",
+ me->name ().c_str (), total_off);
programming_error (msg);
+ if (strict_infinity_checking)
+ scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL);
}
return scm_from_double (total_off);
}
MAKE_SCHEME_CALLBACK (Side_position_interface, y_aligned_on_support_refpoints, 1);
+
SCM
Side_position_interface::y_aligned_on_support_refpoints (SCM smob)
{
}
SCM
-Side_position_interface::aligned_side (Grob*me, Axis a)
+Side_position_interface::aligned_side (Grob *me, Axis a)
{
Direction dir = get_grob_direction (me);
Real position = 2 * (my_off + o - staff_off) / ss;
Real rounded = directed_round (position, dir);
Grob *head = me->get_parent (X_AXIS);
-
- if (rounded <= Staff_symbol_referencer::staff_radius (me)
+
+ if (fabs (position) <= 2 * Staff_symbol_referencer::staff_radius (me) + 1
|| (Note_head::has_interface (head)
&& sign (Staff_symbol_referencer::get_position (head)) == - dir))
{
- o += dir *(rounded - position) * 0.5 * ss;
- if (Staff_symbol_referencer::on_staffline (me, int (rounded)))
+ o += (rounded - position) * 0.5 * ss;
+ if (Staff_symbol_referencer::on_line (me, int (rounded)))
o += dir * 0.5 * ss;
}
}
void
Side_position_interface::set_axis (Grob *me, Axis a)
{
- add_offset_callback (me,
- (a==X_AXIS)
- ? x_aligned_side_proc
- : y_aligned_side_proc,
- a);
+ if (!scm_is_number (me->get_property ("side-axis")))
+ {
+ me->set_property ("side-axis", scm_from_int (a));
+ add_offset_callback (me,
+ (a==X_AXIS)
+ ? x_aligned_side_proc
+ : y_aligned_side_proc,
+ a);
+ }
}
-
-// ugh. doesn't catch all variants.
Axis
Side_position_interface::get_axis (Grob *me)
{
- if (me->get_property_data (ly_symbol2scm ("X-offset"))
- == Side_position_interface::x_aligned_side_proc)
- return X_AXIS;
- else if (me->get_property_data (ly_symbol2scm ("Y-offset"))
- == Side_position_interface::y_aligned_side_proc)
- return Y_AXIS;
-
+ if (scm_is_number (me->get_property ("side-axis")))
+ return Axis (scm_to_int (me->get_property ("side-axis")));
+
+ me->programming_error ("side-axis not set.");
return NO_AXES;
}
"direction-source "
"minimum-space "
"padding "
+ "quantize-position "
+ "side-axis "
"side-relative-direction "
"side-support-elements "
"slur-padding "
"staff-padding "
- "quantize-position "
);