X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fpage-breaking.hh;h=9f226ebafdcba931b3804bfaa9185e1396650f0b;hb=77706635f33adff837dc7af0482f51ff3f0f5cb1;hp=18704fd36b61f68a25ee50858983078ebcc1c9c8;hpb=5abf10a3f05d1264b3dc8d92f56639df27e11bbc;p=lilypond.git diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index 18704fd36b..9f226ebafd 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -1,10 +1,20 @@ /* - page-breaking.hh -- declare a superclass and utility - functions for several different page-breaking algorithms + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2006--2010 Joe Neeman - (c) 2006--2007 Joe Neeman + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #ifndef PAGE_BREAKING_HH @@ -42,24 +52,30 @@ struct System_spec struct Break_position { /* - index in system_spec_index_, if VPOS start of book. + index into system_specs_, if this is VPOS, the Break_position represents the + start of the 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 */ + /* if system_spec_index_ indexes 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 */ + /* if system_spec_index_ indexes a score, this points to the broken column */ Grob *col_; bool score_ender_; + /* if non-zero, this is the (fixed, uncompressed) number of lines between + this Break_position and the previous. */ + int forced_line_count_; + Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false) { system_spec_index_ = s; score_break_ = brk; col_ = g; score_ender_ = end; + forced_line_count_ = 0; } /* @@ -84,6 +100,7 @@ class Page_breaking { public: typedef bool (*Break_predicate) (Grob *); + typedef bool (*Prob_break_predicate) (Prob *); typedef vector Line_division; /* @@ -94,14 +111,26 @@ public: */ virtual SCM solve () = 0; - Page_breaking (Paper_book *pb, Break_predicate); + Page_breaking (Paper_book *pb, Break_predicate, Prob_break_predicate); virtual ~Page_breaking (); bool ragged () const; bool ragged_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; + Real paper_height () 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; + Real min_whitespace_at_top_of_page (Line_details const&) const; + Real min_whitespace_at_bottom_of_page (Line_details const&) const; + int orphan_penalty () const; protected: Paper_book *book_; @@ -127,11 +156,14 @@ protected: vsize current_configuration_count () const; Line_division current_configuration (vsize configuration_index) const; Page_spacing_result space_systems_on_n_pages (vsize configuration_index, - vsize n, vsize first_page_num); + 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); + vsize first_page_num, + Real penalty_for_fewer_pages); Page_spacing_result space_systems_on_best_pages (vsize configuration_index, - vsize first_page_num); + 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); @@ -148,7 +180,11 @@ private: vector line_breaking_; bool ragged_; bool ragged_last_; - Real page_top_space_; + int systems_per_page_; + int max_systems_per_page_; + int min_systems_per_page_; + vsize system_count_; + int orphan_penalty_; vector current_configurations_; vector current_chunks_; @@ -156,11 +192,16 @@ private: vsize current_end_breakpoint_; void cache_line_details (vsize configuration_index); + void compute_line_heights (); void clear_line_details_cache (); vsize cached_configuration_index_; vector cached_line_details_; vector uncompressed_line_details_; + Real paper_height_; + mutable vector page_height_cache_; + mutable vector last_page_height_cache_; + vector chunk_list (vsize start, vsize end); Line_division system_count_bounds (vector const &chunks, bool min); void line_breaker_args (vsize i, @@ -179,6 +220,9 @@ private: 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); + void find_chunks_and_breaks (Break_predicate, Prob_break_predicate); + SCM make_page (int page_num, bool last) const; + SCM get_page_configuration (SCM systems, int page_num, bool ragged, bool last); + SCM draw_page (SCM systems, SCM config, int page_num, bool last); }; #endif /* PAGE_BREAKING_HH */