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>
11 #include "dimensions.hh"
12 #include "paper-def.hh"
13 #include "molecule.hh"
15 #include "axis-group-interface.hh"
16 #include "group-interface.hh"
17 #include "score-element.hh"
21 Span_bar::add_bar (Score_element*me, Score_element*b)
23 Pointer_group_interface gi (me);
26 me->add_dependency (b);
30 Span_bar::width_callback (Score_element *se, Axis )
32 String gl = ly_scm2string (se->get_elt_property ("glyph"));
37 Molecule m = Bar::compound_barline (se, gl, 40 PT);
39 return m.extent (X_AXIS);
42 MAKE_SCHEME_CALLBACK(Span_bar,before_line_breaking);
44 Span_bar::before_line_breaking (SCM smob)
46 evaluate_empty (unsmob_element (smob));
47 evaluate_glyph (unsmob_element (smob));
50 no need to call Bar::before_line_breaking (), because the info
51 in ELEMENTS already has been procced by Bar::before_line_breaking().
53 return SCM_UNSPECIFIED;
57 Span_bar::center_on_spanned_callback (Score_element * me, Axis a)
60 Interval i (get_spanned_interval (me));
63 Bar::brew_molecule delivers a barline of y-extent (-h/2,h/2), so
64 we have to translate ourselves to be in the center of the
65 interval that we span. */
71 Span_bar::evaluate_empty (Score_element*me)
74 TODO: filter all hara-kiried out of ELEMENS list, and then
75 optionally do suicide. Call this cleanage function from
76 center_on_spanned_callback() as well.
79 if (!gh_pair_p (me->get_elt_property ("elements")))
86 Span_bar::evaluate_glyph (Score_element*me)
88 SCM elts = me->get_elt_property ("elements");
89 Score_element * b = unsmob_element (gh_car (elts));
90 SCM glsym =ly_symbol2scm ("glyph");
91 SCM gl =b ->get_elt_property (glsym);
92 if (!gh_string_p (gl))
98 String type = ly_scm2string (gl);
104 else if (type== ":|")
108 else if (type== ":|:")
113 gl = ly_str02scm (type.ch_C());
114 if (scm_equal_p (me->get_elt_property (glsym), gl) != SCM_BOOL_T)
115 me->set_elt_property (glsym, gl);
119 Span_bar::get_spanned_interval (Score_element*me)
121 return Axis_group_interface::group_extent_callback (me, Y_AXIS);
125 MAKE_SCHEME_CALLBACK(Span_bar,get_bar_size);
127 Span_bar::get_bar_size (SCM smob)
129 Score_element* me = unsmob_element (smob);
130 Interval iv (get_spanned_interval (me));
134 This happens if the bars are hara-kiried from under us.
137 return gh_double2scm (-1);
139 return gh_double2scm (iv.length ());
142 Span_bar::set_interface (Score_element *me)
144 Bar::set_interface (me);
146 Pointer_group_interface(me).set_interface ();
147 me->set_extent_callback (width_callback, X_AXIS);
148 me->add_offset_callback (center_on_spanned_callback, Y_AXIS);
149 me->set_interface (ly_symbol2scm ("span-bar-interface"));
150 me->set_extent_callback (0, Y_AXIS);
154 Span_bar::has_interface (Score_element*m)
156 return m && m->has_interface (ly_symbol2scm ("span-bar-interface"));