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"));
37 Molecule m = s->compound_barline (gl, 40 PT);
39 return m.extent (X_AXIS);
43 Span_bar::before_line_breaking ()
45 Bar::before_line_breaking ();
49 // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
53 Span_bar::after_line_breaking ()
55 Bar::after_line_breaking ();
56 Interval i(get_spanned_interval ());
58 translate_axis (i.center (), Y_AXIS);
62 Span_bar::evaluate_empty ()
64 if (!gh_pair_p (get_elt_property ("elements")))
66 set_elt_property ("transparent", SCM_BOOL_T);
71 SCM gl = get_elt_property ("glyph");
72 if (!gh_string_p (gl))
74 set_elt_property ("transparent", SCM_BOOL_T);
79 String type_str = ly_scm2string (gl);
84 else if (type_str== ":|")
88 else if (type_str== ":|:")
95 uhh. should do something with type_str ?!!
100 Span_bar::get_spanned_interval () const
104 for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
106 Score_element *bar = unsmob_element ( gh_car (s));
111 Score_element*common = common_refpoint (bar, Y_AXIS);
113 Interval iv (bar->extent(Y_AXIS));
116 Real y = bar->relative_coordinate (common, Y_AXIS)
117 - relative_coordinate (common, Y_AXIS);
119 y_int.unite (y + iv);
127 Span_bar::height_callback (Dimension_cache const *c)
129 Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
130 return s->get_spanned_interval ();
134 Span_bar::get_bar_size () const
136 Interval iv (get_spanned_interval ());
139 programming_error("Huh? My children deflated (FIXME)");
145 Span_bar::Span_bar ()
147 group (this).set_interface ();
148 dim_cache_[X_AXIS]->set_callback (width_callback);
149 dim_cache_[Y_AXIS]->set_callback (height_callback);