2 span-bar.cc -- implement Span_bar
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 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 String gl = ly_scm2string (s->get_elt_property ("glyph"));
35 Molecule m = s->lookup_l ()->bar (gl, 40 PT, s->paper_l ());
37 return m.extent (X_AXIS);
41 Span_bar::do_pre_processing ()
43 Bar::do_pre_processing ();
47 // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
51 Span_bar::do_post_processing ()
53 Bar::do_post_processing ();
54 Interval i(get_spanned_interval ());
56 translate_axis (i.center (), Y_AXIS);
60 Span_bar::evaluate_empty ()
62 if (!gh_pair_p (get_elt_property ("elements")))
64 set_elt_property ("transparent", SCM_BOOL_T);
69 SCM gl = get_elt_property ("glyph");
70 if (!gh_string_p (gl))
72 set_elt_property ("transparent", SCM_BOOL_T);
77 String type_str = ly_scm2string (gl);
82 else if (type_str== ":|")
86 else if (type_str== ":|:")
94 Span_bar::get_spanned_interval () const
98 for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
100 Score_element *bar = unsmob_element ( gh_car (s));
105 Score_element*common = common_refpoint (bar, Y_AXIS);
107 Interval iv (bar->extent(Y_AXIS));
110 Real y = bar->relative_coordinate (common, Y_AXIS)
111 - relative_coordinate (common, Y_AXIS);
113 y_int.unite (y + iv);
120 Span_bar::height_callback (Dimension_cache const *c)
122 Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
123 return s->get_spanned_interval ();
127 Span_bar::do_brew_molecule () const
129 Interval iv (get_spanned_interval ());
131 SCM s = get_elt_property ("glyph");
132 if (gh_string_p (s) && !iv.empty_b())
134 output.add_molecule (lookup_l ()->bar (ly_scm2string (s),
140 programming_error("Huh? My children deflated (FIXME)");
147 Span_bar::Span_bar ()
149 dim_cache_[X_AXIS]->set_callback (width_callback);
150 dim_cache_[Y_AXIS]->set_callback (height_callback);