source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#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 "axis-group-element.hh"
+#include "dimension-cache.hh"
Link_array<Score_element>
Axis_group_element::get_extra_dependencies() const
{
- return elem_l_arr ();
+ Link_array<Score_element> e(elem_l_arr ());
+ return e;
}
Link_array<Score_element>
ugh. I know
*/
Link_array<Score_element> r;
- for (int i=0; i < elem_l_arr_.size (); i++)
- r.push (dynamic_cast<Score_element*>(elem_l_arr_[i]));
+ for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
+ {
+ SCM e=gh_car (s);
+ r.push (unsmob_element (e));
+ }
return r;
}
{
Link_array<Score_element> childs;
Link_array<Score_element> elems = elem_l_arr ();
+
for (int i=0; i < elems.size (); i++)
{
Score_element* e = elems[i];
return childs;
}
+Axis_group_element::Axis_group_element()
+{
+ axes_[0] = (Axis)-1 ;
+ axes_[1] = (Axis)-1 ;
+
+ set_elt_property ("elements", SCM_EOL);
+ set_elt_property ("transparent", SCM_BOOL_T);
+}
+
void
-Axis_group_element::do_print() const
+Axis_group_element::set_axes (Axis a1, Axis a2)
{
- Graphical_axis_group::do_print();
+ 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(Axis a1, Axis a2)
- : Graphical_axis_group (a1,a2)
+Interval
+Axis_group_element::extent_callback (Dimension_cache const *c)
{
- transparent_b_ = true;
+ Axis a = c->axis ();
+ Axis_group_element * me
+ = dynamic_cast<Axis_group_element*> (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;
}
-Axis_group_element::Axis_group_element ()
- : Graphical_axis_group (X_AXIS, Y_AXIS)
+
+/*
+ UGH.
+ */
+void
+Axis_group_element::add_extra_element (Score_element *e)
{
- transparent_b_ = true;
+ add_element (e);
}
-Axis_group_element*
-Axis_group_element::access_Axis_group_element ()
+
+void
+Axis_group_element::add_element (Score_element *e)
{
- return this;
+ 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]);
+ }
+ set_elt_property ("elements",
+ gh_cons (e->self_scm_,
+ get_elt_property ("elements")));
+
+ assert (e->parent_l(Y_AXIS) == this || e->parent_l (X_AXIS) == this);
}
-IMPLEMENT_IS_TYPE_B2(Axis_group_element, Score_element, Graphical_axis_group);
+
+
+
+