- Item * support_l=0;
- int j = 0;
- for (; j < 2; j++ ) {
- for (int i=1; i < placed_l_arr_a[j].size(); i++) {
- if (support_l)
- placed_l_arr_a[j][i]->add_support(support_l);
- support_l = placed_l_arr_a[j][i];
- }
- }
- support_l = 0;
- for (; j < 4; j++ ) {
- for (int i=1; i < placed_l_arr_a[j].size(); i++) {
- if (support_l)
- placed_l_arr_a[j][i]->add_support(support_l);
- support_l = placed_l_arr_a[j][i];
- }
+
+ for (DOWN_and_UP (d))
+ {
+ SCM ss = scm_reverse_x (scripts_drul[d], SCM_EOL);
+ ss = scm_stable_sort_x (ss, ly_grob_script_priority_less_proc);
+
+ Grob *g = 0; // current grob in list
+ Grob *last = 0; // previous grob in list
+ SCM initial_outside_staff = SCM_EOL; // initial outside_staff_priority of current grob
+ SCM last_initial_outside_staff = SCM_EOL; // initial outside_staff_priority of previous grob
+
+ // loop over all grobs in script column (already sorted by script_priority)
+ for (SCM s = ss; scm_is_pair (s);
+ s = scm_cdr (s), last = g, last_initial_outside_staff = initial_outside_staff)
+ {
+ g = unsmob<Grob> (scm_car (s));
+ initial_outside_staff = g->get_property ("outside-staff-priority");
+ if (last) //not the first grob in the list
+ {
+ SCM last_outside_staff = last->get_property ("outside-staff-priority");
+ /*
+ if outside_staff_priority is missing for previous grob,
+ use all the scripts so far as support for the current grob
+ */
+ if (!scm_is_number (last_outside_staff))
+ for (SCM t = ss; !scm_is_eq (t, s); t = scm_cdr (t))
+ Side_position_interface::add_support (g, unsmob<Grob> (scm_car (t)));
+ /*
+ if outside_staff_priority is missing or is equal to original
+ outside_staff_priority of previous grob, set new
+ outside_staff_priority to just higher than outside_staff_priority
+ of previous grob in order to preserve ordering.
+ */
+ else if ((!scm_is_number (initial_outside_staff))
+ || (fabs (scm_to_double (initial_outside_staff)
+ - robust_scm2double (last_initial_outside_staff, 0)) < 0.001))
+ g->set_property ("outside-staff-priority",
+ scm_from_double (scm_to_double (last_outside_staff) + 0.1));
+ }
+ }