X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faxis-group-interface.cc;h=d590813abf5cedab94f4b9dd1df4582341ad3ca0;hb=e4597b9d661ccb3d1031b9e17ec0bcca2bfaa66d;hp=2c3a23601e12fea229d1fad7275bb1c17c02659d;hpb=36f6cd546770e38c6e2314404e21f1c89504eb7d;p=lilypond.git diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 2c3a23601e..d590813abf 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -3,11 +3,13 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2005 Han-Wen Nienhuys + (c) 2000--2006 Han-Wen Nienhuys */ #include "axis-group-interface.hh" +#include "pointer-group-interface.hh" +#include "grob.hh" #include "hara-kiri-group-spanner.hh" #include "warn.hh" @@ -17,7 +19,7 @@ Axis_group_interface::add_element (Grob *me, Grob *e) SCM axes = me->get_property ("axes"); if (!scm_is_pair (axes)) programming_error ("axes should be nonempty"); - + for (SCM ax = axes; ax != SCM_EOL; ax = scm_cdr (ax)) { Axis a = (Axis) scm_to_int (scm_car (ax)); @@ -25,33 +27,33 @@ Axis_group_interface::add_element (Grob *me, Grob *e) if (!e->get_parent (a)) e->set_parent (me, a); - e->internal_set_property ((a == X_AXIS) - ? ly_symbol2scm ("axis-group-parent-X") - : ly_symbol2scm ("axis-group-parent-Y"), - me->self_scm ()); + e->internal_set_object ((a == X_AXIS) + ? ly_symbol2scm ("axis-group-parent-X") + : ly_symbol2scm ("axis-group-parent-Y"), + me->self_scm ()); } + /* must be ordered, because Align_interface also uses + Axis_group_interface */ Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e); - me->add_dependency (e); } bool Axis_group_interface::has_axis (Grob *me, Axis a) { - /* - urg. FIXME, check for Hara_kiri_group_spanner shouldn't be necessary? - */ - return me->has_extent_callback (group_extent_callback_proc, a) - || (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a)); + SCM axes = me->get_property ("axes"); + + return (SCM_BOOL_F != scm_memq (scm_from_int (a), axes)); } Interval -Axis_group_interface::relative_group_extent (SCM elts, Grob *common, Axis a) +Axis_group_interface::relative_group_extent (vector const &elts, + Grob *common, Axis a) { Interval r; - for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s)) + for (vsize i = 0; i < elts.size (); i++) { - Grob *se = unsmob_grob (scm_car (s)); + Grob *se = elts[i]; Interval dims = se->extent (common, a); if (!dims.is_empty ()) r.unite (dims); @@ -59,17 +61,27 @@ Axis_group_interface::relative_group_extent (SCM elts, Grob *common, Axis a) return r; } - - -MAKE_SCHEME_CALLBACK (Axis_group_interface, group_extent_callback, 2); +MAKE_SCHEME_CALLBACK (Axis_group_interface, width, 1); SCM -Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) +Axis_group_interface::width (SCM smob) { - Grob *me = unsmob_grob (element_smob); - Axis a = (Axis) scm_to_int (scm_axis); + Grob *me = unsmob_grob (smob); + return generic_group_extent (me, X_AXIS); +} - SCM elts = me->get_property ("elements"); - Grob *common = common_refpoint_of_list (elts, me, a); +MAKE_SCHEME_CALLBACK (Axis_group_interface, height, 1); +SCM +Axis_group_interface::height (SCM smob) +{ + Grob *me = unsmob_grob (smob); + return generic_group_extent (me, Y_AXIS); +} + +SCM +Axis_group_interface::generic_group_extent (Grob *me, Axis a) +{ + extract_grob_set (me, "elements", elts); + Grob *common = common_refpoint_of_array (elts, me, a); Real my_coord = me->relative_coordinate (common, a); Interval r (relative_group_extent (elts, common, a)); @@ -78,56 +90,25 @@ Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) } void -Axis_group_interface::set_axes (Grob *me, Axis a1, Axis a2) +Axis_group_interface::get_children (Grob *me, vector *found) { - SCM sa1 = scm_int2num (a1); - SCM sa2 = scm_int2num (a2); - - SCM axes = me->get_property ("axes"); - - if (!scm_is_pair (axes) - || scm_c_memq (sa1, axes) == SCM_BOOL_F - || scm_c_memq (sa2, axes) == SCM_BOOL_F) - { - SCM ax = scm_cons (sa1, SCM_EOL); - if (a1 != a2) - ax = scm_cons (sa2, ax); - me->set_property ("axes", ax); - } - - if (a1 != X_AXIS && a2 != X_AXIS) - me->set_extent (SCM_EOL, X_AXIS); - if (a1 != Y_AXIS && a2 != Y_AXIS) - me->set_extent (SCM_EOL, Y_AXIS); - - /* - why so convoluted ? (fixme/documentme?) - */ - if (me->has_extent_callback (Grob::stencil_extent_proc, a1)) - me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a1); - if (me->has_extent_callback (Grob::stencil_extent_proc, a2)) - me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a2); -} - -Link_array -Axis_group_interface::get_children (Grob *me) -{ - Link_array childs; - childs.push (me); + found->push_back (me); if (!has_interface (me)) - return childs; + return; - for (SCM ep = me->get_property ("elements"); scm_is_pair (ep); ep = scm_cdr (ep)) + extract_grob_set (me, "elements", elements); + for (vsize i = 0; i < elements.size (); i++) { - Grob *e = unsmob_grob (scm_car (ep)); - if (e) - childs.concat (Axis_group_interface::get_children (e)); + Grob *e = elements[i]; + Axis_group_interface::get_children (e, found); } - - return childs; } ADD_INTERFACE (Axis_group_interface, "axis-group-interface", + "An object that groups other layout objects.", - "axes elements"); + + /* properties */ + "axes " + "elements ");