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) 1998--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1998--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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 extract_grob_set (me, "side-support-elements", support); | 169 extract_grob_set (me, "side-support-elements", support); |
170 | 170 |
171 Grob *common[2]; | 171 Grob *common[2]; |
172 for (Axis ax = X_AXIS; ax < NO_AXES; incr (ax)) | 172 for (Axis ax = X_AXIS; ax < NO_AXES; incr (ax)) |
173 common[ax] = common_refpoint_of_array (support, ax == a ? me->get_parent (ax
) : me, ax); | 173 common[ax] = common_refpoint_of_array (support, ax == a ? me->get_parent (ax
) : me, ax); |
174 | 174 |
175 Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me); | 175 Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me); |
176 Direction dir = get_grob_direction (me); | 176 Direction dir = get_grob_direction (me); |
177 | 177 |
178 Skyline my_dim; | 178 Skyline my_dim; |
179 Real skyline_padding = 0.1; | |
180 Skyline_pair *sp = Skyline_pair::unsmob (me->get_property ("vertical-skylines"
)); | 179 Skyline_pair *sp = Skyline_pair::unsmob (me->get_property ("vertical-skylines"
)); |
181 if (sp && a == Y_AXIS && !pure) | 180 if (sp && a == Y_AXIS && !pure) |
182 { | 181 { |
183 Skyline_pair copy = Skyline_pair (*sp); | 182 Skyline_pair copy = Skyline_pair (*sp); |
184 copy.shift (me->relative_coordinate (common[X_AXIS], X_AXIS)); | 183 copy.shift (me->relative_coordinate (common[X_AXIS], X_AXIS)); |
185 copy.raise (me->get_parent (Y_AXIS)->relative_coordinate (common[Y_AXIS],
Y_AXIS)); | 184 copy.raise (me->get_parent (Y_AXIS)->relative_coordinate (common[Y_AXIS],
Y_AXIS)); |
186 my_dim = copy[-dir]; | 185 my_dim = copy[-dir]; |
187 } | 186 } |
188 else | 187 else |
189 { | 188 { |
190 Box off; | 189 Box off; |
191 for (Axis ax = X_AXIS; ax < NO_AXES; incr (ax)) | 190 for (Axis ax = X_AXIS; ax < NO_AXES; incr (ax)) |
192 { | 191 { |
193 if (ax == a) | 192 if (ax == a) |
194 off[ax] = me->get_parent (ax)->maybe_pure_coordinate (common[ax], ax
, pure, start, end) | 193 off[ax] = me->get_parent (ax)->maybe_pure_coordinate (common[ax], ax
, pure, start, end) |
195 + me->maybe_pure_extent (me, ax, pure, start, end); | 194 + me->maybe_pure_extent (me, ax, pure, start, end); |
196 else | 195 else |
197 off[ax] = me->maybe_pure_extent (common[ax], ax, pure, start, end); | 196 off[ax] = me->maybe_pure_extent (common[ax], ax, pure, start, end); |
198 } | 197 } |
199 | 198 |
200 if (off[X_AXIS].is_empty () || off[Y_AXIS].is_empty ()) | 199 if (off[X_AXIS].is_empty () || off[Y_AXIS].is_empty ()) |
201 return scm_from_double (0.0); | 200 return scm_from_double (0.0); |
202 | 201 |
203 my_dim = Skyline (off, skyline_padding, other_axis (a), -dir); | 202 my_dim = Skyline (off, other_axis (a), -dir); |
204 } | 203 } |
205 bool include_staff | 204 bool include_staff |
206 = staff_symbol | 205 = staff_symbol |
207 && a == Y_AXIS | 206 && a == Y_AXIS |
208 && scm_is_number (me->get_property ("staff-padding")) | 207 && scm_is_number (me->get_property ("staff-padding")) |
209 && !to_boolean (me->get_property ("quantize-position")); | 208 && !to_boolean (me->get_property ("quantize-position")); |
210 | 209 |
211 vector<Box> boxes; | 210 vector<Box> boxes; |
212 vector<Skyline_pair> skyps; | 211 vector<Skyline_pair> skyps; |
213 Real min_h = dir == LEFT ? infinity_f : -infinity_f; | 212 Real min_h = dir == LEFT ? infinity_f : -infinity_f; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 275 |
277 if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ()) | 276 if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ()) |
278 continue; | 277 continue; |
279 | 278 |
280 big.unite (b); | 279 big.unite (b); |
281 } | 280 } |
282 if (!big[X_AXIS].is_empty () && !big[Y_AXIS].is_empty ()) | 281 if (!big[X_AXIS].is_empty () && !big[Y_AXIS].is_empty ()) |
283 boxes.push_back (big); | 282 boxes.push_back (big); |
284 } | 283 } |
285 | 284 |
286 Skyline dim (boxes, skyline_padding, other_axis (a), dir); | 285 Skyline dim (boxes, other_axis (a), dir); |
287 if (skyps.size ()) | 286 if (skyps.size ()) |
288 { | 287 { |
289 Skyline_pair merged (skyps, skyline_padding, other_axis (a)); | 288 Skyline_pair merged (skyps); |
290 dim.merge (merged[dir]); | 289 dim.merge (merged[dir]); |
291 } | 290 } |
292 if (!boxes.size ()) | 291 if (!boxes.size ()) |
293 dim.set_minimum_height (0.0); | 292 dim.set_minimum_height (0.0); |
294 else | 293 else |
295 dim.set_minimum_height (min_h); | 294 dim.set_minimum_height (min_h); |
296 | 295 |
297 if (include_staff) | 296 if (include_staff) |
298 { | 297 { |
299 Interval staff_extents; | 298 Interval staff_extents; |
300 common[Y_AXIS] = staff_symbol->common_refpoint (common[Y_AXIS], Y_AXIS); | 299 common[Y_AXIS] = staff_symbol->common_refpoint (common[Y_AXIS], Y_AXIS); |
301 staff_extents = staff_symbol->maybe_pure_extent (common[Y_AXIS], Y_AXIS, p
ure, start, end); | 300 staff_extents = staff_symbol->maybe_pure_extent (common[Y_AXIS], Y_AXIS, p
ure, start, end); |
302 dim.set_minimum_height (minmax (dir, min_h, staff_extents[dir])); | 301 dim.set_minimum_height (minmax (dir, min_h, staff_extents[dir])); |
303 } | 302 } |
304 | 303 |
305 Real dist = dim.distance (my_dim); | 304 Real dist = dim.distance (my_dim, 0.1); // 0.1 m4g1c value...fix... |
306 Real total_off = !isinf (dist) ? dir * dist : 0.0; | 305 Real total_off = !isinf (dist) ? dir * dist : 0.0; |
307 | 306 |
308 return finish_offset (me, dir, total_off, current_offset); | 307 return finish_offset (me, dir, total_off, current_offset); |
309 } | 308 } |
310 | 309 |
311 MAKE_SCHEME_CALLBACK (Side_position_interface, y_aligned_on_support_refpoints, 1
); | 310 MAKE_SCHEME_CALLBACK (Side_position_interface, y_aligned_on_support_refpoints, 1
); |
312 SCM | 311 SCM |
313 Side_position_interface::y_aligned_on_support_refpoints (SCM smob) | 312 Side_position_interface::y_aligned_on_support_refpoints (SCM smob) |
314 { | 313 { |
315 return general_side_position (unsmob_grob (smob), Y_AXIS, false, false, false,
0, 0, 0); | 314 return general_side_position (unsmob_grob (smob), Y_AXIS, false, false, false,
0, 0, 0); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 if (to_boolean (me->get_property ("quantize-position"))) | 400 if (to_boolean (me->get_property ("quantize-position"))) |
402 { | 401 { |
403 Grob *common = me->common_refpoint (staff, Y_AXIS); | 402 Grob *common = me->common_refpoint (staff, Y_AXIS); |
404 Real my_off = me->get_parent (Y_AXIS)->maybe_pure_coordinate (common,
Y_AXIS, pure, start, end); | 403 Real my_off = me->get_parent (Y_AXIS)->maybe_pure_coordinate (common,
Y_AXIS, pure, start, end); |
405 Real staff_off = staff->maybe_pure_coordinate (common, Y_AXIS, pure, s
tart, end); | 404 Real staff_off = staff->maybe_pure_coordinate (common, Y_AXIS, pure, s
tart, end); |
406 Real ss = Staff_symbol::staff_space (staff); | 405 Real ss = Staff_symbol::staff_space (staff); |
407 Real position = 2 * (my_off + o - staff_off) / ss; | 406 Real position = 2 * (my_off + o - staff_off) / ss; |
408 Real rounded = directed_round (position, dir); | 407 Real rounded = directed_round (position, dir); |
409 Grob *head = me->get_parent (X_AXIS); | 408 Grob *head = me->get_parent (X_AXIS); |
410 | 409 |
411 if (fabs (position) <= 2 * Staff_symbol_referencer::staff_radius (me)
+ 1 | 410 Interval staff_span = Staff_symbol::line_span (staff); |
| 411 staff_span.widen (1); |
| 412 if (staff_span.contains (position) |
412 /* In case of a ledger lines, quantize even if we're outside the s
taff. */ | 413 /* In case of a ledger lines, quantize even if we're outside the s
taff. */ |
413 || (Note_head::has_interface (head) | 414 || (Note_head::has_interface (head) |
414 | 415 |
415 && abs (Staff_symbol_referencer::get_position (head)) > abs (p
osition))) | 416 && abs (Staff_symbol_referencer::get_position (head)) > abs (p
osition))) |
416 { | 417 { |
417 o += (rounded - position) * 0.5 * ss; | 418 o += (rounded - position) * 0.5 * ss; |
418 if (Staff_symbol_referencer::on_line (me, int (rounded))) | 419 if (Staff_symbol_referencer::on_line (me, int (rounded))) |
419 o += dir * 0.5 * ss; | 420 o += dir * 0.5 * ss; |
420 } | 421 } |
421 } | 422 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 "direction " | 527 "direction " |
527 "minimum-space " | 528 "minimum-space " |
528 "padding " | 529 "padding " |
529 "quantize-position " | 530 "quantize-position " |
530 "side-axis " | 531 "side-axis " |
531 "side-support-elements " | 532 "side-support-elements " |
532 "slur-padding " | 533 "slur-padding " |
533 "staff-padding " | 534 "staff-padding " |
534 "use-skylines " | 535 "use-skylines " |
535 ); | 536 ); |
LEFT | RIGHT |