source file of the GNU LilyPond music typesetter
- (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1999--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
TODO:
- add support for different stretch/shrink constants?
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
}
}
- /*
- TODO: should support natural length on only the last line.
- */
- if (line_len_ < 0)
- my_solve_natural_len ();
- else
- my_solve_linelen ();
+
}
/*
*/
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 <springs_.size (); i++)
we have l>= 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.
*/