2 page-breaking.hh -- declare a superclass and utility
3 functions for several different page-breaking algorithms
5 source file of the GNU LilyPond music typesetter
7 (c) 2006--2007 Joe Neeman <joeneeman@gmail.com>
10 #ifndef PAGE_BREAKING_HH
11 #define PAGE_BREAKING_HH
13 #include "constrained-breaking.hh"
14 #include "page-spacing.hh"
16 /* Either a paper-score, markup or header.
20 System_spec (Paper_score *ps)
26 System_spec (Prob *pb)
44 vsize sys_; /* our index in the all_ list */
45 vsize score_break_; /* if sys_ is a score, then we start at the score_brk_'th
46 possible page-break in the score */
47 Grob *col_; /* if sys_ is a score, this points to the broken column */
50 Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false)
58 bool operator< (const Break_position &other)
60 return (sys_ == VPOS && other.sys_ != VPOS)
61 || (sys_ < other.sys_)
62 || (sys_ == other.sys_ && score_break_ < other.score_break_);
65 bool operator<= (const Break_position &other)
68 || (sys_ < other.sys_ && other.sys_ != VPOS)
69 || (sys_ == other.sys_ && score_break_ <= other.score_break_);
76 typedef bool (*Break_predicate) (Grob *);
77 typedef vector<vsize> Line_division;
78 virtual SCM solve () = 0;
80 Page_breaking (Paper_book *pb, Break_predicate);
81 virtual ~Page_breaking ();
84 bool ragged_last () const;
86 Real page_height (int page_number, bool last) const;
91 vsize next_system (Break_position const &break_pos) const;
93 SCM make_pages (vector<vsize> lines_per_page, SCM lines);
95 vsize min_system_count (vsize start, vsize end);
96 vsize max_system_count (vsize start, vsize end);
99 void break_into_pieces (vsize start, vsize end, Line_division const &div);
102 void set_current_breakpoints (vsize start,
105 Line_division lower_bound = Line_division (),
106 Line_division upper_bound = Line_division ());
107 void set_to_ideal_line_configuration (vsize start, vsize end);
109 vsize current_configuration_count () const;
110 Line_division current_configuration (vsize configuration_index) const;
111 Spacing_result space_systems_on_n_pages (vsize configuration_index, vsize n, vsize first_page_num);
112 Spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n, vsize first_page_num);
113 Spacing_result space_systems_on_best_pages (vsize configuration_index, vsize first_page_num);
114 vsize min_page_count (vsize configuration_index, vsize first_page_num);
115 bool all_lines_stretched (vsize configuration_index);
116 Real blank_page_penalty () const;
118 SCM breakpoint_property (vsize breakpoint, char const *str);
119 vector<Break_position> breaks_;
122 vector<Break_position> chunks_;
123 vector<System_spec> all_;
124 vector<Constrained_breaking> line_breaking_;
128 vector<Line_division> current_configurations_;
129 vector<Break_position> current_chunks_;
130 vsize current_start_breakpoint_;
131 vsize current_end_breakpoint_;
133 void cache_line_details (vsize configuration_index);
134 void clear_line_details_cache ();
135 vsize cached_configuration_index_;
136 vector<Line_details> cached_line_details_;
137 vector<Line_details> uncompressed_line_details_;
139 vector<Break_position> chunk_list (vsize start, vsize end);
140 Line_division system_count_bounds (vector<Break_position> const &chunks, bool min);
141 void line_breaker_args (vsize i,
142 Break_position const &start,
143 Break_position const &end,
144 vsize *line_breaker_start,
145 vsize *line_breaker_end);
147 void line_divisions_rec (vsize system_count,
148 Line_division const &min,
149 Line_division const &max,
152 vector<Line_details> line_details (vsize start, vsize end, Line_division const &div);
153 Spacing_result space_systems_on_1_page (vector<Line_details> const &lines, Real page_height, bool ragged);
154 Spacing_result space_systems_on_2_pages (vsize configuration_index, vsize first_page_num);
155 Spacing_result finalize_spacing_result (vsize configuration_index, Spacing_result);
156 void create_system_list ();
157 void find_chunks_and_breaks (Break_predicate);
159 #endif /* PAGE_BREAKING_HH */