X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faxis-group-interface.cc;h=b7ce9afd3d182f131551e21242801de50a4a9453;hb=821a5c58b0143163b399728165152e9fdd6b4c45;hp=00c4c8d32c02145beb4878160843d6cbeb8371af;hpb=b0064942493df77833e6e41e05d362850f4874b0;p=lilypond.git diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 00c4c8d32c..b7ce9afd3d 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -3,145 +3,123 @@ source file of the GNU LilyPond music typesetter - (c) 2000 Han-Wen Nienhuys + (c) 2000--2004 Han-Wen Nienhuys */ - +#include "hara-kiri-group-spanner.hh" #include "axis-group-interface.hh" -#include "score-element.hh" -#include "dimension-cache.hh" - -Axis_group_interface::Axis_group_interface (Score_element*s) -{ - elt_l_ = s; -} - -Axis_group_interface -Axis_group_interface (Score_element*s) -{ - return Axis_group_interface (s); -} +#include "grob.hh" void -Axis_group_interface::add_element (Score_element *e) +Axis_group_interface::add_element (Grob*me,Grob *e) { - for (SCM ax = elt_l_->get_elt_property ("axes"); ax != SCM_EOL ; ax = gh_cdr (ax)) + for (SCM ax = me->get_property ("axes"); ax != SCM_EOL ; ax = ly_cdr (ax)) { - Axis a = (Axis) gh_scm2int (gh_car (ax)); + Axis a = (Axis) ly_scm2int (ly_car (ax)); - if (!e->parent_l (a)) - e->set_parent (elt_l_, a); + if (!e->get_parent (a)) + e->set_parent (me, a); } - Pointer_group_interface (elt_l_).add_element (e); - elt_l_->add_dependency (e); + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e); + me->add_dependency (e); } - bool -Axis_group_interface::axis_b (Axis a )const +Axis_group_interface::has_axis (Grob*me,Axis a) { - return elt_l_->has_extent_callback_b (group_extent_callback, 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)); } Interval -Axis_group_interface::relative_group_extent (Axis a, Score_element *common, SCM elts) +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; ly_pair_p (s); s = ly_cdr (s)) { - Score_element * se = unsmob_element (gh_car (s)); - Interval dims = se->extent (a); - if (!dims.empty_b ()) - r.unite (dims + se->relative_coordinate (common, a)); + Grob * se = unsmob_grob (ly_car (s)); + Interval dims = se->extent (common, a); + if (!dims.is_empty ()) + r.unite (dims); } return r; } -Interval -Axis_group_interface::group_extent_callback (Score_element const*me, Axis a) +MAKE_SCHEME_CALLBACK (Axis_group_interface,group_extent_callback,2); +SCM +Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) { - Score_element * common =(Score_element*) me; + Grob *me = unsmob_grob (element_smob); + Axis a = (Axis) ly_scm2int (scm_axis); - for (SCM s = me->get_elt_pointer ("elements"); gh_pair_p (s); s = gh_cdr (s)) - { - Score_element * se = unsmob_element (gh_car (s)); - common = se->common_refpoint (common, a); - } + SCM elts = me->get_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_elt_pointer ("elements"))); + Interval r (relative_group_extent (a, common, elts)); - return r - my_coord; + return ly_interval2scm (r - my_coord); } void -Axis_group_interface::set_interface () +Axis_group_interface::set_axes (Grob*me,Axis a1, Axis a2) { - if (!has_interface_b ()) - { - elt_l_->set_elt_pointer ("elements", SCM_EOL); + SCM sa1= scm_int2num (a1); + SCM sa2 = scm_int2num (a2); - - Group_interface (elt_l_, "interfaces").add_thing (ly_symbol2scm ("Axis_group")); - } -} - -void -Axis_group_interface::set_axes (Axis a1, Axis a2) -{ - // set_interface () ? - SCM sa1= gh_int2scm (a1); - SCM sa2 = gh_int2scm (a2); - - SCM prop = elt_l_->get_elt_property ("axes"); + SCM axes = me->get_property ("axes"); - if (prop == SCM_UNDEFINED - || scm_memq (sa1, prop) == SCM_BOOL_F - || scm_memq (sa2, prop) == SCM_BOOL_F) + if (!ly_pair_p (axes) + || scm_c_memq (sa1, axes) == SCM_BOOL_F + || scm_c_memq (sa2, axes) == SCM_BOOL_F) { - SCM ax = gh_cons (sa1, SCM_EOL); + SCM ax = scm_cons (sa1, SCM_EOL); if (a1 != a2) - ax= gh_cons (sa2, ax); - elt_l_->set_elt_property ("axes", ax); + ax= scm_cons (sa2, ax); + me->set_property ("axes", ax); } if (a1 != X_AXIS && a2 != X_AXIS) - elt_l_->set_extent_callback (0, X_AXIS); + me->set_extent (SCM_EOL, X_AXIS); if (a1 != Y_AXIS && a2 != Y_AXIS) - elt_l_->set_extent_callback (0, Y_AXIS); - - elt_l_->set_extent_callback (Axis_group_interface::group_extent_callback,a1); - elt_l_->set_extent_callback (Axis_group_interface::group_extent_callback,a2); + 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 (Axis_group_interface::group_extent_callback_proc,a1); + if (me->has_extent_callback (Grob::stencil_extent_proc, a2)) + me->set_extent (Axis_group_interface::group_extent_callback_proc,a2); } -Link_array -Axis_group_interface::get_children () +Link_array +Axis_group_interface::get_children (Grob*me) { - Link_array childs; - childs.push (elt_l_) ; + Link_array childs; + childs.push (me) ; - if (!has_interface_b ()) + if (!has_interface (me)) return childs; - for (SCM ep = elt_l_->get_elt_pointer ("elements"); gh_pair_p (ep); ep = gh_cdr (ep)) + for (SCM ep = me->get_property ("elements"); ly_pair_p (ep); ep = ly_cdr (ep)) { - Score_element* e = unsmob_element (gh_car (ep)); + Grob* e = unsmob_grob (ly_car (ep)); if (e) - childs.concat (Axis_group_interface (e).get_children ()); + childs.concat (Axis_group_interface::get_children (e)); } return childs; } -bool -Axis_group_interface::has_interface_b () -{ - SCM ifs = elt_l_->get_elt_property ("interfaces"); - - if (!gh_pair_p (ifs )) - return false; - return scm_memq (ly_symbol2scm ("Axis_group"),ifs) != SCM_BOOL_F; -} +ADD_INTERFACE (Axis_group_interface, "axis-group-interface", + "An object that groups other layout objects.", + "axes elements");