/*
- spacing-interface.cc -- functionality that is shared between Note_spacing
- and Staff_spacing
+ This file is part of LilyPond, the GNU music typesetter.
- source file of the GNU LilyPond music typesetter
+ Copyright (C) 2007--2010 Joe Neeman <joeneeman@gmail.com>
- (c) 2007 Joe Neeman <joeneeman@gmail.com>
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#include "spacing-interface.hh"
#include "paper-column.hh"
#include "separation-item.hh"
#include "skyline.hh"
+#include "skyline-pair.hh"
#include "system.hh"
/* return the right-pointing skyline of the left-items and the left-pointing
}
/*
- Compute the column of the right-items. This is a big function,
- since RIGHT-ITEMS may span more columns (eg. if a clef is inserted,
- this will add a new column to RIGHT-ITEMS. Here we look at the
- columns, and return the left-most. If there are multiple columns, we
- prune RIGHT-ITEMS.
-
- If we end up pruning, we add a left-neighbor to every column that
- gets pruned. This ensures that loose columns in cross-staff music
- do indeed get marked as loose. The problem situation is when a voice
- passes from staff 1 to staff 2 and a clef appears later on in staff 1.
- Then the NoteSpacing attached to the last note in staff 1 has two
- right-items: one pointing to the next note in staff 2 and one pointing
- to the clef. We will prune the clef right-item here and, unless we add
- a left-neighbor to the clef, it won't get marked as loose.
+ Compute the left-most column of the right-items.
*/
Item *
Spacing_interface::right_column (Grob *me)
Grob_array *a = unsmob_grob_array (me->get_object ("right-items"));
Item *mincol = 0;
int min_rank = INT_MAX;
- bool prune = false;
for (vsize i = 0; a && i < a->size (); i++)
{
Item *ri = a->item (i);
if (rank < min_rank)
{
min_rank = rank;
- if (mincol)
- prune = true;
-
mincol = col;
}
- else if (rank > min_rank)
- prune = true;
- }
-
- if (prune && a)
- {
- vector<Grob*> &right = a->array_reference ();
- for (vsize i = right.size (); i--;)
- {
- if (dynamic_cast<Item *> (right[i])->get_column () != mincol)
- {
- extract_grob_set (right[i], "left-neighbors", lns);
- if (lns.empty ())
- Pointer_group_interface::add_grob (right[i],
- ly_symbol2scm ("left-neighbors"),
- dynamic_cast<Item*> (me)->get_column ());
-
- right.erase (right.begin () + i);
- }
- }
}
return mincol;