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"
15 #include "group-interface.hh"
19 Span_bar::add_bar (Score_element*b)
21 Group_interface gi (this);
29 Span_bar::width_callback (Dimension_cache const * c)
31 Span_bar* s= dynamic_cast<Span_bar*> (c->element_l ());
32 String gl = ly_scm2string (s->get_elt_property ("glyph"));
36 Molecule m = s->compound_barline (gl, 40 PT);
38 return m.extent (X_AXIS);
42 Span_bar::before_line_breaking ()
46 Bar::before_line_breaking ();
48 // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
52 Span_bar::after_line_breaking ()
54 Bar::after_line_breaking ();
55 SCM s = get_elt_property ("collapse-height");
57 && get_spanned_interval ().length () < gh_scm2double (s))
59 set_elt_property ("transparent", SCM_BOOL_T);
64 Interval i (get_spanned_interval ());
65 translate_axis (i.center (), Y_AXIS);
69 Span_bar::evaluate_empty ()
71 if (!gh_pair_p (get_elt_property ("elements")))
73 set_elt_property ("transparent", SCM_BOOL_T);
78 SCM gl = get_elt_property ("glyph");
79 if (!gh_string_p (gl))
81 set_elt_property ("transparent", SCM_BOOL_T);
86 String type_str = ly_scm2string (gl);
91 else if (type_str== ":|")
95 else if (type_str== ":|:")
99 set_elt_property ("glyph", ly_str02scm (type_str.ch_C ()));
104 Span_bar::get_spanned_interval () const
108 for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
110 Score_element *bar = unsmob_element ( gh_car (s));
115 Score_element*common = common_refpoint (bar, Y_AXIS);
117 Interval iv (bar->extent(Y_AXIS));
120 Real y = bar->relative_coordinate (common, Y_AXIS)
121 - relative_coordinate (common, Y_AXIS);
123 y_int.unite (y + iv);
131 Span_bar::height_callback (Dimension_cache const *c)
133 Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
134 return s->get_spanned_interval ();
138 Span_bar::get_bar_size () const
140 Interval iv (get_spanned_interval ());
143 programming_error("Huh? My children deflated (FIXME)");
149 Span_bar::Span_bar ()
151 group (this).set_interface ();
152 dim_cache_[X_AXIS]->set_extent_callback (width_callback);
153 dim_cache_[Y_AXIS]->set_extent_callback (height_callback);