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 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);
62 SCM me = get_elt_property ("glyph");
63 if (gh_string_p (me) && ly_scm2string (me) == "bracket")
65 SCM e = get_elt_property ("other");
66 if (e != SCM_UNDEFINED)
68 assert (SMOB_IS_TYPE_B (Score_element, e));
69 Score_element* se = SMOB_TO_TYPE (Score_element, e);
70 SCM her = se->get_elt_property ("glyph");
72 // urg x-extent broken?
73 if (gh_string_p (her) && ly_scm2string (her) == "brace")
74 se->translate_axis (-extent (X_AXIS).length (), X_AXIS);
76 if (gh_string_p (her) && ly_scm2string (her) == "brace"
77 && !to_boolean (get_elt_property ("transparent")))
78 se->translate_axis (-paper_l ()->get_var ("interline"), X_AXIS);
85 Span_bar::evaluate_empty ()
87 if (!gh_pair_p (get_elt_property ("elements")))
89 set_elt_property ("transparent", SCM_BOOL_T);
94 SCM gl = get_elt_property ("glyph");
95 if (!gh_string_p (gl))
97 set_elt_property ("transparent", SCM_BOOL_T);
102 String type_str = ly_scm2string (gl);
103 if (type_str == "|:")
107 else if (type_str== ":|")
111 else if (type_str== ":|:")
119 Span_bar::get_spanned_interval () const
123 for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
125 Score_element *bar = unsmob_element ( gh_car (s));
130 Score_element*common = common_refpoint (bar, Y_AXIS);
132 Interval iv (bar->extent(Y_AXIS));
135 Real y = bar->relative_coordinate (common, Y_AXIS)
136 - relative_coordinate (common, Y_AXIS);
138 y_int.unite (y + iv);
145 Span_bar::height_callback (Dimension_cache const *c)
147 Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
148 return s->get_spanned_interval ();
152 Span_bar::do_brew_molecule_p () const
154 Interval iv (get_spanned_interval ());
155 Molecule*output = new Molecule;
156 SCM s = get_elt_property ("glyph");
157 if (gh_string_p (s) && !iv.empty_b())
159 output->add_molecule (lookup_l ()->bar (ly_scm2string (s),
165 programming_error("Huh? My children deflated (FIXME)");
172 Span_bar::Span_bar ()
174 dim_cache_[X_AXIS]->set_callback (width_callback);
175 dim_cache_[Y_AXIS]->set_callback (height_callback);