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) 2000--2012 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 2000--2012 Jan Nieuwenhuizen <janneke@gnu.org> |
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 bool simple_y = to_boolean (me->get_property ("simple-Y")) && !to_boolean (me-
>get_property ("cross-staff")); | 263 bool simple_y = to_boolean (me->get_property ("simple-Y")) && !to_boolean (me-
>get_property ("cross-staff")); |
264 | 264 |
265 Drul_array<SCM> bounds (me->get_property ("left-bound-info"), | 265 Drul_array<SCM> bounds (me->get_property ("left-bound-info"), |
266 me->get_property ("right-bound-info")); | 266 me->get_property ("right-bound-info")); |
267 | 267 |
268 Grob *commonx = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
X_AXIS); | 268 Grob *commonx = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
X_AXIS); |
269 commonx = me->common_refpoint (commonx, X_AXIS); | 269 commonx = me->common_refpoint (commonx, X_AXIS); |
270 | 270 |
271 Drul_array<Offset> span_points; | 271 Drul_array<Offset> span_points; |
272 | 272 |
273 for(LEFT_and_RIGHT(d)) | 273 for (LEFT_and_RIGHT (d)) |
274 { | 274 { |
275 Offset z (robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), | 275 Offset z (robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), |
276 bounds[d], SCM_BOOL_F), 0.0), | 276 bounds[d], SCM_BOOL_F), 0.0), |
277 robust_scm2double (ly_assoc_get (ly_symbol2scm ("Y"), | 277 robust_scm2double (ly_assoc_get (ly_symbol2scm ("Y"), |
278 bounds[d], SCM_BOOL_F), 0.0)); | 278 bounds[d], SCM_BOOL_F), 0.0)); |
279 | 279 |
280 span_points[d] = z; | 280 span_points[d] = z; |
281 } | 281 } |
282 | 282 |
283 Drul_array<Real> gaps (0, 0); | 283 Drul_array<Real> gaps (0, 0); |
284 Drul_array<bool> arrows (0, 0); | 284 Drul_array<bool> arrows (0, 0); |
285 Drul_array<Stencil *> stencils (0, 0); | 285 Drul_array<Stencil *> stencils (0, 0); |
286 Drul_array<Grob *> common_y (0, 0); | 286 Drul_array<Grob *> common_y (0, 0); |
287 | 287 |
288 // For scaling of 'padding and 'stencil-offset | 288 // For scaling of 'padding and 'stencil-offset |
289 Real magstep | 289 Real magstep |
290 = pow (2, robust_scm2double (me->get_property ("font-size"), 0.0) / 6); | 290 = pow (2, robust_scm2double (me->get_property ("font-size"), 0.0) / 6); |
291 | 291 |
292 for(LEFT_and_RIGHT(d)) | 292 for (LEFT_and_RIGHT (d)) |
293 { | 293 { |
294 gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), | 294 gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), |
295 bounds[d], SCM_BOOL_F), 0.0); | 295 bounds[d], SCM_BOOL_F), 0.0); |
296 arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"), | 296 arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"), |
297 bounds[d], SCM_BOOL_F)); | 297 bounds[d], SCM_BOOL_F)); |
298 stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"), | 298 stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"), |
299 bounds[d], SCM_BOOL_F)); | 299 bounds[d], SCM_BOOL_F)); |
300 common_y[d] = unsmob_grob (ly_assoc_get (ly_symbol2scm ("common-Y"), | 300 common_y[d] = unsmob_grob (ly_assoc_get (ly_symbol2scm ("common-Y"), |
301 bounds[d], SCM_BOOL_F)); | 301 bounds[d], SCM_BOOL_F)); |
302 if (!common_y[d]) | 302 if (!common_y[d]) |
303 common_y[d] = me; | 303 common_y[d] = me; |
304 } | 304 } |
305 | 305 |
306 Grob *my_common_y = common_y[LEFT]->common_refpoint (common_y[RIGHT], Y_AXIS); | 306 Grob *my_common_y = common_y[LEFT]->common_refpoint (common_y[RIGHT], Y_AXIS); |
307 | 307 |
308 if (!simple_y) | 308 if (!simple_y) |
309 { | 309 { |
310 for(LEFT_and_RIGHT(d)) | 310 for (LEFT_and_RIGHT (d)) |
311 span_points[d][Y_AXIS] += common_y[d]->relative_coordinate (my_common_y,
Y_AXIS); | 311 span_points[d][Y_AXIS] += common_y[d]->relative_coordinate (my_common_y,
Y_AXIS); |
312 } | 312 } |
313 | 313 |
314 Interval normalized_endpoints = robust_scm2interval (me->get_property ("normal
ized-endpoints"), Interval (0, 1)); | 314 Interval normalized_endpoints = robust_scm2interval (me->get_property ("normal
ized-endpoints"), Interval (0, 1)); |
315 Real y_length = span_points[RIGHT][Y_AXIS] - span_points[LEFT][Y_AXIS]; | 315 Real y_length = span_points[RIGHT][Y_AXIS] - span_points[LEFT][Y_AXIS]; |
316 | 316 |
317 span_points[LEFT][Y_AXIS] += normalized_endpoints[LEFT] * y_length; | 317 span_points[LEFT][Y_AXIS] += normalized_endpoints[LEFT] * y_length; |
318 span_points[RIGHT][Y_AXIS] -= (1 - normalized_endpoints[RIGHT]) * y_length; | 318 span_points[RIGHT][Y_AXIS] -= (1 - normalized_endpoints[RIGHT]) * y_length; |
319 | 319 |
320 Offset dz = (span_points[RIGHT] - span_points[LEFT]); | 320 Offset dz = (span_points[RIGHT] - span_points[LEFT]); |
321 Offset dz_dir = dz.direction (); | 321 Offset dz_dir = dz.direction (); |
322 if (gaps[LEFT] + gaps[RIGHT] > dz.length ()) | 322 if (gaps[LEFT] + gaps[RIGHT] > dz.length ()) |
323 { | 323 { |
324 return SCM_EOL; | 324 return SCM_EOL; |
325 } | 325 } |
326 | 326 |
327 Stencil line; | 327 Stencil line; |
328 for(LEFT_and_RIGHT(d)) | 328 for (LEFT_and_RIGHT (d)) |
329 { | 329 { |
330 span_points[d] += -d * gaps[d] * magstep * dz.direction (); | 330 span_points[d] += -d * gaps[d] * magstep * dz.direction (); |
331 | 331 |
332 if (stencils[d]) | 332 if (stencils[d]) |
333 { | 333 { |
334 Stencil s = stencils[d]->translated (span_points[d]); | 334 Stencil s = stencils[d]->translated (span_points[d]); |
335 SCM align = ly_assoc_get (ly_symbol2scm ("stencil-align-dir-y"), | 335 SCM align = ly_assoc_get (ly_symbol2scm ("stencil-align-dir-y"), |
336 bounds[d], SCM_BOOL_F); | 336 bounds[d], SCM_BOOL_F); |
337 SCM off = ly_assoc_get (ly_symbol2scm ("stencil-offset"), | 337 SCM off = ly_assoc_get (ly_symbol2scm ("stencil-offset"), |
338 bounds[d], SCM_BOOL_F); | 338 bounds[d], SCM_BOOL_F); |
339 | 339 |
340 if (scm_is_number (align)) | 340 if (scm_is_number (align)) |
341 s.align_to (Y_AXIS, scm_to_double (align)); | 341 s.align_to (Y_AXIS, scm_to_double (align)); |
342 | 342 |
343 if (is_number_pair (off)) | 343 if (is_number_pair (off)) |
344 s.translate (ly_scm2offset (off) * magstep); | 344 s.translate (ly_scm2offset (off) * magstep); |
345 | 345 |
346 line.add_stencil (s); | 346 line.add_stencil (s); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 for(LEFT_and_RIGHT(d)) | 350 for (LEFT_and_RIGHT (d)) |
351 { | 351 { |
352 if (stencils[d]) | 352 if (stencils[d]) |
353 span_points[d] += dz_dir * | 353 span_points[d] += dz_dir * |
354 (stencils[d]->extent (X_AXIS)[-d] / dz_dir[X_AXIS]); | 354 (stencils[d]->extent (X_AXIS)[-d] / dz_dir[X_AXIS]); |
355 } | 355 } |
356 | 356 |
357 Offset adjust = dz.direction () * Staff_symbol_referencer::staff_space (me); | 357 Offset adjust = dz.direction () * Staff_symbol_referencer::staff_space (me); |
358 | 358 |
359 Offset line_left = span_points[LEFT] + (arrows[LEFT] ? adjust * 1.4 : Offset (
0, 0)); | 359 Offset line_left = span_points[LEFT] + (arrows[LEFT] ? adjust * 1.4 : Offset (
0, 0)); |
360 Offset line_right = span_points[RIGHT] - (arrows[RIGHT] ? adjust * 0.55 : Offs
et (0, 0)); | 360 Offset line_right = span_points[RIGHT] - (arrows[RIGHT] ? adjust * 0.55 : Offs
et (0, 0)); |
(...skipping 22 matching lines...) Expand all Loading... |
383 "bound-details " | 383 "bound-details " |
384 "extra-dy " | 384 "extra-dy " |
385 "gap " | 385 "gap " |
386 "left-bound-info " | 386 "left-bound-info " |
387 "note-columns " | 387 "note-columns " |
388 "right-bound-info " | 388 "right-bound-info " |
389 "simple-Y " | 389 "simple-Y " |
390 "thickness " | 390 "thickness " |
391 "to-barline " | 391 "to-barline " |
392 ); | 392 ); |
LEFT | RIGHT |