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) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1996--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 "time-signature.hh" | 20 #include "time-signature.hh" |
21 | 21 |
22 #include "grob.hh" | 22 #include "grob.hh" |
23 #include "font-interface.hh" | 23 #include "font-interface.hh" |
24 #include "international.hh" | 24 #include "international.hh" |
25 #include "output-def.hh" | 25 #include "output-def.hh" |
| 26 #include "staff-symbol.hh" |
26 #include "staff-symbol-referencer.hh" | 27 #include "staff-symbol-referencer.hh" |
27 #include "text-interface.hh" | 28 #include "text-interface.hh" |
28 #include "warn.hh" | 29 #include "warn.hh" |
29 | 30 |
30 /* | 31 /* |
31 TODO: | 32 TODO: |
32 | 33 |
33 this file should go ; The formatting can completely be done with | 34 this file should go ; The formatting can completely be done with |
34 markups. | 35 markups. |
35 */ | 36 */ |
(...skipping 14 matching lines...) Expand all Loading... |
50 } | 51 } |
51 | 52 |
52 Stencil m; | 53 Stencil m; |
53 if (st == ly_symbol2scm ("single-digit")) | 54 if (st == ly_symbol2scm ("single-digit")) |
54 m = numbered_time_signature (me, n, 0); | 55 m = numbered_time_signature (me, n, 0); |
55 else if (scm_is_symbol (st)) | 56 else if (scm_is_symbol (st)) |
56 m = special_time_signature (me, st, n, d); | 57 m = special_time_signature (me, st, n, d); |
57 else | 58 else |
58 m = numbered_time_signature (me, n, d); | 59 m = numbered_time_signature (me, n, d); |
59 | 60 |
60 if (Staff_symbol_referencer::line_count (me) % 2 == 0) | 61 /* |
61 m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS); | 62 position the signature centred on the staff line |
| 63 nearest to the middle of the staff |
| 64 */ |
| 65 if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) |
| 66 { |
| 67 std::vector<Real> const linepos = Staff_symbol::line_positions (staff); |
| 68 if (!linepos.empty ()) |
| 69 { |
| 70 Interval const span = Staff_symbol::line_span (staff); |
| 71 Real const mid = span.center (); |
| 72 Real pos = linepos.front (); |
| 73 Real dist = fabs (pos - mid); |
| 74 for (std::vector<Real>::const_iterator |
| 75 i = linepos.begin (), e = linepos.end (); |
| 76 ++i != e;) |
| 77 { |
| 78 double const d = fabs (*i - mid); |
| 79 if (d < dist) |
| 80 { |
| 81 pos = *i; |
| 82 dist = d; |
| 83 } |
| 84 } |
| 85 |
| 86 m.translate_axis |
| 87 (pos * Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS); |
| 88 } |
| 89 } |
62 | 90 |
63 return m.smobbed_copy (); | 91 return m.smobbed_copy (); |
64 } | 92 } |
65 | 93 |
66 Stencil | 94 Stencil |
67 Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d) | 95 Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d) |
68 { | 96 { |
69 string style = robust_symbol2string (scm_style, "default"); | 97 string style = robust_symbol2string (scm_style, "default"); |
70 | 98 |
71 if (style == "numbered") | 99 if (style == "numbered") |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 "All time signatures are typeset with a single digit, e.g.," | 180 "All time signatures are typeset with a single digit, e.g.," |
153 " 3/2 is written as 3.\n" | 181 " 3/2 is written as 3.\n" |
154 "@item numbered\n" | 182 "@item numbered\n" |
155 "All time signatures are typeset with two digits.\n" | 183 "All time signatures are typeset with two digits.\n" |
156 "@end table", | 184 "@end table", |
157 | 185 |
158 /* properties */ | 186 /* properties */ |
159 "fraction " | 187 "fraction " |
160 "style " | 188 "style " |
161 ); | 189 ); |
OLD | NEW |