X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faxis-group-element.cc;h=081b42a22faee300ad1e5c6ac66dc0771df5fe8d;hb=d26be70e8f3942df6f13e25a7f79321b9b98d1a8;hp=8aa8263668e3f13dfc3cb3b6442d782e13ac9db0;hpb=1cf3d59c1559fb9774c4c1c8cae155cfe54a927c;p=lilypond.git diff --git a/lily/axis-group-element.cc b/lily/axis-group-element.cc index 8aa8263668..081b42a22f 100644 --- a/lily/axis-group-element.cc +++ b/lily/axis-group-element.cc @@ -3,41 +3,25 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1999 Han-Wen Nienhuys */ #include "axis-group-element.hh" -#include "graphical-axis-group.hh" - -void -Axis_group_element::do_unlink() -{ - remove_all(); -} - -void -Axis_group_element::do_junk_links() -{ - elem_l_arr_.set_size (0); -} - +#include "dimension-cache.hh" +#include "group-interface.hh" Link_array Axis_group_element::get_extra_dependencies() const { - return elem_l_arr (); + Link_array e(elem_l_arr ()); + return e; } Link_array Axis_group_element::elem_l_arr () const { - /* - ugh. I know - */ - Link_array r; - for (int i=0; i < elem_l_arr_.size (); i++) - r.push (elem_l_arr_[i]->access_Score_element()); - return r; + return + Group_interface__extract_elements (this, (Score_element*)0, "elements"); } Link_array @@ -45,11 +29,12 @@ Axis_group_element::get_children () { Link_array childs; Link_array elems = elem_l_arr (); + for (int i=0; i < elems.size (); i++) { Score_element* e = elems[i]; childs.push (e) ; - Axis_group_element * axis_group= e->access_Axis_group_element (); + Axis_group_element * axis_group= dynamic_cast (e); if (axis_group) childs.concat (axis_group->get_children ()); } @@ -57,30 +42,64 @@ Axis_group_element::get_children () return childs; } -void -Axis_group_element::do_print() const +Axis_group_element::Axis_group_element() { - Graphical_axis_group::do_print(); -} + axes_[0] = (Axis)-1 ; + axes_[1] = (Axis)-1 ; -Axis_group_element::Axis_group_element(Axis a1, Axis a2) - : Graphical_axis_group (a1,a2) -{ - transparent_b_ = true; + set_elt_property ("elements", SCM_EOL); + set_elt_property ("transparent", SCM_BOOL_T); } -Axis_group_element::Axis_group_element () - : Graphical_axis_group (X_AXIS, Y_AXIS) +void +Axis_group_element::set_axes (Axis a1, Axis a2) { - transparent_b_ = true; + axes_[0] = a1 ; + axes_[1] = a2 ; + if (a1 != X_AXIS && a2 != X_AXIS) + set_empty (X_AXIS); + if (a1 != Y_AXIS && a2 != Y_AXIS) + set_empty (Y_AXIS); + + dim_cache_[a1]->set_callback(extent_callback); + dim_cache_[a2]->set_callback (extent_callback); } -Axis_group_element* -Axis_group_element::access_Axis_group_element () +Interval +Axis_group_element::extent_callback (Dimension_cache const *c) { - return this; + Axis a = c->axis (); + Axis_group_element * me + = dynamic_cast (c->element_l ()); + + Interval r; + for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) + { + SCM e=gh_car (s); + Score_element * se = SMOB_TO_TYPE (Score_element, e); + + Interval dims = se->extent (a); + if (!dims.empty_b ()) + r.unite (dims + se->relative_coordinate (me, a)); + } + + return r; } -IMPLEMENT_IS_TYPE_B2(Axis_group_element, Score_element, Graphical_axis_group); +void +Axis_group_element::add_element (Score_element *e) +{ + used_b_ =true; + e->used_b_ = true; + + for (int i = 0; i < 2; i++) + { + if (!e->parent_l (axes_[i])) + e->set_parent (this, axes_[i]); + } + Group_interface gi (this); + gi.add_element (e); +} +