- (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ 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/>.
its neighbor (ie. no funny polyphonic stuff), don't make it loose.
*/
if (l == l_neighbor && r == r_neighbor && col->extent (col, X_AXIS).length () > 0)
its neighbor (ie. no funny polyphonic stuff), don't make it loose.
*/
if (l == l_neighbor && r == r_neighbor && col->extent (col, X_AXIS).length () > 0)
nicely folded, but hey, then don't do that.
*/
if (! ((Paper_column::is_musical (l_neighbor) || Paper_column::is_breakable (l_neighbor))
nicely folded, but hey, then don't do that.
*/
if (! ((Paper_column::is_musical (l_neighbor) || Paper_column::is_breakable (l_neighbor))
- {
- extract_grob_set (g, "elements", gelts);
- for (vsize j = gelts.size (); j--;)
- {
- Grob *h = gelts[j];
-
- if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar"))
- {
- extract_grob_set (h, "elements", helts);
- for (vsize k = helts.size (); k--;)
- if ("" != robust_scm2string (helts[k]->get_property ("glyph-name"), ""))
- return false;
- }
- }
- }
+ {
+ extract_grob_set (g, "elements", gelts);
+ for (vsize j = gelts.size (); j--;)
+ {
+ Grob *h = gelts[j];
+
+ if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar"))
+ {
+ extract_grob_set (h, "elements", helts);
+ for (vsize k = helts.size (); k--;)
+ if ("" != robust_scm2string (helts[k]->get_property ("glyph-name"), ""))
+ return false;
+ }
+ }
+ }
- Drul_array<Item *> next_door,
- Spacing_options const *options)
+ Drul_array<Item *> next_door,
+ Spacing_options const *options)
{
Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
extract_grob_set (lc, "spacing-wishes", wishes);
for (vsize k = wishes.size (); k--;)
{
Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
extract_grob_set (lc, "spacing-wishes", wishes);
for (vsize k = wishes.size (); k--;)
- {
- Grob *sp = wishes[k];
- if (Spacing_interface::left_column (sp) != lc
- || Spacing_interface::right_column (sp) != rc)
- continue;
-
- if (Note_spacing::has_interface (sp))
- {
- /*
- The note spacing should be taken from the musical
- columns.
- */
- Real base = note_spacing (me, lc, rc, options);
- Spring spring = Note_spacing::get_spacing (sp, rc, base, options->increment_);
-
- dists[d] = max (dists[d], spring.min_distance ());
- }
- else if (Staff_spacing::has_interface (sp))
- {
- Spring spring = Staff_spacing::get_spacing (sp, rc);
-
- dists[d] = max (dists[d], spring.min_distance ());
- }
- else
- programming_error ("Subversive spacing wish");
- }
+ {
+ Grob *sp = wishes[k];
+ if (Spacing_interface::left_column (sp) != lc
+ || Spacing_interface::right_column (sp) != rc)
+ continue;
+
+ if (Note_spacing::has_interface (sp))
+ {
+ /*
+ The note spacing should be taken from the musical
+ columns.
+ */
+ Real base = note_spacing (me, lc, rc, options);
+ Spring spring = Note_spacing::get_spacing (sp, rc, base, options->increment_);
+
+ dists[d] = max (dists[d], spring.min_distance ());
+ }
+ else if (Staff_spacing::has_interface (sp))
+ {
+ Spring spring = Staff_spacing::get_spacing (sp, rc, 0.0);
+
+ dists[d] = max (dists[d], spring.min_distance ());
+ }
+ else
+ programming_error ("Subversive spacing wish");
+ }
- && is_loose_column (cols->at (i - 1), c, cols->at (i + 1), options);
+ && is_loose_column (cols->at (i - 1), c, cols->at (i + 1), options);
/* Breakable columns never get pruned; even if they are loose,
their broken pieces are not. However, we mark them so that
the spacing can take their mid-line looseness into account. */
if (loose && Paper_column::is_breakable (c))
/* Breakable columns never get pruned; even if they are loose,
their broken pieces are not. However, we mark them so that
the spacing can take their mid-line looseness into account. */
if (loose && Paper_column::is_breakable (c))
- {
- loose = false;
- c->set_property ("maybe-loose", SCM_BOOL_T);
- }
+ {
+ loose = false;
+ c->set_property ("maybe-loose", SCM_BOOL_T);
+ }
+ /*
+ Unbreakable columns which only contain page-labels also
+ never get pruned, otherwise the labels are lost before they can
+ be collected by the System: so we mark these columns too.
+ */
+ if (!loose && !Paper_column::is_breakable (c)
+ && scm_is_pair (c->get_property ("labels")))
+ {
+ extract_grob_set (c, "elements", elts);
+ if (elts.empty ())
+ c->set_property ("maybe-loose", SCM_BOOL_T);
+ }
- {
- Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor"));
- Grob *left_neighbor = unsmob_grob (c->get_object ("left-neighbor"));
-
- /*
- Either object can be non existent, if the score ends
- prematurely.
- */
- if (!right_neighbor || !left_neighbor)
- {
- c->programming_error ("Cannot determine neighbors for floating column. ");
- c->set_object ("between-cols", scm_cons (cols->at (i-1)->self_scm (),
- cols->at (i+1)->self_scm ()));
- }
- else
- {
- c->set_object ("between-cols", scm_cons (left_neighbor->self_scm (),
- right_neighbor->self_scm ()));
-
-
- /*
- Set distance constraints for loose columns
- */
- Drul_array<Item *> next_door (dynamic_cast<Item*> (cols->at (i - 1)),
- dynamic_cast<Item*> (cols->at (i + 1)));
-
- set_distances_for_loose_col (me, c, next_door, options);
- }
- }
-
- if (!loose)
- newcols.push_back (c);
+ {
+ Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor"));
+ Grob *left_neighbor = unsmob_grob (c->get_object ("left-neighbor"));
+
+ /*
+ Either object can be non existent, if the score ends
+ prematurely.
+ */
+ if (!right_neighbor || !left_neighbor)
+ {
+ c->programming_error ("Cannot determine neighbors for floating column.");
+ c->set_object ("between-cols", scm_cons (cols->at (i - 1)->self_scm (),
+ cols->at (i + 1)->self_scm ()));
+ }
+ else
+ {
+ c->set_object ("between-cols", scm_cons (left_neighbor->self_scm (),
+ right_neighbor->self_scm ()));
+
+ /*
+ Set distance constraints for loose columns
+ */
+ Drul_array<Item *> next_door (dynamic_cast<Item *> (left_neighbor),
+ dynamic_cast<Item *> (right_neighbor));
+
+ set_distances_for_loose_col (me, c, next_door, options);
+ }
+ }
+
+ else
+ newcols.push_back (c);
{
for (vsize i = 0; i < cols.size (); i++)
{
extract_grob_set (cols[i], "spacing-wishes", wishes);
for (vsize j = wishes.size (); j--;)
{
for (vsize i = 0; i < cols.size (); i++)
{
extract_grob_set (cols[i], "spacing-wishes", wishes);
for (vsize j = wishes.size (); j--;)
- {
- Item *wish = dynamic_cast<Item*> (wishes[j]);
- Item *left_col = wish->get_column ();
- int left_rank = Paper_column::get_rank (left_col);
- int min_right_rank = INT_MAX;
-
- extract_grob_set (wish, "right-items", right_items);
- for (vsize k = right_items.size (); k--;)
- {
- Item *right_col = dynamic_cast<Item*> (right_items[k])->get_column ();
- int right_rank = Paper_column::get_rank (right_col);
-
- if (right_rank < min_right_rank)
- {
- left_col->set_object ("right-neighbor", right_col->self_scm ());
- min_right_rank = right_rank;
- }
-
- Grob *old_left_neighbor = unsmob_grob (right_col->get_object ("left-neighbor"));
- if (!old_left_neighbor || left_rank > Paper_column::get_rank (old_left_neighbor))
- right_col->set_object ("left-neighbor", left_col->self_scm ());
- }
- }
+ {
+ Item *wish = dynamic_cast<Item *> (wishes[j]);
+ Item *left_col = wish->get_column ();
+ int left_rank = Paper_column::get_rank (left_col);
+ int min_right_rank = INT_MAX;
+
+ extract_grob_set (wish, "right-items", right_items);
+ for (vsize k = right_items.size (); k--;)
+ {
+ Item *right_col = dynamic_cast<Item *> (right_items[k])->get_column ();
+ int right_rank = Paper_column::get_rank (right_col);
+
+ if (right_rank < min_right_rank)
+ {
+ left_col->set_object ("right-neighbor", right_col->self_scm ());
+ min_right_rank = right_rank;
+ }
+
+ Grob *old_left_neighbor = unsmob_grob (right_col->get_object ("left-neighbor"));
+ if (!old_left_neighbor || left_rank > Paper_column::get_rank (old_left_neighbor))
+ right_col->set_object ("left-neighbor", left_col->self_scm ());
+ }
+ }
{
for (vsize i = 0; i < cols.size (); i++)
{
Item *it = dynamic_cast<Item *> (cols[i]);
if (!Paper_column::is_breakable (it) && !Paper_column::is_musical (it))
{
for (vsize i = 0; i < cols.size (); i++)
{
Item *it = dynamic_cast<Item *> (cols[i]);
if (!Paper_column::is_breakable (it) && !Paper_column::is_musical (it))