struct Break_position
{
- /* our index in the all_ list */
- vsize sys_;
+ vsize system_spec_index_;
- /* if sys_ is a score, then we start at the score_brk_'th possible
+ /* if system_spec_index_ is a score, then we start at the score_brk_'th possible
page-break in the score */
vsize score_break_;
- /* if sys_ is a score, this points to the broken column */
+ /* if system_spec_index_ is a score, this points to the broken column */
Grob *col_;
bool score_ender_;
Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false)
{
- sys_ = s;
+ system_spec_index_ = s;
score_break_ = brk;
col_ = g;
score_ender_ = end;
}
/*
- lexicographic in (sys_, score_break_)
+ lexicographic in (system_spec_index_, score_break_)
*/
bool operator< (const Break_position &other)
{
- return (sys_ == VPOS && other.sys_ != VPOS)
- || (sys_ < other.sys_)
- || (sys_ == other.sys_ && score_break_ < other.score_break_);
+ return (system_spec_index_ == VPOS && other.system_spec_index_ != VPOS)
+ || (system_spec_index_ < other.system_spec_index_)
+ || (system_spec_index_ == other.system_spec_index_ && score_break_ < other.score_break_);
}
bool operator<= (const Break_position &other)
{
- return (sys_ == VPOS)
- || (sys_ < other.sys_ && other.sys_ != VPOS)
- || (sys_ == other.sys_ && score_break_ <= other.score_break_);
+ return (system_spec_index_ == VPOS)
+ || (system_spec_index_ < other.system_spec_index_ && other.system_spec_index_ != VPOS)
+ || (system_spec_index_ == other.system_spec_index_ && score_break_ <= other.score_break_);
}
};
bool ragged () const;
bool ragged_last () const;
- bool last () const;
+ bool is_last () const;
Real page_height (int page_number, bool last) const;
protected:
SCM breakpoint_property (vsize breakpoint, char const *str);
-
-protected:
- vector<Break_position> breaks_;
-
+ vsize last_break_position () const;
private:
+ vector<Break_position> breaks_;
vector<Break_position> chunks_;
vector<System_spec> system_specs_;
vector<Constrained_breaking> line_breaking_;
vsize
Page_breaking::next_system (Break_position const &break_pos) const
{
- vsize sys = break_pos.sys_;
+ vsize sys = break_pos.system_spec_index_;
if (sys == VPOS) /* beginning of the book */
return 0;
vsize *line_breaker_end)
{
assert (system_specs_[sys].pscore_);
- assert (next_system (start) <= sys && sys <= end.sys_);
+ assert (next_system (start) <= sys && sys <= end.system_spec_index_);
- if (start.sys_ == sys)
+ if (start.system_spec_index_ == sys)
*line_breaker_start = start.score_break_;
else
*line_breaker_start = 0;
- if (end.sys_ == sys)
+ if (end.system_spec_index_ == sys)
*line_breaker_end = end.score_break_;
else
*line_breaker_end = VPOS;
{
Break_position const &pos = breaks_[breakpoint];
- if (pos.sys_ == VPOS)
+ if (pos.system_spec_index_ == VPOS)
return SCM_EOL;
- if (system_specs_[pos.sys_].pscore_)
+ if (system_specs_[pos.system_spec_index_].pscore_)
return pos.col_->get_property (str);
- return system_specs_[pos.sys_].prob_->get_property (str);
+ return system_specs_[pos.system_spec_index_].prob_->get_property (str);
}
SCM
return Spacing_result ();
if (n == 1)
ret = space_systems_on_1_page (cached_line_details_,
- page_height (first_page_num, last ()),
- ragged () || (last () && ragged_last ()));
+ page_height (first_page_num, is_last ()),
+ ragged () || (is_last () && ragged_last ()));
else if (n == 2)
ret = space_systems_on_2_pages (configuration, first_page_num);
else
Real
Page_breaking::blank_page_penalty () const
{
- SCM penalty_sym = last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force");
+ SCM penalty_sym = is_last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force");
return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0);
}
Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_num)
{
Real page1_height = page_height (first_page_num, false);
- Real page2_height = page_height (first_page_num+1, last ());
+ Real page2_height = page_height (first_page_num + 1, is_last ());
bool ragged1 = ragged ();
- bool ragged2 = ragged () || (last () && ragged_last ());
+ bool ragged2 = ragged () || (is_last () && ragged_last ());
/* if there is a forced break, this reduces to 2 1-page problems */
cache_line_details (configuration);
return current_configurations_[configuration_index];
}
-bool Page_breaking::last () const
+bool
+Page_breaking::is_last () const
+{
+ return current_end_breakpoint_ == last_break_position ();
+}
+
+vsize
+Page_breaking::last_break_position () const
{
- return current_end_breakpoint_ == breaks_.size () - 1;
+ return breaks_.size () - 1;
}