Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2901)

Delta Between Two Patch Sets: lily/slur.cc

Issue 6498077: Approximates cross-staff slurs in VerticalAxisGroup vertical-skylines. Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Left Patch Set: Builds cross-staff-stub skylines directly into VerticalAxisGroup skylines Created 12 years, 7 months ago
Right Patch Set: Better approximations Created 12 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 Jan Nieuwenhuizen <janneke@gnu.org> 5 Jan Nieuwenhuizen <janneke@gnu.org>
6 6
7 LilyPond is free software: you can redistribute it and/or modify 7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or 9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 Stencil *m = me->get_stencil (); 138 Stencil *m = me->get_stencil ();
139 return m ? ly_interval2scm (m->extent (Y_AXIS)) 139 return m ? ly_interval2scm (m->extent (Y_AXIS))
140 : ly_interval2scm (Interval ()); 140 : ly_interval2scm (Interval ());
141 } 141 }
142 142
143 MAKE_SCHEME_CALLBACK (Slur, print, 1); 143 MAKE_SCHEME_CALLBACK (Slur, print, 1);
144 SCM 144 SCM
145 Slur::print (SCM smob) 145 Slur::print (SCM smob)
146 { 146 {
147 Grob *me = unsmob_grob (smob); 147 Grob *me = unsmob_grob (smob);
148
148 extract_grob_set (me, "note-columns", encompasses); 149 extract_grob_set (me, "note-columns", encompasses);
149 if (encompasses.empty ()) 150 if (encompasses.empty ())
150 { 151 {
151 me->suicide (); 152 me->suicide ();
152 return SCM_EOL; 153 return SCM_EOL;
153 } 154 }
154 155
155 Real staff_thick = Staff_symbol_referencer::line_thickness (me); 156 Real staff_thick = Staff_symbol_referencer::line_thickness (me);
156 Real base_thick = staff_thick 157 Real base_thick = staff_thick
157 * robust_scm2double (me->get_property ("thickness"), 1); 158 * robust_scm2double (me->get_property ("thickness"), 1);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 Slur::main_to_stub (Grob *main, Grob *stub) 256 Slur::main_to_stub (Grob *main, Grob *stub)
256 { 257 {
257 extract_grob_set (main, "note-columns", nc); 258 extract_grob_set (main, "note-columns", nc);
258 for (vsize i = 0; i < nc.size (); i++) 259 for (vsize i = 0; i < nc.size (); i++)
259 add_column (stub, nc[i]); 260 add_column (stub, nc[i]);
260 261
261 extract_grob_set (main, "encompass-objects", eo); 262 extract_grob_set (main, "encompass-objects", eo);
262 for (vsize i = 0; i < eo.size (); i++) 263 for (vsize i = 0; i < eo.size (); i++)
263 add_extra_encompass (stub, eo[i]); 264 add_extra_encompass (stub, eo[i]);
264 265
265 stub->set_object ("surrogate", main->self_scm ());
266
267 dynamic_cast<Spanner *> (stub)->set_bound 266 dynamic_cast<Spanner *> (stub)->set_bound
268 (LEFT, dynamic_cast<Spanner *> (main)->get_bound (LEFT)); 267 (LEFT, dynamic_cast<Spanner *> (main)->get_bound (LEFT));
269 dynamic_cast<Spanner *> (stub)->set_bound 268 dynamic_cast<Spanner *> (stub)->set_bound
270 (RIGHT, dynamic_cast<Spanner *> (main)->get_bound (RIGHT)); 269 (RIGHT, dynamic_cast<Spanner *> (main)->get_bound (RIGHT));
271 }
272
273 MAKE_SCHEME_CALLBACK (Slur, direction_from_shadowed_slur, 1);
274 SCM
275 Slur::direction_from_shadowed_slur (SCM smob)
276 {
277 Grob *me = unsmob_grob (smob);
278 if (Grob *slur = unsmob_grob (me->get_object ("surrogate")))
279 return scm_from_int (get_grob_direction (slur));
280
281 me->programming_error ("Cannot determine SlurStub direction");
282
283 return scm_from_int (UP);
284 } 270 }
285 271
286 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, pure_outside_slur_callback, 4, 1, ""); 272 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, pure_outside_slur_callback, 4, 1, "");
287 SCM 273 SCM
288 Slur::pure_outside_slur_callback (SCM grob, SCM start_scm, SCM end_scm, SCM offs et_scm) 274 Slur::pure_outside_slur_callback (SCM grob, SCM start_scm, SCM end_scm, SCM offs et_scm)
289 { 275 {
290 int start = robust_scm2int (start_scm, 0); 276 int start = robust_scm2int (start_scm, 0);
291 int end = robust_scm2int (end_scm, 0); 277 int end = robust_scm2int (end_scm, 0);
292 Grob *script = unsmob_grob (grob); 278 Grob *script = unsmob_grob (grob);
293 Grob *slur = unsmob_grob (script->get_object ("slur")); 279 Grob *slur = unsmob_grob (script->get_object ("slur"));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 { 398 {
413 Box b; 399 Box b;
414 b.add_point (curve.curve_point (i * 1.0 / box_count)); 400 b.add_point (curve.curve_point (i * 1.0 / box_count));
415 b.add_point (curve.curve_point ((i + 1) * 1.0 / box_count)); 401 b.add_point (curve.curve_point ((i + 1) * 1.0 / box_count));
416 boxes.push_back (b); 402 boxes.push_back (b);
417 } 403 }
418 404
419 return Skyline_pair (boxes, X_AXIS).smobbed_copy (); 405 return Skyline_pair (boxes, X_AXIS).smobbed_copy ();
420 } 406 }
421 407
408 /*
409 * USE ME ONLY FOR CROSS STAFF SLURS!
410 * We only want to keep the topmost skyline of the topmost axis group(s)
411 * and the bottommost skyline of the bottommost axis group(s). Otherwise,
412 * the VerticalAxisGroups will be spaced very far apart to accommodate the
413 * slur, which we don't want, as it is cross staff.
414 *
415 * TODO: Currently, the code below keeps the topmost and bottommost axis
416 * groups and gets rid of the rest. This should be more nuanced for
417 * cases like ossias where the topmost staff changes over the course of
418 * the slur. Ditto for the bottommost staff.
419 */
420
422 MAKE_SCHEME_CALLBACK (Slur, extremal_stub_vertical_skylines, 1); 421 MAKE_SCHEME_CALLBACK (Slur, extremal_stub_vertical_skylines, 1);
423 SCM 422 SCM
424 Slur::extremal_stub_vertical_skylines (SCM smob) 423 Slur::extremal_stub_vertical_skylines (SCM smob)
425 { 424 {
426 Grob *me = unsmob_grob (smob); 425 Grob *me = unsmob_grob (smob);
427 vector<int> vais; 426 Grob *cause = unsmob_grob (me->get_property ("cause"));
428 extract_grob_set (me, "note-columns", note_columns); 427 if (!cause || !cause->is_live ())
429 for (vsize i = 0; i < note_columns.size (); i++) 428 {
430 vais.push_back (Grob::get_vertical_axis_group_index (note_columns[i])); 429 me->suicide ();
431 430 return SCM_BOOL_F;
432 vector_sort (vais, less<int> ()); 431 }
433 int my_vai = Grob::get_vertical_axis_group_index (me); 432
434 if (!(my_vai == vais[0] || my_vai == vais.back ())) 433 // triggers suicide if necessary
434 (void) me->get_property ("cross-staff");
435 if (!me->is_live ())
436 return SCM_BOOL_F;
437
438 Grob *my_vag = Grob::get_vertical_axis_group (me);
439 extract_grob_set (me, "note-columns", ro_note_columns);
440 vector<Grob *> note_columns (ro_note_columns);
441 vector_sort (note_columns, Grob::vertical_less);
442 bool highest = my_vag == Grob::get_vertical_axis_group (note_columns[0]);
443 bool lowest = my_vag == Grob::get_vertical_axis_group (note_columns.back ());
444 if (!highest && !lowest)
435 return Skyline_pair ().smobbed_copy (); 445 return Skyline_pair ().smobbed_copy ();
436 446
437 Skyline_pair sky = *Skyline_pair::unsmob (vertical_skylines (smob)); 447 Skyline_pair sky = *Skyline_pair::unsmob (vertical_skylines (smob));
438 if (my_vai == vais[0]) 448
439 sky[DOWN] = Skyline (); 449 if (highest)
450 sky[DOWN] = Skyline (DOWN);
440 else 451 else
441 sky[UP] = Skyline (); 452 sky[UP] = Skyline (UP);
442 453
443 return sky.smobbed_copy (); 454 return sky.smobbed_copy ();
444 } 455 }
445 456
446 /* 457 /*
447 * Used by Slur_engraver:: and Phrasing_slur_engraver:: 458 * Used by Slur_engraver:: and Phrasing_slur_engraver::
448 */ 459 */
449 void 460 void
450 Slur::auxiliary_acknowledge_extra_object (Grob_info const &info, 461 Slur::auxiliary_acknowledge_extra_object (Grob_info const &info,
451 vector<Grob *> &slurs, 462 vector<Slur_info> &slur_infos,
452 vector<Grob *> &end_slurs) 463 vector<Slur_info> &end_slur_infos)
453 { 464 {
454 if (slurs.empty () && end_slurs.empty ()) 465 if (slur_infos.empty () && end_slur_infos.empty ())
455 return; 466 return;
456 467
457 Grob *e = info.grob (); 468 Grob *e = info.grob ();
458 SCM avoid = e->get_property ("avoid-slur"); 469 SCM avoid = e->get_property ("avoid-slur");
459 Grob *slur; 470 Grob *slur;
460 if (end_slurs.size () && !slurs.size ()) 471 if (end_slur_infos.size () && !slur_infos.size ())
461 slur = end_slurs[0]; 472 slur = end_slur_infos[0].slur_;
462 else 473 else
463 slur = slurs[0]; 474 slur = slur_infos[0].slur_;
464 475
465 if (Tie::has_interface (e) 476 if (Tie::has_interface (e)
466 || avoid == ly_symbol2scm ("inside")) 477 || avoid == ly_symbol2scm ("inside"))
467 { 478 {
468 for (vsize i = slurs.size (); i--;) 479 for (vsize i = slur_infos.size (); i--;)
469 add_extra_encompass (slurs[i], e); 480 add_extra_encompass (slur_infos[i].slur_, e);
470 for (vsize i = end_slurs.size (); i--;) 481 for (vsize i = end_slur_infos.size (); i--;)
471 add_extra_encompass (end_slurs[i], e); 482 add_extra_encompass (end_slur_infos[i].slur_, e);
472 if (slur) 483 if (slur)
473 e->set_object ("slur", slur->self_scm ()); 484 e->set_object ("slur", slur->self_scm ());
474 } 485 }
475 else if (avoid == ly_symbol2scm ("outside") 486 else if (avoid == ly_symbol2scm ("outside")
476 || avoid == ly_symbol2scm ("around")) 487 || avoid == ly_symbol2scm ("around"))
477 { 488 {
478 if (slur) 489 if (slur)
479 { 490 {
480 chain_offset_callback (e, outside_slur_callback_proc, Y_AXIS); 491 chain_offset_callback (e, outside_slur_callback_proc, Y_AXIS);
481 chain_callback (e, outside_slur_cross_staff_proc, ly_symbol2scm ("cros s-staff")); 492 chain_callback (e, outside_slur_cross_staff_proc, ly_symbol2scm ("cros s-staff"));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 "direction " 624 "direction "
614 "eccentricity " 625 "eccentricity "
615 "encompass-objects " 626 "encompass-objects "
616 "height-limit " 627 "height-limit "
617 "inspect-quants " 628 "inspect-quants "
618 "inspect-index " 629 "inspect-index "
619 "line-thickness " 630 "line-thickness "
620 "note-columns " 631 "note-columns "
621 "positions " 632 "positions "
622 "ratio " 633 "ratio "
623 "thickness " 634 "thickness "
dak 2012/09/02 15:59:00 No entry for "surrogate"?
MikeSol 2012/09/02 16:45:14 scm/define-grob-interfaces.scm
624 ); 635 );
625 636
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b