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 SCM s = get_elt_property ("collapse-height");
58 && get_spanned_interval ().length () < gh_scm2double (s))
60 set_elt_property ("transparent", SCM_BOOL_T);
65 Interval i (get_spanned_interval ());
66 translate_axis (i.center (), Y_AXIS);
70 Span_bar::evaluate_empty ()
72 if (!gh_pair_p (get_elt_property ("elements")))
74 set_elt_property ("transparent", SCM_BOOL_T);
79 SCM gl = get_elt_property ("glyph");
80 if (!gh_string_p (gl))
82 set_elt_property ("transparent", SCM_BOOL_T);
87 String type_str = ly_scm2string (gl);
92 else if (type_str== ":|")
96 else if (type_str== ":|:")
103 uhh. should do something with type_str ?!!
108 Span_bar::get_spanned_interval () const
112 for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
114 Score_element *bar = unsmob_element ( gh_car (s));
119 Score_element*common = common_refpoint (bar, Y_AXIS);
121 Interval iv (bar->extent(Y_AXIS));
124 Real y = bar->relative_coordinate (common, Y_AXIS)
125 - relative_coordinate (common, Y_AXIS);
127 y_int.unite (y + iv);
135 Span_bar::height_callback (Dimension_cache const *c)
137 Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
138 return s->get_spanned_interval ();
142 Span_bar::get_bar_size () const
144 Interval iv (get_spanned_interval ());
147 programming_error("Huh? My children deflated (FIXME)");
153 Span_bar::Span_bar ()
155 group (this).set_interface ();
156 dim_cache_[X_AXIS]->set_callback (width_callback);
157 dim_cache_[Y_AXIS]->set_callback (height_callback);