X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fconstrained-breaking.cc;h=df08d5433ce6cefd38c944448a80c20f0350c8cf;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=b3236a518c4a7c65d0dfaaa300bffe93936539a1;hpb=d61cf3bbdb1c6670a127ba3baddf2f04d3e34fd3;p=lilypond.git diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index b3236a518c..df08d5433c 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2006--2012 Joe Neeman + Copyright (C) 2006--2015 Joe Neeman LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -202,8 +202,10 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count) } } /* if we get to here, just put everything on one line */ - warning (_ ("cannot find line breaking that satisfies constraints")); - ret.push_back (space_line (0, end_brk)); + if (sys_count > 0) { + warning (_ ("cannot find line breaking that satisfies constraints")); + ret.push_back (space_line (0, end_brk)); + } return ret; } @@ -291,9 +293,11 @@ Constrained_breaking::line_details (vsize start, vsize end, vsize sys_count) } /* if we get to here, just put everything on one line */ - Line_details details; - fill_line_details (&details, 0, end_brk); - ret.push_back (details); + if (sys_count > 0) { + Line_details details; + fill_line_details (&details, 0, end_brk); + ret.push_back (details); + } return ret; } @@ -361,10 +365,10 @@ Constrained_breaking::Constrained_breaking (Paper_score *ps, vector const static SCM min_permission (SCM perm1, SCM perm2) { - if (perm1 == ly_symbol2scm ("force")) + if (scm_is_eq (perm1, ly_symbol2scm ("force"))) return perm2; - if (perm1 == ly_symbol2scm ("allow") - && perm2 != ly_symbol2scm ("force")) + if (scm_is_eq (perm1, ly_symbol2scm ("allow")) + && !scm_is_eq (perm2, ly_symbol2scm ("force"))) return perm2; return SCM_EOL; } @@ -436,10 +440,10 @@ Constrained_breaking::initialize () breaks_ = pscore_->get_break_indices (); all_ = pscore_->root_system ()->used_columns (); lines_.resize (breaks_.size (), breaks_.size (), Line_details ()); - vector spacers - = pscore_->root_system ()->get_simple_spacers (other_lines.length (), - other_lines.length () - first_line.length (), - ragged_right_); + vector forces = get_line_forces (all_, + other_lines.length (), + other_lines.length () - first_line.length (), + ragged_right_); for (vsize i = 0; i + 1 < breaks_.size (); i++) { for (vsize j = i + 1; j < breaks_.size (); j++) @@ -448,18 +452,9 @@ Constrained_breaking::initialize () bool ragged = ragged_right_ || (last && ragged_last_); Line_details &line = lines_.at (j, i); - line.force_ = spacers[i * breaks_.size () + j].force_penalty (ragged_right_); - if (!spacers[i * breaks_.size () + j].fits ()) - { - if (spacers[i * breaks_.size () + j].minimal_) - line.force_ = -200000; - else - line.force_ = infinity_f; - } + line.force_ = forces[i * breaks_.size () + j]; if (ragged && last && !isinf (line.force_)) line.force_ = (line.force_ < 0 && j > i + 1) ? infinity_f : 0; - if (!line.force_ && !spacers[i * breaks_.size () + j].line_len ()) - line.force_ = infinity_f; if (isinf (line.force_)) break; @@ -565,7 +560,7 @@ Line_details::Line_details (Prob *pb, Output_def *paper) if (scm_is_pair (footnotes)) for (SCM s = footnotes; scm_is_pair (s); s = scm_cdr (s)) { - Stencil *sten = unsmob_stencil (scm_caddar (s)); + Stencil *sten = unsmob (scm_caddar (s)); if (!sten) { programming_error ("expecting stencil, got empty pointer"); @@ -576,7 +571,9 @@ Line_details::Line_details (Prob *pb, Output_def *paper) last_column_ = 0; force_ = 0; - Interval stencil_extent = unsmob_stencil (pb->get_property ("stencil"))->extent (Y_AXIS); + Stencil *st = unsmob (pb->get_property ("stencil")); + Interval stencil_extent = st->is_empty (Y_AXIS) ? Interval (0, 0) + : st->extent (Y_AXIS); shape_ = Line_shape (stencil_extent, stencil_extent); // pretend it goes all the way across tallness_ = 0; bottom_padding_ = 0;