2 span-bar.cc -- implement Span_bar
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "dimension-cache.hh"
11 #include "dimensions.hh"
12 #include "paper-def.hh"
13 #include "molecule.hh"
14 #include "align-element.hh"
16 #include "group-interface.hh"
20 Span_bar::add_bar (Score_element*b)
22 Group_interface gi (this);
30 Span_bar::width_callback (Dimension_cache const * c)
32 Span_bar* s= dynamic_cast<Span_bar*> (c->element_l ());
33 Molecule m = s->lookup_l ()->bar (s->type_str_, 40 PT, s->paper_l ());
35 return m.extent (X_AXIS);
39 Span_bar::do_pre_processing ()
41 Bar::do_pre_processing ();
45 // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
49 Span_bar::do_post_processing ()
51 Bar::do_post_processing ();
52 Interval i(get_spanned_interval ());
54 translate_axis (i.center (), Y_AXIS);
58 Span_bar::evaluate_empty ()
60 if (!gh_pair_p (get_elt_property ("elements")))
62 set_elt_property ("transparent", SCM_BOOL_T);
66 if (type_str_.empty_b ())
68 set_elt_property ("transparent", SCM_BOOL_T);
72 else if (type_str_ == "|:")
76 else if (type_str_ == ":|")
80 else if (type_str_ == ":|:")
87 Span_bar::get_spanned_interval () const
91 for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
93 Score_element *bar = unsmob_element ( gh_car (s));
98 Score_element*common = common_refpoint (bar, Y_AXIS);
100 Interval iv (bar->extent(Y_AXIS));
103 Real y = bar->relative_coordinate (common, Y_AXIS)
104 - relative_coordinate (common, Y_AXIS);
106 y_int.unite (y + iv);
113 Span_bar::height_callback (Dimension_cache const *c)
115 Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
116 return s->get_spanned_interval ();
120 Span_bar::do_brew_molecule_p () const
122 Interval iv (get_spanned_interval ());
123 Molecule*output = new Molecule;
126 output->add_molecule (lookup_l ()->bar (type_str_, iv.length (), paper_l ()));
130 programming_error("Huh? My children deflated (FIXME)");
137 Span_bar::Span_bar ()
140 dim_cache_[X_AXIS]->set_callback (width_callback);
141 dim_cache_[Y_AXIS]->set_callback (height_callback);