LEFT | RIGHT |
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--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1996--2011 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 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 pure_property_cache_ = SCM_UNDEFINED; | 226 pure_property_cache_ = SCM_UNDEFINED; |
227 } | 227 } |
228 | 228 |
229 Spanner::Spanner (Spanner const &s) | 229 Spanner::Spanner (Spanner const &s) |
230 : Grob (s) | 230 : Grob (s) |
231 { | 231 { |
232 spanned_drul_.set (0, 0); | 232 spanned_drul_.set (0, 0); |
233 pure_property_cache_ = SCM_UNDEFINED; | 233 pure_property_cache_ = SCM_UNDEFINED; |
234 } | 234 } |
235 | 235 |
| 236 /* |
| 237 Certain spanners have pre-computed X values that lie either in |
| 238 X-positions or the X key of the alists returned for left-bound-info |
| 239 and right-bound-info. These are calculated to give the real length |
| 240 of a spanner (which, because of various padding or overhang properties, |
| 241 can extend pass or arrive short of a given bound). If possible, we |
| 242 use these to calculate the spanner's length, and otherwise, we use |
| 243 the bound. |
| 244 |
| 245 For those writing a new spanner, DO NOT use both X-positions and |
| 246 left-bound-info/right-bound-info. |
| 247 */ |
236 Real | 248 Real |
237 Spanner::spanner_length () const | 249 Spanner::spanner_length () const |
238 { | 250 { |
239 Interval lr = robust_scm2interval (get_property ("X-positions"), | 251 Interval lr = robust_scm2interval (get_property ("X-positions"), |
240 Interval (1,-1)); | 252 Interval (1,-1)); |
241 | 253 |
242 if (lr.is_empty ()) | 254 if (lr.is_empty ()) |
243 { | 255 { |
244 Drul_array<SCM> bounds (get_property ("left-bound-info"), | 256 Drul_array<SCM> bounds (get_property ("left-bound-info"), |
245 get_property ("right-bound-info")); | 257 get_property ("right-bound-info")); |
246 | 258 |
247 Direction d = LEFT; | 259 Direction d = LEFT; |
248 do | 260 do |
249 lr[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), | 261 lr[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), |
250 bounds[d], SCM_BOOL_F), -d); | 262 bounds[d], SCM_BOOL_F), -d); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 " on the right. The left bound is also the X@tie{}reference" | 558 " on the right. The left bound is also the X@tie{}reference" |
547 " point of the spanner.", | 559 " point of the spanner.", |
548 | 560 |
549 /* properties */ | 561 /* properties */ |
550 "normalized-endpoints " | 562 "normalized-endpoints " |
551 "minimum-length " | 563 "minimum-length " |
552 "spanner-broken " | 564 "spanner-broken " |
553 "spanner-id " | 565 "spanner-id " |
554 "to-barline " | 566 "to-barline " |
555 ); | 567 ); |
LEFT | RIGHT |