X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fscript-column.cc;h=b9c9e178f4bc65ddf3e28d3a9ceb76fd0d694bda;hb=98b690b03df23d45ae827340c00700be8814c156;hp=30e2b68f62bcf7f3a5d3c34239f7b4726c32eb4c;hpb=b7a0cffbf9d1069860368f289a5b50e9d1d90ba8;p=lilypond.git diff --git a/lily/script-column.cc b/lily/script-column.cc index 30e2b68f62..b9c9e178f4 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1999--2009 Han-Wen Nienhuys + Copyright (C) 1999--2011 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -116,7 +116,7 @@ Script_column::before_line_breaking (SCM smob) Side_position_interface::x_aligned_side_proc) staff_sided.push_back (sc); } - + order_grobs (staff_sided); return SCM_UNSPECIFIED; } @@ -139,26 +139,39 @@ Script_column::order_grobs (vector grobs) SCM ss = scm_reverse_x (scripts_drul[d], SCM_EOL); ss = scm_stable_sort_x (ss, ly_grob_script_priority_less_proc); - Grob *last = 0; - for (SCM s = ss; scm_is_pair (s); s = scm_cdr (s)) + 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) { - Grob *g = unsmob_grob (scm_car (s)); - if (last) - { - SCM outside_staff = last->get_property ("outside-staff-priority"); - if (scm_is_number (outside_staff)) - { - /* we allow the outside-staff-priority ordering to override the - script-priority ordering */ - if (!scm_is_number (g->get_property ("outside-staff-priority"))) - g->set_property ("outside-staff-priority", - scm_from_double (scm_to_double (outside_staff) + 0.1)); - } - else + 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, just + use it as a support for the current grob + */ + if (!scm_is_number (last_outside_staff)) Side_position_interface::add_support (g, last); + /* + 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)); } - - last = g; } } while (flip (&d) != DOWN); @@ -166,8 +179,8 @@ Script_column::order_grobs (vector grobs) ADD_INTERFACE (Script_column, "An interface that sorts scripts according to their" - " @code{script-priority}.", - + " @code{script-priority} and @code{outside-staff-priority}.", + /* properties */ "" );