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 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 else | 243 else |
244 programming_error ("Note_column without first_head()"); | 244 programming_error ("Note_column without first_head()"); |
245 } | 245 } |
246 else | 246 else |
247 notedim.unite (notes[i]->extent (common, Y_AXIS)); | 247 notedim.unite (notes[i]->extent (common, Y_AXIS)); |
248 } | 248 } |
249 | 249 |
250 Real y = dir * max (0.0, | 250 Real y = dir * max (0.0, |
251 -dir * restdim[-dir] + dir * notedim[dir] + minimu
m_dist); | 251 -dir * restdim[-dir] + dir * notedim[dir] + minimu
m_dist); |
252 | 252 |
253 int stafflines = Staff_symbol_referencer::line_count (me); | |
254 if (!stafflines) | |
255 { | |
256 programming_error ("no staff line count"); | |
257 stafflines = 5; | |
258 } | |
259 | |
260 // move discretely by half spaces. | 253 // move discretely by half spaces. |
261 int discrete_y = dir * int (ceil (y / (0.5 * dir * staff_space))); | 254 int discrete_y = dir * int (ceil (y / (0.5 * dir * staff_space))); |
262 | 255 |
| 256 Interval staff_span = Staff_symbol_referencer::staff_span (rest); |
| 257 staff_span.widen (1); |
263 // move by whole spaces inside the staff. | 258 // move by whole spaces inside the staff. |
264 if (fabs (Staff_symbol_referencer::get_position (rest) | 259 if (staff_span.contains |
265 + discrete_y) < stafflines + 1) | 260 (Staff_symbol_referencer::get_position (rest) + discrete_y)) |
266 { | 261 { |
267 discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0); | 262 discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0); |
268 } | 263 } |
269 | 264 |
270 Rest::translate (rest, discrete_y); | 265 Rest::translate (rest, discrete_y); |
271 if (rcount[dir]++) | 266 if (rcount[dir]++) |
272 rest->warning (_ ("too many colliding rests")); | 267 rest->warning (_ ("too many colliding rests")); |
273 } | 268 } |
274 } | 269 } |
275 return SCM_BOOL_T; | 270 return SCM_BOOL_T; |
276 } | 271 } |
277 | 272 |
278 ADD_INTERFACE (Rest_collision, | 273 ADD_INTERFACE (Rest_collision, |
279 "Move ordinary rests (not multi-measure nor pitched rests)" | 274 "Move ordinary rests (not multi-measure nor pitched rests)" |
280 " to avoid conflicts.", | 275 " to avoid conflicts.", |
281 | 276 |
282 /* properties */ | 277 /* properties */ |
283 "minimum-distance " | 278 "minimum-distance " |
284 "positioning-done " | 279 "positioning-done " |
285 "elements " | 280 "elements " |
286 ); | 281 ); |
287 | 282 |
OLD | NEW |