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"
Grob *common = common_refpoint_of_array (support, me->get_parent (a), a);
Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me);
- bool include_staff = false;
-
- if (staff_symbol
- && a == Y_AXIS)
- {
- if (scm_is_number (me->get_property ("staff-padding")))
- include_staff = true;
- }
+ bool include_staff =
+ staff_symbol
+ && a == Y_AXIS
+ && scm_is_number (me->get_property ("staff-padding"))
+ && !to_boolean (me->get_property ("quantize-position"));
Interval dim;
Interval staff_extents;
&& 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",
}
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);
Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
if (staff && a == Y_AXIS)
{
- if (scm_is_number (me->get_property ("staff-padding")))
- {
- Real padding
- = Staff_symbol_referencer::staff_space (me)
- * scm_to_double (me->get_property ("staff-padding"));
-
- Grob *common = me->common_refpoint (staff, Y_AXIS);
-
- Interval staff_size = staff->extent (common, Y_AXIS);
- Real diff = dir*staff_size[dir] + padding - dir * (o + iv[-dir]);
- o += dir * max (diff, 0.0);
- }
-
if (to_boolean (me->get_property ("quantize-position")))
{
Grob *common = me->common_refpoint (staff, Y_AXIS);
Real rounded = directed_round (position, dir);
Grob *head = me->get_parent (X_AXIS);
- if (rounded <= Staff_symbol_referencer::staff_radius (me)
+ if (rounded <= 2 * Staff_symbol_referencer::staff_radius (me)
|| (Note_head::has_interface (head)
&& sign (Staff_symbol_referencer::get_position (head)) == - dir))
{
o += dir * 0.5 * ss;
}
}
+ else if (scm_is_number (me->get_property ("staff-padding")))
+ {
+ Real padding
+ = Staff_symbol_referencer::staff_space (me)
+ * scm_to_double (me->get_property ("staff-padding"));
+
+ Grob *common = me->common_refpoint (staff, Y_AXIS);
+
+ Interval staff_size = staff->extent (common, Y_AXIS);
+ Real diff = dir*staff_size[dir] + padding - dir * (o + iv[-dir]);
+ o += dir * max (diff, 0.0);
+ }
}
return scm_from_double (o);
}
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 "
+ "side-axis "
"side-relative-direction "
"side-support-elements "
"slur-padding "