X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fsimple-spacer.cc;h=a44e9f8d7546d8262d7a74af30fae5226a9f82c9;hb=7979d8adaa8393daefd6585534221a93dd526758;hp=aa6269be08087d869d625dd96c44a0a8b44f81c4;hpb=d765f3af45be51f15da55cf570a4b172200e1035;p=lilypond.git diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index aa6269be08..a44e9f8d75 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2002 Han-Wen Nienhuys + (c) 1999--2003 Han-Wen Nienhuys TODO: - add support for different stretch/shrink constants? @@ -144,13 +144,7 @@ Simple_spacer::active_blocking_force () const Real Simple_spacer::active_springs_stiffness () const { - Real den = 0.0; - for (int i=0; i < springs_.size (); i++) - if (springs_[i].active_b_) - { - den += 1 / springs_[i].hooke_; - } - return 1/den; + return range_stiffness (0, springs_.size ()); } void @@ -302,13 +296,7 @@ Simple_spacer::add_columns (Link_array const &icols) } } - /* - TODO: should support natural length on only the last line. - */ - if (line_len_ < 0) - my_solve_natural_len (); - else - my_solve_linelen (); + } /* @@ -327,21 +315,22 @@ Simple_spacer::add_columns (Link_array const &icols) */ void -Simple_spacer::solve (Column_x_positions *positions, bool ragged) const +Simple_spacer::solve (Column_x_positions *positions, bool ragged) { - positions->force_ = force_; - if ((force_ < 0)) - { - - /* - We used to have a penalty for compression, no matter what, but that - fucked up wtk1-fugue2 (taking 3 full pages.) + /* + TODO: should support natural length on only the last line. + */ + ragged = ragged || (line_len_ < 0) ; + if (ragged) + my_solve_natural_len (); + else + my_solve_linelen (); - maybe this should be tunable? - */ - if (compression_penalty_b_) - ; // positions->force_ *= 2; // hmm. - } + positions->force_ = force_; + /* + We used to have a penalty for compression, no matter what, but that + fucked up wtk1-fugue2 (taking 3 full pages.) + */ positions->config_.push (indent_); for (int i=0; i = 0 here, up to rounding errors */ } + + /* + For raggedright, we must have a measure of music density: this is + to prevent lots of short lines (which all have force = 0). + */ + if (ragged && line_len_ > 0) + { + Real len = positions->config_.top (); + positions->force_ = (line_len_ - len) * active_springs_stiffness (); + } + + positions->cols_ = spaced_cols_; positions->loose_cols_ = loose_cols_; - positions->satisfies_constraints_b_ = (line_len_ < 0) || active_b (); - /* Check if breaking constraints are met. */