2 axis-group-interface.cc -- implement Axis_group_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "axis-group-interface.hh"
11 #include "pointer-group-interface.hh"
13 #include "hara-kiri-group-spanner.hh"
17 Axis_group_interface::add_element (Grob *me, Grob *e)
19 SCM axes = me->get_property ("axes");
20 if (!scm_is_pair (axes))
21 programming_error ("axes should be nonempty");
23 for (SCM ax = axes; ax != SCM_EOL; ax = scm_cdr (ax))
25 Axis a = (Axis) scm_to_int (scm_car (ax));
27 if (!e->get_parent (a))
28 e->set_parent (me, a);
30 e->internal_set_object ((a == X_AXIS)
31 ? ly_symbol2scm ("axis-group-parent-X")
32 : ly_symbol2scm ("axis-group-parent-Y"),
36 Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e);
40 Axis_group_interface::has_axis (Grob *me, Axis a)
42 SCM axes = me->get_property ("axes");
44 return (SCM_BOOL_F != scm_memq (scm_from_int (a), axes));
48 Axis_group_interface::relative_group_extent (Link_array<Grob> const &elts,
52 for (int i = 0; i < elts.size (); i++)
55 Interval dims = se->extent (common, a);
56 if (!dims.is_empty ())
62 MAKE_SCHEME_CALLBACK (Axis_group_interface, width, 1);
64 Axis_group_interface::width (SCM smob)
66 Grob *me = unsmob_grob (smob);
67 return generic_group_extent (me, X_AXIS);
70 MAKE_SCHEME_CALLBACK (Axis_group_interface, height, 1);
72 Axis_group_interface::height (SCM smob)
74 Grob *me = unsmob_grob (smob);
75 return generic_group_extent (me, Y_AXIS);
79 Axis_group_interface::generic_group_extent (Grob *me, Axis a)
81 extract_grob_set (me, "elements", elts);
82 Grob *common = common_refpoint_of_array (elts, me, a);
84 Real my_coord = me->relative_coordinate (common, a);
85 Interval r (relative_group_extent (elts, common, a));
87 return ly_interval2scm (r - my_coord);
91 Axis_group_interface::get_children (Grob *me, Link_array<Grob> *found)
95 if (!has_interface (me))
98 extract_grob_set (me, "elements", elements);
99 for (int i = 0; i < elements.size (); i++)
101 Grob *e = elements[i];
102 Axis_group_interface::get_children (e, found);
106 ADD_INTERFACE (Axis_group_interface, "axis-group-interface",
108 "An object that groups other layout objects.",