X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fpage-breaking.hh;h=c6c1bc02c80b88c32b0fa2b0275a70fcbb6d1fca;hb=b76907a5a0c3663895350205e29c7462db4b2b45;hp=23ffbd807ec0df559a3b13c56e6c13fb6da5ad43;hpb=9cada1c1aa1666beb1895a31c95671f7cc32c205;p=lilypond.git diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index 23ffbd807e..c6c1bc02c8 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter - (c) 2006--2007 Joe Neeman + (c) 2006--2009 Joe Neeman */ #ifndef PAGE_BREAKING_HH @@ -41,32 +41,42 @@ struct System_spec struct Break_position { - vsize sys_; /* our index in the all_ list */ - vsize score_break_; /* if sys_ is a score, then we start at the score_brk_'th - possible page-break in the score */ - Grob *col_; /* if sys_ is a score, this points to the broken column */ + /* + index in system_spec_index_, if VPOS start of book. + */ + vsize system_spec_index_; + + /* 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 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 (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_); } }; @@ -75,6 +85,13 @@ class Page_breaking public: typedef bool (*Break_predicate) (Grob *); typedef vector Line_division; + + /* + TODO: naming. + + determine the page breaking, and break scores into lines + appropriately. + */ virtual SCM solve () = 0; Page_breaking (Paper_book *pb, Break_predicate); @@ -82,8 +99,18 @@ public: bool ragged () const; bool ragged_last () const; - bool last () const; + bool is_last () const; + bool ends_score () const; + int systems_per_page () const; + int max_systems_per_page () const; + int min_systems_per_page () const; Real page_height (int page_number, bool last) const; + Real page_top_space () const; + vsize system_count () const; + Real line_count_penalty (int line_count) const; + int line_count_status (int line_count) const; + bool too_many_lines (int line_count) const; + bool too_few_lines (int line_count) const; protected: Paper_book *book_; @@ -104,24 +131,39 @@ protected: vsize system_count, Line_division lower_bound = Line_division (), Line_division upper_bound = Line_division ()); + void set_to_ideal_line_configuration (vsize start, vsize end); + vsize current_configuration_count () const; Line_division current_configuration (vsize configuration_index) const; - Spacing_result space_systems_on_n_pages (vsize configuration_index, vsize n, vsize first_page_num); - Spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n, vsize first_page_num); - Spacing_result space_systems_on_best_pages (vsize configuration_index, vsize first_page_num); + Page_spacing_result space_systems_on_n_pages (vsize configuration_index, + vsize n, vsize first_page_num); + Page_spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n, + vsize first_page_num); + Page_spacing_result space_systems_on_best_pages (vsize configuration_index, + vsize first_page_num); + Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index, + vsize first_page_num); + Page_spacing_result pack_systems_on_least_pages (vsize configuration_index, + vsize first_page_num); vsize min_page_count (vsize configuration_index, vsize first_page_num); bool all_lines_stretched (vsize configuration_index); Real blank_page_penalty () const; SCM breakpoint_property (vsize breakpoint, char const *str); - vector breaks_; + vsize last_break_position () const; private: + vector breaks_; vector chunks_; - vector all_; + vector system_specs_; vector line_breaking_; bool ragged_; bool ragged_last_; + int systems_per_page_; + int max_systems_per_page_; + int min_systems_per_page_; + Real page_top_space_; + vsize system_count_; vector current_configurations_; vector current_chunks_; @@ -132,6 +174,7 @@ private: void clear_line_details_cache (); vsize cached_configuration_index_; vector cached_line_details_; + vector uncompressed_line_details_; vector chunk_list (vsize start, vsize end); Line_division system_count_bounds (vector const &chunks, bool min); @@ -147,9 +190,9 @@ private: Line_division *cur); vector line_details (vsize start, vsize end, Line_division const &div); - Spacing_result space_systems_on_1_page (vector const &lines, Real page_height, bool ragged); - Spacing_result space_systems_on_2_pages (vsize configuration_index, vsize first_page_num); - Spacing_result finalize_spacing_result (vsize configuration_index, Spacing_result); + Page_spacing_result space_systems_on_1_page (vector const &lines, Real page_height, bool ragged); + Page_spacing_result space_systems_on_2_pages (vsize configuration_index, vsize first_page_num); + Page_spacing_result finalize_spacing_result (vsize configuration_index, Page_spacing_result); void create_system_list (); void find_chunks_and_breaks (Break_predicate); };