compressed.extent_[UP] = old.extent_[UP] + orig[i].extent_.length () + old.padding_;
compressed.space_ += old.space_;
compressed.inverse_hooke_ += old.inverse_hooke_;
+ compressed.title_ = old.title_;
/* we don't need the force_ field for the vertical spacing,
so we use force_ = n to signal that the line was compressed,
book_ = pb;
ragged_ = to_boolean (pb->paper_->c_variable ("ragged-bottom"));
ragged_last_ = to_boolean (pb->paper_->c_variable ("ragged-last-bottom"));
+ page_top_space_ = robust_scm2double (pb->paper_->c_variable ("page-top-space"), 0);
create_system_list ();
find_chunks_and_breaks (is_break);
}
return ragged_last_;
}
+Real
+Page_breaking::page_top_space () const
+{
+ return page_top_space_;
+}
+
/* translate indices into breaks_ into start-end parameters for the line breaker */
void
Page_breaking::line_breaker_args (vsize sys,
ly_symbol2scm ("is-last"), scm_from_bool (last),
SCM_UNDEFINED));
SCM height = scm_apply_1 (calc_height, page, SCM_EOL);
- return scm_to_double (height) - scm_to_double (book_->paper_->c_variable ("page-top-space"));
+ return scm_to_double (height) - page_top_space_;
}
SCM
Page_spacing_result res;
vsize page = 0;
vsize page_first_line = 0;
- Page_spacing space (page_height (first_page_num, false));
+ Page_spacing space (page_height (first_page_num, false), page_top_space_);
cache_line_details (configuration);
for (vsize line = 0; line < cached_line_details_.size (); line++)
Page_spacing_result
Page_breaking::space_systems_on_1_page (vector<Line_details> const &lines, Real page_height, bool ragged)
{
- Page_spacing space (page_height);
+ Page_spacing space (page_height, page_top_space_);
Page_spacing_result ret;
for (vsize i = 0; i < lines.size (); i++)
vector<Real> page1_force;
vector<Real> page2_force;
- Page_spacing page1 (page1_height);
- Page_spacing page2 (page2_height);
+ Page_spacing page1 (page1_height, page_top_space_);
+ Page_spacing page2 (page2_height, page_top_space_);
page1_force.resize (cached_line_details_.size () - 1, infinity_f);
page2_force.resize (cached_line_details_.size () - 1, infinity_f);
void
Page_spacing::calc_force ()
{
- if (rod_height_ + last_line_.bottom_padding_ >= page_height_)
+ /* If the first system is a title, we add back in the page-top-space. */
+ Real height = first_line_.title_ ? page_height_ + page_top_space_ : page_height_;
+
+ if (rod_height_ + last_line_.bottom_padding_ >= height)
force_ = infinity_f;
else
- force_ = (page_height_ - rod_height_ - last_line_.bottom_padding_ - spring_len_)
+ force_ = (height - rod_height_ - last_line_.bottom_padding_ - spring_len_)
/ max (0.1, inverse_spring_k_);
}
void
Page_spacing::append_system (const Line_details &line)
{
+ if (!rod_height_)
+ first_line_ = line;
+
rod_height_ += last_line_.padding_;
rod_height_ += line.extent_.length ();
spring_len_ += line.space_;
inverse_spring_k_ += line.inverse_hooke_;
+ first_line_ = line;
+
calc_force ();
}
Page_spacer::calc_subproblem (vsize page, vsize line)
{
bool last = line == lines_.size () - 1;
- Page_spacing space (breaker_->page_height (page + first_page_num_, last));
+ Page_spacing space (breaker_->page_height (page + first_page_num_, last),
+ breaker_->page_top_space ());
Page_spacing_node &cur = state_.at (line, page);
bool ragged = ragged_ || (ragged_last_ && last);