X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmelody-spanner.cc;h=826364bb7e79c9f7d2c89cf07bc03893af2aac82;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=03cf1370952e8abde3fdf1d96c168d35960374b8;hpb=75eebcb49e52d296b1da3e1074e0825d2c780db4;p=lilypond.git diff --git a/lily/melody-spanner.cc b/lily/melody-spanner.cc index 03cf137095..826364bb7e 100644 --- a/lily/melody-spanner.cc +++ b/lily/melody-spanner.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2005--2006 Han-Wen Nienhuys + (c) 2005--2008 Han-Wen Nienhuys */ @@ -20,33 +20,33 @@ /* Interpolate stem directions for neutral stems. */ -MAKE_SCHEME_CALLBACK(Melody_spanner,calc_neutral_stem_direction, 1); +MAKE_SCHEME_CALLBACK (Melody_spanner, calc_neutral_stem_direction, 1); SCM Melody_spanner::calc_neutral_stem_direction (SCM smob) { Grob *stem = unsmob_grob (smob); Grob *me = unsmob_grob (stem->get_object ("melody-spanner")); if (!me || !me->is_live ()) - return SCM_UNSPECIFIED; + return scm_from_int (DOWN); extract_grob_set (me, "stems", stems); - Array dirs; - for (int i = 0; i < stems.size (); i++) - { - dirs.push (to_dir (stems[i]->get_property ("default-direction"))); - } + vector dirs; + for (vsize i = 0; i < stems.size (); i++) + dirs.push_back (to_dir (stems[i]->get_property ("default-direction"))); - int last_nonneutral = -1; - int next_nonneutral = 0; - while (next_nonneutral < dirs.size() && !dirs[next_nonneutral]) - next_nonneutral ++; + vsize last_nonneutral = VPOS; + vsize next_nonneutral = 0; + while (next_nonneutral != VPOS && next_nonneutral < dirs.size () + && !dirs[next_nonneutral]) + next_nonneutral++; - while (last_nonneutral < dirs.size () - 1) + SCM retval = SCM_EOL; + while (last_nonneutral == VPOS || last_nonneutral + 1 < dirs.size ()) { Direction d1 = CENTER; Direction d2 = CENTER; - if (last_nonneutral >= 0) + if (last_nonneutral != VPOS) d1 = dirs[last_nonneutral]; if (next_nonneutral < dirs.size ()) d2 = dirs[next_nonneutral]; @@ -61,24 +61,27 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob) else total = to_dir (me->get_property ("neutral-direction")); - for (int i = last_nonneutral + 1; i < next_nonneutral; i++) - stems[i]->set_property ("neutral-direction", scm_from_int (total)); - + for (vsize i = last_nonneutral + 1; i < next_nonneutral; i++) + { + if (stems[i] == stem) + retval = scm_from_int (total); + else + stems[i]->set_property ("neutral-direction", scm_from_int (total)); + } last_nonneutral = next_nonneutral; while (last_nonneutral < dirs.size () && dirs[last_nonneutral]) - last_nonneutral ++; + last_nonneutral++; next_nonneutral = last_nonneutral; - last_nonneutral --; + last_nonneutral--; while (next_nonneutral < dirs.size () && !dirs[next_nonneutral]) - next_nonneutral ++; + next_nonneutral++; } - me->suicide (); - return SCM_UNSPECIFIED; + return retval; } void @@ -89,10 +92,12 @@ Melody_spanner::add_stem (Grob *me, Grob *stem) stem->set_property ("neutral-direction", Melody_spanner::calc_neutral_stem_direction_proc); } -ADD_INTERFACE (Melody_spanner, "melody-spanner-interface", +ADD_INTERFACE (Melody_spanner, "Context dependent typesetting decisions.", + /* properties */ "stems " - "neutral-direction "); + "neutral-direction " + );