X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faxis-group-interface.cc;h=4d734640edeaf8c63b116158ab6d1f2a064e6c17;hb=7095841e441b2ad2d8ca798e6d1d241e57bdd0c5;hp=b7a8ec5a2060660453d69d695dd888c4e6a88f30;hpb=94189ec2b8da6d7e89dc619c646a927adead9b19;p=lilypond.git diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index b7a8ec5a20..4d734640ed 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2001 Han-Wen Nienhuys + (c) 2000--2003 Han-Wen Nienhuys */ #include "hara-kiri-group-spanner.hh" @@ -13,20 +13,20 @@ void Axis_group_interface::add_element (Grob*me,Grob *e) { - for (SCM ax = me->get_grob_property ("axes"); ax != SCM_EOL ; ax = gh_cdr (ax)) + for (SCM ax = me->get_grob_property ("axes"); ax != SCM_EOL ; ax = ly_cdr (ax)) { - Axis a = (Axis) gh_scm2int (gh_car (ax)); + Axis a = (Axis) gh_scm2int (ly_car (ax)); - if (!e->parent_l (a)) + if (!e->get_parent (a)) e->set_parent (me, a); } - Pointer_group_interface::add_element (me, "elements", e); + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e); me->add_dependency (e); } bool -Axis_group_interface::axis_b (Grob*me,Axis a ) +Axis_group_interface::axis_b (Grob*me,Axis a) { /* urg. FIXME, check for Hara_kiri_group_spanner shouldn't be necessary? @@ -34,52 +34,44 @@ Axis_group_interface::axis_b (Grob*me,Axis a ) */ return me->has_extent_callback_b (group_extent_callback_proc, a) || - (me->has_extent_callback_b (Hara_kiri_group_spanner::y_extent_proc, a)); + (me->has_extent_callback_b (Hara_kiri_group_spanner::y_extent_proc, a)); } Interval Axis_group_interface::relative_group_extent (Axis a, Grob *common, SCM elts) { Interval r; - for (SCM s = elts; gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = elts; gh_pair_p (s); s = ly_cdr (s)) { - Grob * se = unsmob_grob (gh_car (s)); + Grob * se = unsmob_grob (ly_car (s)); Interval dims = se->extent (common, a); - if (!dims.empty_b ()) + if (!dims.is_empty ()) r.unite (dims); } return r; } -MAKE_SCHEME_CALLBACK(Axis_group_interface,group_extent_callback,2); +MAKE_SCHEME_CALLBACK (Axis_group_interface,group_extent_callback,2); SCM Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) { Grob *me = unsmob_grob (element_smob); Axis a = (Axis) gh_scm2int (scm_axis); - Grob * common =(Grob*) me; - - for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) - { - Grob * se = unsmob_grob (gh_car (s)); - common = se->common_refpoint (common, a); - } + SCM elts = me->get_grob_property ("elements"); + Grob * common = common_refpoint_of_list (elts, me, a); Real my_coord = me->relative_coordinate (common, a); - Interval r (relative_group_extent (a, common, me->get_grob_property ("elements"))); + Interval r (relative_group_extent (a, common,elts)); return ly_interval2scm (r - my_coord); } - - void Axis_group_interface::set_axes (Grob*me,Axis a1, Axis a2) { - // set_interface () ? - SCM sa1= gh_int2scm (a1); - SCM sa2 = gh_int2scm (a2); + SCM sa1= scm_int2num (a1); + SCM sa2 = scm_int2num (a2); SCM axes = me->get_grob_property ("axes"); @@ -94,17 +86,17 @@ Axis_group_interface::set_axes (Grob*me,Axis a1, Axis a2) } if (a1 != X_AXIS && a2 != X_AXIS) - me->set_extent_callback (SCM_EOL, X_AXIS); + me->set_extent (SCM_EOL, X_AXIS); if (a1 != Y_AXIS && a2 != Y_AXIS) - me->set_extent_callback (SCM_EOL, Y_AXIS); + me->set_extent (SCM_EOL, Y_AXIS); /* why so convoluted ? (fixme/documentme?) */ if (me->has_extent_callback_b (Grob::molecule_extent_proc, a1)) - me->set_extent_callback (Axis_group_interface::group_extent_callback_proc,a1); + me->set_extent (Axis_group_interface::group_extent_callback_proc,a1); if (me->has_extent_callback_b (Grob::molecule_extent_proc, a2)) - me->set_extent_callback (Axis_group_interface::group_extent_callback_proc,a2); + me->set_extent (Axis_group_interface::group_extent_callback_proc,a2); } Link_array @@ -116,9 +108,9 @@ Axis_group_interface::get_children (Grob*me) if (!has_interface (me)) return childs; - for (SCM ep = me->get_grob_property ("elements"); gh_pair_p (ep); ep = gh_cdr (ep)) + for (SCM ep = me->get_grob_property ("elements"); gh_pair_p (ep); ep = ly_cdr (ep)) { - Grob* e = unsmob_grob (gh_car (ep)); + Grob* e = unsmob_grob (ly_car (ep)); if (e) childs.concat (Axis_group_interface::get_children (e)); } @@ -126,19 +118,8 @@ Axis_group_interface::get_children (Grob*me) return childs; } -bool -Axis_group_interface::has_interface (Grob*me) -{ - return me && me->has_interface (ly_symbol2scm ("axis-group-interface")); -} - -void -Axis_group_interface::set_interface (Grob*me) -{ - if (!has_interface (me)) - { - me->set_interface (ly_symbol2scm ("axis-group-interface")); - } -} +ADD_INTERFACE (Axis_group_interface, "axis-group-interface", + "a group of coupled grobs", + "axes");