Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 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 | 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 | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
11 LilyPond is distributed in the hope that it will be useful, | 11 LilyPond is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 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/>. | 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
20 #include "bar-line.hh" | 20 #include "bar-line.hh" |
21 | 21 |
22 #include "all-font-metrics.hh" | 22 #include "all-font-metrics.hh" |
23 #include "font-interface.hh" | 23 #include "font-interface.hh" |
24 #include "line-interface.hh" | 24 #include "line-interface.hh" |
25 #include "lookup.hh" | 25 #include "lookup.hh" |
26 #include "output-def.hh" | 26 #include "output-def.hh" |
27 #include "paper-column.hh" | 27 #include "paper-column.hh" |
28 #include "staff-symbol.hh" | |
28 #include "staff-symbol-referencer.hh" | 29 #include "staff-symbol-referencer.hh" |
29 | 30 |
31 #include <set> | |
32 | |
33 | |
30 MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_extent, 1) | 34 MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_extent, 1) |
31 SCM | 35 SCM |
32 Bar_line::calc_bar_extent (SCM smob) | 36 Bar_line::calc_bar_extent (SCM smob) |
33 { | 37 { |
34 Interval result; | 38 Interval result; |
35 Grob *me = unsmob_grob (smob); | 39 Grob *me = unsmob_grob (smob); |
36 if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) | 40 if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) |
37 { | 41 { |
38 result = staff->extent (staff, Y_AXIS); | 42 result = staff->extent (staff, Y_AXIS); |
39 | 43 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 | 109 |
106 kern *= staffline; | 110 kern *= staffline; |
107 thinkern *= staffline; | 111 thinkern *= staffline; |
108 hair *= staffline; | 112 hair *= staffline; |
109 fatline *= staffline; | 113 fatline *= staffline; |
110 | 114 |
111 Stencil thin = simple_barline (me, hair, extent, rounded); | 115 Stencil thin = simple_barline (me, hair, extent, rounded); |
112 Stencil thick = simple_barline (me, fatline, extent, rounded); | 116 Stencil thick = simple_barline (me, fatline, extent, rounded); |
113 Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot") ; | 117 Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot") ; |
114 | 118 |
115 int lines = Staff_symbol_referencer::line_count (me); | 119 /* |
116 Real dist | 120 the two dots of the repeat sign should be centred at the middle of |
117 = ((lines & 1 || lines == 0) | 121 the staff and both should avoid staff lines |
118 ? 1 | 122 */ |
119 : (staff_space < 2 ? 2 : .5)) * staff_space; | 123 Real centre = 0.0, dist = 1.0; |
124 if (staff_space) | |
125 { | |
126 if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) | |
127 { | |
128 std::vector<Real> linepos = Staff_symbol::line_positions (staff); | |
129 if (!linepos.empty ()) | |
130 { | |
131 centre = Staff_symbol::line_span (staff).center (); | |
132 | |
133 /* | |
134 fold the staff into two at centre and find the first gap | |
135 big enough to hold a dot and some space below and above | |
136 */ | |
137 std::set<Real> half_staff; | |
138 half_staff.insert (0.0); | |
139 for (std::vector<Real>::const_iterator | |
140 i = linepos.begin (), e = linepos.end (); | |
141 i != e; | |
142 ++i) | |
143 half_staff.insert (fabs (*i - centre)); | |
144 | |
145 /* | |
146 gap is measured like line-positions; | |
147 1.0 for dot diameter, twice the staffline width for the | |
148 gap above and below and one more staffline width for the | |
149 two half stafflines | |
150 */ | |
151 Real const gap_to_find = (1.0 + 3 * staffline) / staff_space; | |
Keith
2012/07/10 14:59:15
Pál, see new issue 2648 on the tracker.
The vario
Keith
2012/07/14 07:46:59
It seems you want
Real const gap_to_find = (dot.e
| |
152 dist = *half_staff.rbegin () * 2 + gap_to_find; | |
153 for (std::set<Real>::const_iterator | |
154 i0 = half_staff.begin (), i1 = i0, e = half_staff.end (); | |
155 ++i1 != e; | |
156 i0 = i1) | |
157 if (*i1 - *i0 > gap_to_find) | |
158 { | |
159 dist = *i0 + *i1; | |
160 break; | |
161 } | |
162 } | |
163 } | |
164 } | |
165 else | |
166 dist += 3 * staffline; | |
167 | |
168 if (staff_space == 0.0) | |
169 staff_space = 1.0; | |
170 | |
120 Stencil colon (dot); | 171 Stencil colon (dot); |
121 colon.translate_axis (dist, Y_AXIS); | 172 colon.translate_axis (dist * staff_space / 2, Y_AXIS); |
122 colon.add_stencil (dot); | 173 colon.add_stencil (dot); |
123 colon.translate_axis (-dist / 2, Y_AXIS); | 174 colon.translate_axis ((centre - dist / 2) * staff_space / 2, Y_AXIS); |
124 | 175 |
125 Real const h = extent.length (); | 176 Real const h = extent.length (); |
126 Stencil m; | 177 Stencil m; |
127 | 178 |
128 if (str == "||:") | 179 if (str == "||:") |
129 str = "|:"; | 180 str = "|:"; |
130 | 181 |
131 if (str == "|S" || str == "S|") | 182 if (str == "|S" || str == "S|") |
132 str = "S"; | 183 str = "S"; |
133 | 184 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 "gap " | 522 "gap " |
472 "kern " | 523 "kern " |
473 "thin-kern " | 524 "thin-kern " |
474 "hair-thickness " | 525 "hair-thickness " |
475 "has-span-bar " | 526 "has-span-bar " |
476 "thick-thickness " | 527 "thick-thickness " |
477 "glyph " | 528 "glyph " |
478 "glyph-name " | 529 "glyph-name " |
479 "bar-extent " | 530 "bar-extent " |
480 ); | 531 ); |
OLD | NEW |