LEFT | RIGHT |
1 /* | |
2 This file is part of LilyPond, the GNU music typesetter. | |
3 | |
4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | |
5 | |
6 LilyPond is free software: you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation, either version 3 of the License, or | |
9 (at your option) any later version. | |
10 | |
11 LilyPond is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | |
18 */ | |
19 | |
20 #include "span-bar.hh" | |
21 | |
22 #include "font-interface.hh" | |
23 #include "dimensions.hh" | |
24 #include "output-def.hh" | |
25 #include "stencil.hh" | |
26 #include "warn.hh" | |
27 #include "axis-group-interface.hh" | |
28 #include "bar-line.hh" | |
29 #include "grob.hh" | |
30 #include "pointer-group-interface.hh" | |
31 #include "staff-symbol-referencer.hh" | |
32 | |
33 void | |
34 Span_bar::add_bar (Grob *me, Grob *b) | |
35 { | |
36 Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b); | |
37 } | |
38 | |
39 MAKE_SCHEME_CALLBACK (Span_bar, center_on_spanned_callback, 1); | |
40 | |
41 /* Is the following routine used anywhere? */ | |
42 SCM | |
43 Span_bar::center_on_spanned_callback (SCM smob) | |
44 { | |
45 Grob *me = unsmob_grob (smob); | |
46 Interval i (get_spanned_interval (me)); | |
47 | |
48 /* Bar_line::print delivers a barline of y-extent (-h/2, h/2), so | |
49 we have to translate ourselves to be in the center of the | |
50 interval that we span. */ | |
51 if (i.is_empty ()) | |
52 { | |
53 me->suicide (); | |
54 return scm_from_double (0.0); | |
55 } | |
56 | |
57 return scm_from_double (i.center ()); | |
58 } | |
59 | |
60 void | |
61 Span_bar::notify_grobs_of_my_existence (Grob *me) | |
62 { | |
63 extract_grob_set (me, "elements", elts); | |
64 vector<Grob *> sortable (elts.begin (), elts.end ()); | |
65 vector_sort (sortable, Grob::vertical_less); | |
66 for (vsize i = 0; i < sortable.size (); i++) | |
67 sortable[i]->set_property ("has-span-bar", | |
68 scm_cons (i != sortable.size () - 1 ? me->self_sc
m () : scm_from_bool (false), | |
69 i != 0 ? me->self_scm () : scm_from_boo
l (false))); | |
70 } | |
71 | |
72 Interval | |
73 Span_bar::get_spanned_interval (Grob *me) | |
74 { | |
75 return ly_scm2interval (Axis_group_interface::generic_group_extent (me, Y_AXIS
)); | |
76 } | |
77 | |
78 ADD_INTERFACE (Span_bar, | |
79 "A bar line that is spanned between other barlines. This" | |
80 " interface is used for bar lines that connect different" | |
81 " staves.", | |
82 | |
83 /* properties */ | |
84 "glyph-name " | |
85 "elements " | |
86 "pure-Y-common " | |
87 "pure-relevant-grobs " | |
88 "pure-relevant-items " | |
89 "pure-relevant-spanners " | |
90 ); | |
91 | |
LEFT | RIGHT |