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

Delta Between Two Patch Sets: lily/axis-group-interface.cc

Issue 7185044: Caches the interior skylines of vertical axis groups and systems. Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Left Patch Set: Ignores staff-padding for cross-staff grobs Created 12 years ago
Right Patch Set: Gives Hairpin outside-staff-interface Created 11 years, 11 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
« no previous file with change/comment | « input/regression/tuplet-number-outside-staff-priority.ly ('k') | lily/directional-element-interface.cc » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2000--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> 4 Copyright (C) 2000--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 24 matching lines...) Expand all
35 #include "staff-grouper-interface.hh" 35 #include "staff-grouper-interface.hh"
36 #include "stem.hh" 36 #include "stem.hh"
37 #include "stencil.hh" 37 #include "stencil.hh"
38 #include "system.hh" 38 #include "system.hh"
39 #include "warn.hh" 39 #include "warn.hh"
40 #include "unpure-pure-container.hh" 40 #include "unpure-pure-container.hh"
41 41
42 // NON MEMBER FUNCTIONS 42 // NON MEMBER FUNCTIONS
43 43
44 bool 44 bool
45 staff_priority_less (Grob *const &g1, Grob *const &g2) 45 staff_priority_less (Grob *const &g1, Grob *const &g2)
dak 2013/12/11 13:44:25 There is no point in passing references to pointer
46 { 46 {
47 Real priority_1 = robust_scm2double (g1->get_property ("outside-staff-priority "), -infinity_f); 47 Real priority_1 = robust_scm2double (g1->get_property ("outside-staff-priority "), -infinity_f);
48 Real priority_2 = robust_scm2double (g2->get_property ("outside-staff-priority "), -infinity_f); 48 Real priority_2 = robust_scm2double (g2->get_property ("outside-staff-priority "), -infinity_f);
49 49
50 if (priority_1 < priority_2) 50 if (priority_1 < priority_2)
51 return true; 51 return true;
52 else if (priority_1 > priority_2) 52 else if (priority_1 > priority_2)
53 return false; 53 return false;
54 54
55 /* if neither grob has an outside-staff priority, the ordering will have no 55 /* if neither grob has an outside-staff priority, the ordering will have no
56 effect -- we just need to choose a consistent ordering. We do this to 56 effect -- we just need to choose a consistent ordering. We do this to
57 avoid the side-effect of calculating extents. */ 57 avoid the side-effect of calculating extents. */
58 if (isinf (priority_1)) 58 if (isinf (priority_1))
59 return g1 < g2; 59 return g1 < g2;
dak 2013/12/11 13:44:25 Making decisions based on memory address is a bad
60 60
61 /* if there is no preference in staff priority, choose the left-most one */ 61 /* if there is no preference in staff priority, choose the left-most one */
62 Grob *common = g1->common_refpoint (g2, X_AXIS); 62 Grob *common = g1->common_refpoint (g2, X_AXIS);
63 Real start_1 = g1->extent (common, X_AXIS)[LEFT]; 63 Real start_1 = g1->extent (common, X_AXIS)[LEFT];
64 Real start_2 = g2->extent (common, X_AXIS)[LEFT]; 64 Real start_2 = g2->extent (common, X_AXIS)[LEFT];
65 return start_1 < start_2; 65 return start_1 < start_2;
66 } 66 }
67 67
68 bool 68 bool
69 pure_staff_priority_less (Grob *const &g1, Grob *const &g2) 69 pure_staff_priority_less (Grob *const &g1, Grob *const &g2)
70 { 70 {
71 Real priority_1 = robust_scm2double (g1->get_property ("outside-staff-priority "), -infinity_f); 71 Real priority_1 = robust_scm2double (g1->get_property ("outside-staff-priority "), -infinity_f);
72 Real priority_2 = robust_scm2double (g2->get_property ("outside-staff-priority "), -infinity_f); 72 Real priority_2 = robust_scm2double (g2->get_property ("outside-staff-priority "), -infinity_f);
73 73
74 return priority_1 < priority_2; 74 return priority_1 < priority_2;
75 } 75 }
76 76
77 static void 77 static void
dak 2013/12/11 13:44:25 There is no comment that indicates what add_interi
78 add_interior_skylines (Grob *me, Grob *x_common, Grob *y_common, vector<Skyline_ pair> *skylines) 78 add_interior_skylines (Grob *me, Grob *x_common, Grob *y_common, vector<Skyline_ pair> *skylines)
79 { 79 {
80 if (Grob_array *elements = unsmob_grob_array (me->get_object ("elements"))) 80 if (Grob_array *elements = unsmob_grob_array (me->get_object ("elements")))
81 { 81 {
82 for (vsize i = 0; i < elements->size (); i++) 82 for (vsize i = 0; i < elements->size (); i++)
83 add_interior_skylines (elements->grob (i), x_common, y_common, skylines) ; 83 add_interior_skylines (elements->grob (i), x_common, y_common, skylines) ;
84 } 84 }
85 else if (!scm_is_number (me->get_property ("outside-staff-priority")) 85 else if (!scm_is_number (me->get_property ("outside-staff-priority"))
86 && !to_boolean (me->get_property ("cross-staff"))) 86 && !to_boolean (me->get_property ("cross-staff")))
87 { 87 {
88 Skyline_pair *maybe_pair = Skyline_pair::unsmob (me->get_property ("vertic al-skylines")); 88 Skyline_pair *maybe_pair = Skyline_pair::unsmob (me->get_property ("vertic al-skylines"));
89 if (!maybe_pair) 89 if (!maybe_pair)
90 return; 90 return;
91 if (maybe_pair->is_empty ()) 91 if (maybe_pair->is_empty ())
92 return; 92 return;
93 skylines->push_back (Skyline_pair (*maybe_pair)); 93 skylines->push_back (Skyline_pair (*maybe_pair));
94 skylines->back ().shift (me->relative_coordinate (x_common, X_AXIS)); 94 skylines->back ().shift (me->relative_coordinate (x_common, X_AXIS));
95 skylines->back ().raise (me->relative_coordinate (y_common, Y_AXIS)); 95 skylines->back ().raise (me->relative_coordinate (y_common, Y_AXIS));
96 } 96 }
97 } 97 }
98 98
99 SCM 99 SCM
dak 2013/12/11 13:44:25 There is no comment what valid_outside_staff_place
100 valid_outside_staff_placement_directive (Grob *me) 100 valid_outside_staff_placement_directive (Grob *me)
101 { 101 {
102 SCM directive = me->get_property ("outside-staff-placement-directive"); 102 SCM directive = me->get_property ("outside-staff-placement-directive");
103 103
104 if ((directive == ly_symbol2scm ("left-to-right-greedy")) 104 if ((directive == ly_symbol2scm ("left-to-right-greedy"))
dak 2013/12/11 13:44:25 If there is only a limited set of valid values, th
105 || (directive == ly_symbol2scm ("left-to-right-polite")) 105 || (directive == ly_symbol2scm ("left-to-right-polite"))
106 || (directive == ly_symbol2scm ("right-to-left-greedy")) 106 || (directive == ly_symbol2scm ("right-to-left-greedy"))
107 || (directive == ly_symbol2scm ("right-to-left-polite"))) 107 || (directive == ly_symbol2scm ("right-to-left-polite")))
108 return directive; 108 return directive;
109 109
110 if (directive == SCM_EOL) 110 if (directive == SCM_EOL)
111 return ly_symbol2scm ("left-to-right-polite"); 111 return ly_symbol2scm ("left-to-right-polite");
112 112
113 me->warning (_f ("\"%s\" is not a valid outside-staff-placement-directive", 113 me->warning (_f ("\"%s\" is not a valid outside-staff-placement-directive",
114 robust_symbol2string (directive, "").c_str ())); 114 robust_symbol2string (directive, "").c_str ()));
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 vector<Interval> mid_line_staff_heights; 324 vector<Interval> mid_line_staff_heights;
325 begin_line_heights.resize (ranks.size () - 1); 325 begin_line_heights.resize (ranks.size () - 1);
326 mid_line_heights.resize (ranks.size () - 1); 326 mid_line_heights.resize (ranks.size () - 1);
327 327
328 for (vsize i = 0; i < elts.size (); ++i) 328 for (vsize i = 0; i < elts.size (); ++i)
329 { 329 {
330 Grob *g = elts[i]; 330 Grob *g = elts[i];
331 331
332 if (to_boolean (g->get_property ("cross-staff")) 332 if (to_boolean (g->get_property ("cross-staff"))
333 && !has_interface (g)) 333 && !has_interface (g))
334 continue;
335
336 if (!g->is_live ())
334 continue; 337 continue;
335 338
336 bool outside_staff = scm_is_number (g->get_property ("outside-staff-priori ty")); 339 bool outside_staff = scm_is_number (g->get_property ("outside-staff-priori ty"));
337 Real padding = robust_scm2double (g->get_property ("outside-staff-padding" ), get_default_outside_staff_padding ()); 340 Real padding = robust_scm2double (g->get_property ("outside-staff-padding" ), get_default_outside_staff_padding ());
338 341
339 // When we encounter the first outside-staff grob, make a copy 342 // When we encounter the first outside-staff grob, make a copy
340 // of the current heights to use as an estimate for the staff heights. 343 // of the current heights to use as an estimate for the staff heights.
341 // Note that the outside-staff approximation that we use here doesn't 344 // Note that the outside-staff approximation that we use here doesn't
342 // consider any collisions that might occur between outside-staff grobs, 345 // consider any collisions that might occur between outside-staff grobs,
343 // but only the fact that outside-staff grobs may need to be raised above 346 // but only the fact that outside-staff grobs may need to be raised above
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 Grob *me = unsmob_grob (smob); 564 Grob *me = unsmob_grob (smob);
562 return internal_calc_pure_relevant_grobs (me, "elements"); 565 return internal_calc_pure_relevant_grobs (me, "elements");
563 } 566 }
564 567
565 SCM 568 SCM
566 Axis_group_interface::internal_calc_pure_relevant_grobs (Grob *me, string grob_s et_name) 569 Axis_group_interface::internal_calc_pure_relevant_grobs (Grob *me, string grob_s et_name)
567 { 570 {
568 extract_grob_set (me, grob_set_name.c_str (), elts); 571 extract_grob_set (me, grob_set_name.c_str (), elts);
569 572
570 vector<Grob *> relevant_grobs; 573 vector<Grob *> relevant_grobs;
571 SCM pure_relevant_p = ly_lily_module_constant ("pure-relevant?");
572 574
573 for (vsize i = 0; i < elts.size (); i++) 575 for (vsize i = 0; i < elts.size (); i++)
574 { 576 {
575 if (to_boolean (scm_apply_1 (pure_relevant_p, elts[i]->self_scm (), SCM_EO L))) 577 if (elts[i] && elts[i]->is_live ())
576 relevant_grobs.push_back (elts[i]);
577
578 if (Item *it = dynamic_cast<Item *> (elts[i]))
579 { 578 {
580 for (LEFT_and_RIGHT (d)) 579 relevant_grobs.push_back (elts[i]);
580 if (Item *it = dynamic_cast<Item *> (elts[i]))
581 { 581 {
582 Item *piece = it->find_prebroken_piece (d); 582 for (LEFT_and_RIGHT (d))
583 if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self _scm (), SCM_EOL))) 583 {
584 relevant_grobs.push_back (piece); 584 Item *piece = it->find_prebroken_piece (d);
585 if (piece && piece->is_live ())
586 relevant_grobs.push_back (piece);
587 }
585 } 588 }
586 } 589 }
587 } 590 }
588 591
589 vector_sort (relevant_grobs, pure_staff_priority_less); 592 vector_sort (relevant_grobs, pure_staff_priority_less);
590 SCM grobs_scm = Grob_array::make_array (); 593 SCM grobs_scm = Grob_array::make_array ();
591 unsmob_grob_array (grobs_scm)->set_array (relevant_grobs); 594 unsmob_grob_array (grobs_scm)->set_array (relevant_grobs);
592 595
593 return grobs_scm; 596 return grobs_scm;
594 } 597 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 Interval 644 Interval
642 Axis_group_interface::pure_group_height (Grob *me, int start, int end) 645 Axis_group_interface::pure_group_height (Grob *me, int start, int end)
643 { 646 {
644 Grob *common = unsmob_grob (me->get_object ("pure-Y-common")); 647 Grob *common = unsmob_grob (me->get_object ("pure-Y-common"));
645 648
646 if (!common) 649 if (!common)
647 { 650 {
648 programming_error ("no pure Y common refpoint"); 651 programming_error ("no pure Y common refpoint");
649 return Interval (); 652 return Interval ();
650 } 653 }
651 Real my_coord = me->relative_coordinate (common, Y_AXIS); 654 Real my_coord = me->pure_relative_y_coordinate (common, start, end);
652 Interval r (relative_pure_height (me, start, end)); 655 Interval r (relative_pure_height (me, start, end));
653 656
654 return r - my_coord; 657 return r - my_coord;
655 } 658 }
656 659
657 void 660 void
658 Axis_group_interface::get_children (Grob *me, vector<Grob *> *found) 661 Axis_group_interface::get_children (Grob *me, vector<Grob *> *found)
659 { 662 {
660 found->push_back (me); 663 found->push_back (me);
661 664
(...skipping 16 matching lines...) Expand all
678 Grob *parent = me->get_parent (Y_AXIS); 681 Grob *parent = me->get_parent (Y_AXIS);
679 if (!parent) 682 if (!parent)
680 return 0; 683 return 0;
681 684
682 if (scm_is_number (parent->get_property ("outside-staff-priority"))) 685 if (scm_is_number (parent->get_property ("outside-staff-priority")))
683 return parent; 686 return parent;
684 687
685 return outside_staff_ancestor (parent); 688 return outside_staff_ancestor (parent);
686 } 689 }
687 690
688 MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_inside_staff_skylines, 1); 691 MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_inside_staff_skylines, 1);
dak 2013/12/11 13:44:25 There is no comment what calc_inside_staff_skyline
689 SCM 692 SCM
690 Axis_group_interface::calc_inside_staff_skylines (SCM smob) 693 Axis_group_interface::calc_inside_staff_skylines (SCM smob)
691 { 694 {
692 Grob *me = unsmob_grob (smob); 695 Grob *me = unsmob_grob (smob);
693 extract_grob_set (me, "vertical-skyline-elements", elements); 696 extract_grob_set (me, "vertical-skyline-elements", elements);
694 697
695 Grob *x_common = common_refpoint_of_array (elements, me, X_AXIS); 698 Grob *x_common = common_refpoint_of_array (elements, me, X_AXIS);
696 Grob *y_common = common_refpoint_of_array (elements, me, Y_AXIS); 699 Grob *y_common = common_refpoint_of_array (elements, me, Y_AXIS);
697 700
698 assert (y_common == me); 701 assert (y_common == me);
dak 2013/12/11 13:44:25 If skylines are disabled, why would this assertion
699 702
700 vector<Skyline_pair> inside_staff_skylines; 703 vector<Skyline_pair> inside_staff_skylines;
701 704
702 for (vsize i = 0; i < elements.size () 705 for (vsize i = 0; i < elements.size ()
703 && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++) 706 && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++)
704 { 707 {
705 Grob *elt = elements[i]; 708 Grob *elt = elements[i];
706 Grob *ancestor = outside_staff_ancestor (elt); 709 Grob *ancestor = outside_staff_ancestor (elt);
707 if (!ancestor) 710 if (!ancestor)
708 add_interior_skylines (elt, x_common, y_common, &inside_staff_skylines); 711 add_interior_skylines (elt, x_common, y_common, &inside_staff_skylines);
709 } 712 }
710 713
711 Skyline_pair skylines (inside_staff_skylines); 714 Skyline_pair skylines (inside_staff_skylines);
712 return skylines.smobbed_copy (); 715 return skylines.smobbed_copy ();
713 } 716 }
714 717
715 /* 718 /*
716 Only returns false if a Y-child of a grob has a lower outside-staff-priority 719 Only returns false if a Y-child of a grob has a lower outside-staff-priority
717 than its Y-parent. 720 than its Y-parent.
718 */ 721 */
719 722
720 bool 723 bool
721 sane_outside_staff_priority_parental_relationship (Grob *me) 724 sane_outside_staff_priority_parental_relationship (Grob *me)
dak 2013/12/11 13:44:25 What has this to do with sanity? Are childs only
722 { 725 {
723 // no outside staff priority 726 // no outside staff priority
724 if (!scm_is_number (me->get_property ("outside-staff-priority"))) 727 if (!scm_is_number (me->get_property ("outside-staff-priority")))
725 return true; 728 return true;
726 729
727 Grob *ancestor = Axis_group_interface::outside_staff_ancestor (me); 730 Grob *ancestor = Axis_group_interface::outside_staff_ancestor (me);
728 // no outside staff ancestor 731 // no outside staff ancestor
729 if (!ancestor) 732 if (!ancestor)
730 return true; 733 return true;
731 734
732 return staff_priority_less (ancestor, me); 735 return staff_priority_less (ancestor, me);
733 } 736 }
734 737
735 SCM 738 SCM
736 ancestor_priority_plus_a_bit (Grob *me) 739 ancestor_priority_plus_a_bit (Grob *me)
dak 2013/12/11 13:44:25 Why do we need this?
737 { 740 {
738 Grob *ancestor = Axis_group_interface::outside_staff_ancestor (me); 741 Grob *ancestor = Axis_group_interface::outside_staff_ancestor (me);
739 // no outside staff ancestor 742 // no outside staff ancestor
740 if (!ancestor) 743 if (!ancestor)
741 { 744 {
742 me->programming_error ("This function should only be called if ancestry is sure."); 745 me->programming_error ("This function should only be called if ancestry is sure.");
743 return SCM_BOOL_F; 746 return SCM_BOOL_F;
744 } 747 }
745 748
746 return scm_from_double (scm_to_double (ancestor->get_property ("outside-staff- priority")) + 0.0001); 749 return scm_from_double (scm_to_double (ancestor->get_property ("outside-staff- priority")) + 0.0001);
dak 2013/12/11 13:44:25 This does not distinguish between various ancestor
747 } 750 }
748 751
749 /* 752 /*
750 Before doing calculations involving outside staff priority are done, we 753 Before doing calculations involving outside staff priority are done, we
751 suicide any grobs that need to be suicided and make sure that grobs that 754 suicide any grobs that need to be suicided and make sure that grobs that
752 depend on the placement of a Y parent do not have a lower 755 depend on the placement of a Y parent do not have a lower
753 outside-staff-priority than the parent, which would cause their being 756 outside-staff-priority than the parent, which would cause their being
754 placed first. 757 placed first.
755 */ 758 */
756 void 759 void
757 Axis_group_interface::prepare_for_outside_staff_calculations (Grob *me) 760 Axis_group_interface::prepare_for_outside_staff_calculations (Grob *me)
758 { 761 {
759 extract_grob_set (me, "vertical-skyline-elements", elements); 762 extract_grob_set (me, "vertical-skyline-elements", elements);
760 for (vsize i = 0; i < elements.size (); i++) 763 for (vsize i = 0; i < elements.size (); i++)
761 /* 764 /*
762 As a sanity check, we make sure that no grob with an outside staff priorit y 765 As a sanity check, we make sure that no grob with an outside staff priorit y
763 has a Y-parent that also has an outside staff priority, which would result 766 has a Y-parent that also has an outside staff priority, which would result
764 in two movings. 767 in two movings.
dak 2013/12/11 13:44:25 Huh? Above we called a staff priority relation "s
765 */ 768 */
766 if (!sane_outside_staff_priority_parental_relationship (elements[i])) 769 if (!sane_outside_staff_priority_parental_relationship (elements[i]))
767 { 770 {
768 elements[i]->warning ("An elements' Y parent must have a lower outside staff priority than the element."); 771 elements[i]->warning ("An elements' Y parent must have a lower outside staff priority than the element.");
dak 2013/12/11 13:44:25 Looks like the above comment got things wrong.
769 elements[i]->set_property ("outside-staff-priority", ancestor_priority_ plus_a_bit (elements[i])); 772 elements[i]->set_property ("outside-staff-priority", ancestor_priority_ plus_a_bit (elements[i]));
770 } 773 }
771 774
772 /* For grobs with an outside-staff-priority, the sorting function might 775 /* For grobs with an outside-staff-priority, the sorting function might
773 call extent and cause suicide. This breaks the contract that is required 776 call extent and cause suicide. This breaks the contract that is required
774 for the STL sort function. To avoid this, we make sure that any suicides 777 for the STL sort function. To avoid this, we make sure that any suicides
775 are triggered beforehand. 778 are triggered beforehand.
dak 2013/12/11 13:44:25 But we do not _do_ any sorting here. Why would we
776 */ 779 */
777 for (vsize i = 0; i < elements.size (); i++) 780 for (vsize i = 0; i < elements.size (); i++)
778 if (scm_is_number (elements[i]->get_property ("outside-staff-priority"))) 781 if (scm_is_number (elements[i]->get_property ("outside-staff-priority")))
779 elements[i]->extent (elements[i], X_AXIS); 782 elements[i]->extent (elements[i], X_AXIS);
780 } 783 }
781 784
782 MAKE_SCHEME_CALLBACK (Axis_group_interface, vertical_skyline_elements, 1); 785 MAKE_SCHEME_CALLBACK (Axis_group_interface, vertical_skyline_elements, 1);
dak 2013/12/11 13:44:25 There is no comment what this function returns, an
783 SCM 786 SCM
784 Axis_group_interface::vertical_skyline_elements (SCM smob) 787 Axis_group_interface::vertical_skyline_elements (SCM smob)
785 { 788 {
786 Grob *me = unsmob_grob (smob); 789 Grob *me = unsmob_grob (smob);
787 790
788 extract_grob_set (me, "elements", origelements); 791 extract_grob_set (me, "elements", origelements);
789 vector<Grob *> elements (origelements); 792 vector<Grob *> elements (origelements);
790 prepare_for_outside_staff_calculations (me); 793 prepare_for_outside_staff_calculations (me);
791 sort_outside_staff_elements (me, elements); 794 sort_outside_staff_elements (me, elements);
792 795
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 vector<Grob *> outside_staff_elements; 831 vector<Grob *> outside_staff_elements;
829 832
830 vsize i = 0; 833 vsize i = 0;
831 834
832 for (i = 0; i < elements.size () 835 for (i = 0; i < elements.size ()
833 && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++) 836 && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++)
834 { 837 {
835 Grob *elt = elements[i]; 838 Grob *elt = elements[i];
836 if (!sane_outside_staff_priority_parental_relationship (elements[i])) 839 if (!sane_outside_staff_priority_parental_relationship (elements[i]))
837 { 840 {
838 elt->programming_error ("Sorting function should have made sure that I have an outside-staff-priority although my parent does. Setting to parent's..." ); 841 elt->programming_error ("Sorting function should have made sure that I have an outside-staff-priority although my parent does. Setting to parent's..." );
dak 2013/12/11 13:44:25 The error message does not make sense. "Sorting fu
839 elt->set_property ("outside-staff-priority", ancestor_priority_plus_a_ bit (elements[i])); 842 elt->set_property ("outside-staff-priority", ancestor_priority_plus_a_ bit (elements[i]));
840 } 843 }
841 else 844 else
842 inside_staff_elements.push_back (elt); 845 inside_staff_elements.push_back (elt);
843 } 846 }
844 847
845 SCM directive 848 SCM directive
846 = valid_outside_staff_placement_directive (me); 849 = valid_outside_staff_placement_directive (me);
847 850
848 bool l2r = ((directive == ly_symbol2scm ("left-to-right-greedy")) 851 bool l2r = ((directive == ly_symbol2scm ("left-to-right-greedy"))
dak 2013/12/11 13:44:25 Actually, this strongly suggests that the "directi
849 || (directive == ly_symbol2scm ("left-to-right-polite"))); 852 || (directive == ly_symbol2scm ("left-to-right-polite")));
850 853
851 bool polite = ((directive == ly_symbol2scm ("left-to-right-polite")) 854 bool polite = ((directive == ly_symbol2scm ("left-to-right-polite"))
852 || (directive == ly_symbol2scm ("right-to-left-polite"))); 855 || (directive == ly_symbol2scm ("right-to-left-polite")));
853 856
854 857
855 // We want to avoid situations like this: 858 // We want to avoid situations like this:
856 // still more text 859 // still more text
857 // more text 860 // more text
858 // text 861 // text
(...skipping 15 matching lines...) Expand all
874 for (; i < elements.size (); i++) 877 for (; i < elements.size (); i++)
875 { 878 {
876 if (to_boolean (elements[i]->get_property ("cross-staff"))) 879 if (to_boolean (elements[i]->get_property ("cross-staff")))
877 continue; 880 continue;
878 881
879 // Collect all the outside-staff grobs that have a particular priority. 882 // Collect all the outside-staff grobs that have a particular priority.
880 SCM priority = elements[i]->get_property ("outside-staff-priority"); 883 SCM priority = elements[i]->get_property ("outside-staff-priority");
881 vector<Grob *> current_elts; 884 vector<Grob *> current_elts;
882 current_elts.push_back (elements[i]); 885 current_elts.push_back (elements[i]);
883 while (i + 1 < elements.size () 886 while (i + 1 < elements.size ()
884 && scm_is_eq (elements[i + 1]->get_property ("outside-staff-priorit y"), priority)) 887 && scm_is_eq (elements[i + 1]->get_property ("outside-staff-priorit y"), priority))
dak 2013/12/11 13:44:25 Priorities are generally numeric and cannot reliab
885 { 888 {
886 if (!to_boolean (elements[i + 1]->get_property ("cross-staff"))) 889 if (!to_boolean (elements[i + 1]->get_property ("cross-staff")))
887 current_elts.push_back (elements[i + 1]); 890 current_elts.push_back (elements[i + 1]);
888 ++i; 891 ++i;
889 } 892 }
890 893
891 // this loop orders the current elements 894 // this loop orders the current elements
892 while (!current_elts.empty ()) 895 while (!current_elts.empty ())
893 { 896 {
894 Drul_array<Real> last_end (-infinity_f, -infinity_f); 897 Drul_array<Real> last_end (-infinity_f, -infinity_f);
895 vector<Grob *> skipped_elements; 898 vector<Grob *> skipped_elements;
896 for (vsize j = l2r ? 0 : current_elts.size (); 899 for (vsize j = l2r ? 0 : current_elts.size ();
dak 2013/12/11 13:44:25 This is rather inscrutable, and it is worth noting
897 l2r ? j < current_elts.size () : j--; 900 l2r ? j < current_elts.size () : j--;
898 l2r ? j++ : 0) 901 l2r ? j++ : 0)
899 { 902 {
900 Grob *elt = current_elts[j]; 903 Grob *elt = current_elts[j];
901 Real horizon_padding 904 Real horizon_padding
902 = robust_scm2double (elt->get_property ("outside-staff-horizontal- padding"), 0.0); 905 = robust_scm2double (elt->get_property ("outside-staff-horizontal- padding"), 0.0);
903 Interval x_extent = elt->extent (x_common, X_AXIS); 906 Interval x_extent = elt->extent (x_common, X_AXIS);
904 x_extent.widen (horizon_padding); 907 x_extent.widen (horizon_padding);
905 908
906 Direction dir = get_grob_direction (elt); 909 Direction dir = get_grob_direction (elt);
907 if (dir == CENTER) 910 if (dir == CENTER)
908 { 911 {
909 warning (_ ("an outside-staff object should have a direction, de faulting to up")); 912 warning (_ ("an outside-staff object should have a direction, de faulting to up"));
910 elt->set_property ("direction", scm_from_int (UP)); 913 elt->set_property ("direction", scm_from_int (UP));
911 dir = UP; 914 dir = UP;
912 } 915 }
913 916
914 if (x_extent[LEFT] <= last_end[dir] && polite) 917 if (x_extent[LEFT] <= last_end[dir] && polite)
dak 2013/12/11 13:44:25 Shouldn't that be < here?
915 { 918 {
916 skipped_elements.push_back (elt); 919 skipped_elements.push_back (elt);
917 continue; 920 continue;
918 } 921 }
919 last_end[dir] = x_extent[RIGHT]; 922 last_end[dir] = x_extent[RIGHT];
920 923
921 outside_staff_elements.push_back (elt); 924 outside_staff_elements.push_back (elt);
922 } 925 }
923 swap (current_elts, skipped_elements); 926 swap (current_elts, skipped_elements);
924 skipped_elements.clear (); 927 skipped_elements.clear ();
dak 2013/12/11 13:44:25 If we have r->l order here, the loop was run backw
925 } 928 }
926 } 929 }
927 930
928 elements.clear (); 931 elements.clear ();
929 elements.insert (elements.end (), inside_staff_elements.begin (), inside_staff _elements.end ()); 932 elements.insert (elements.end (), inside_staff_elements.begin (), inside_staff _elements.end ());
930 elements.insert (elements.end (), outside_staff_elements.begin (), outside_sta ff_elements.end ()); 933 elements.insert (elements.end (), outside_staff_elements.begin (), outside_sta ff_elements.end ());
931 } 934 }
932 935
933 // It is tricky to correctly handle skyline placement of cross-staff grobs. 936 // It is tricky to correctly handle skyline placement of cross-staff grobs.
934 // For example, cross-staff beams cannot be formatted until the distance between 937 // For example, cross-staff beams cannot be formatted until the distance between
(...skipping 22 matching lines...) Expand all
957 960
958 961
959 Drul_array<vector<Skyline_pair> > all_v_skylines; 962 Drul_array<vector<Skyline_pair> > all_v_skylines;
960 963
961 for (vsize i = 0; i < elements.size (); i++) 964 for (vsize i = 0; i < elements.size (); i++)
962 { 965 {
963 // don't do anything with grobs present 966 // don't do anything with grobs present
964 // in the inside staff skyline 967 // in the inside staff skyline
965 Grob *elt = elements[i]; 968 Grob *elt = elements[i];
966 Grob *ancestor = outside_staff_ancestor (elt); 969 Grob *ancestor = outside_staff_ancestor (elt);
967 if (!ancestor && !scm_is_number (elt->get_property ("outside-staff-priorit y"))) 970 if (!ancestor && !scm_is_number (elt->get_property ("outside-staff-priorit y")))
dak 2013/12/11 13:44:25 There is no point in calculating the outside_staff
968 continue; 971 continue;
969 972
970 Skyline_pair *v_orig = Skyline_pair::unsmob (elt->get_property ("vertical- skylines")); 973 Skyline_pair *v_orig = Skyline_pair::unsmob (elt->get_property ("vertical- skylines"));
971 if (v_orig->is_empty ()) 974 if (v_orig->is_empty ())
972 continue; 975 continue;
973 976
974 Skyline_pair v_skylines (*v_orig); 977 Skyline_pair v_skylines (*v_orig);
975 // recursive in case the grobs' parent has a direction set but not the gro b 978 // recursive in case the grobs' parent has a direction set but not the gro b
976 Direction dir = recursive_get_grob_direction (elt); 979 Direction dir = recursive_get_grob_direction (elt);
977 v_skylines.shift (elt->relative_coordinate (x_common, X_AXIS)); 980 v_skylines.shift (elt->relative_coordinate (x_common, X_AXIS));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 "pure-relevant-items " 1071 "pure-relevant-items "
1069 "pure-relevant-spanners " 1072 "pure-relevant-spanners "
1070 "pure-Y-common " 1073 "pure-Y-common "
1071 "staff-affinity " 1074 "staff-affinity "
1072 "staff-grouper " 1075 "staff-grouper "
1073 "staff-staff-spacing " 1076 "staff-staff-spacing "
1074 "system-Y-offset " 1077 "system-Y-offset "
1075 "X-common " 1078 "X-common "
1076 "Y-common " 1079 "Y-common "
1077 ); 1080 );
LEFTRIGHT

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