(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
+#include "dimension-cache.hh"
#include "span-bar.hh"
#include "lookup.hh"
#include "dimensions.hh"
#include "molecule.hh"
#include "align-element.hh"
#include "warn.hh"
+#include "group-interface.hh"
+
void
Span_bar::add_bar (Score_element*b)
{
- spanning_l_arr_.push (b);
- add_dependency (b);
-}
+ Group_interface gi (this);
+ gi.add_element (b);
-void
-Span_bar::do_substitute_element_pointer (Score_element*o, Score_element*n)
-{
- spanning_l_arr_.unordered_substitute (o, n);
+ add_dependency (b);
}
-void
-Span_bar::set_align (Align_element *a)
-{
- add_dependency (a);
-}
Interval
-Span_bar::do_width () const
+Span_bar::width_callback (Dimension_cache const * c)
{
- if (no_width_b_)
- {
- return Interval (0,0);
- }
-
- Molecule m = lookup_l ()->bar (type_str_, 40 PT);
+ Span_bar* s= dynamic_cast<Span_bar*> (c->element_l ());
+ Molecule m = s->lookup_l ()->bar (s->type_str_, 40 PT, s->paper_l ());
return m.extent (X_AXIS);
}
Bar::do_pre_processing ();
evaluate_empty ();
- translate_axis (extra_x_off_, X_AXIS);
- dim_cache_[Y_AXIS].set_empty (false); // a hack to make mark scripts work.
+ // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
}
void
Span_bar::do_post_processing ()
{
Bar::do_post_processing ();
+ Interval i(get_spanned_interval ());
+
+ translate_axis (i.center (), Y_AXIS);
}
void
Span_bar::evaluate_empty ()
{
- if (spanning_l_arr_.size () < 1)
+ if (!gh_pair_p (get_elt_property ("elements")))
{
- transparent_b_ = true;
- set_empty (true);
+ set_elt_property ("transparent", SCM_BOOL_T);
+ set_empty (X_AXIS);
+ set_empty (Y_AXIS);
}
if (type_str_.empty_b ())
{
- transparent_b_=true;
- set_empty (true);
+ set_elt_property ("transparent", SCM_BOOL_T);
+ set_empty (X_AXIS);
+ set_empty (Y_AXIS);
}
else if (type_str_ == "|:")
{
Span_bar::get_spanned_interval () const
{
Interval y_int;
- for (int i=0; i < spanning_l_arr_.size (); i++)
+
+ for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
{
- Dimension_cache*common =
- common_group (spanning_l_arr_[i], Y_AXIS);
-
- Real y = spanning_l_arr_[i]->dim_cache_[Y_AXIS].relative_coordinate (common)
- -dim_cache_[Y_AXIS].relative_coordinate (common);
+ Score_element *bar = unsmob_element ( gh_car (s));
+
+ if (!bar)
+ continue;
+
+ Score_element*common = common_refpoint (bar, Y_AXIS);
- y_int.unite (y + spanning_l_arr_[i]->extent(Y_AXIS));
+ Interval iv (bar->extent(Y_AXIS));
+ if (!iv.empty_b ())
+ {
+ Real y = bar->relative_coordinate (common, Y_AXIS)
+ - relative_coordinate (common, Y_AXIS);
+
+ y_int.unite (y + iv);
+ }
}
return y_int;
}
Interval
-Span_bar::do_height () const
+Span_bar::height_callback (Dimension_cache const *c)
{
- return get_spanned_interval ();
+ Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
+ return s->get_spanned_interval ();
}
Molecule*
Molecule*output = new Molecule;
if (!iv.empty_b())
{
- output->add_molecule (lookup_l ()->bar (type_str_, iv.length ()));
- output->translate_axis (iv.center (), Y_AXIS);
+ output->add_molecule (lookup_l ()->bar (type_str_, iv.length (), paper_l ()));
}
else
{
- warning("Huh? My children deflated (FIXME)");
+ programming_error("Huh? My children deflated (FIXME)");
}
return output;
}
Span_bar::Span_bar ()
{
type_str_ = "";
- extra_x_off_ = 0.0;
- no_width_b_ = false;
+ dim_cache_[X_AXIS]->set_callback (width_callback);
+ dim_cache_[Y_AXIS]->set_callback (height_callback);
}
+