]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-spacing.hh
Use between-system-padding as a default for
[lilypond.git] / lily / include / page-spacing.hh
1 /*
2   page-spacing.hh -- routines for spacing systems
3   vertically across pages
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2006 Joe Neeman <joeneeman@gmail.com>
8 */
9
10 #ifndef PAGE_SPACING_HH
11 #define PAGE_SPACING_HH
12
13 #include "constrained-breaking.hh"
14
15 struct Spacing_result {
16   vector<vsize> systems_per_page_;
17   vector<Real> force_;
18   Real penalty_;
19   Real demerits_;
20
21   Spacing_result ()
22   {
23     penalty_ = 0;
24     demerits_ = infinity_f;
25   }
26 };
27
28 /* for page_count > 2, we use a dynamic algorithm similar to
29    constrained-breaking -- we have a class that stores the intermediate
30    calculations so they can be reused for querying different page counts.
31 */
32
33 class Page_spacer
34 {
35 public:
36   Page_spacer (vector<Line_details> const &lines, Real page_height, bool ragged, bool ragged_last);
37   Spacing_result solve (vsize page_count);
38
39 private:
40   struct Page_spacing_node
41   {
42     Page_spacing_node ()
43     {
44       demerits_ = infinity_f;
45       force_ = infinity_f;
46       penalty_ = infinity_f;
47       prev_ = VPOS;
48     }
49
50     Real demerits_;
51     Real force_;
52     Real penalty_;
53     vsize prev_;
54   };
55
56   Real page_height_;
57   vector<Line_details> lines_;
58   Matrix<Page_spacing_node> state_;
59   vsize max_page_count_;
60
61   bool ragged_;
62   bool ragged_last_;
63
64   void resize (vsize page_count);
65   bool calc_subproblem (vsize page, vsize lines);
66 };
67
68 vsize
69 min_page_count (vector<Line_details> const &lines,
70                 Real page_height, bool ragged, bool ragged_last);
71
72 Spacing_result
73 space_systems_on_n_pages (vector<Line_details> const&,
74                           vsize n,
75                           Real page_height,
76                           bool ragged,
77                           bool ragged_last);
78
79 Spacing_result
80 space_systems_on_n_or_one_more_pages (vector<Line_details> const&,
81                                       vsize n,
82                                       Real page_height,
83                                       Real odd_pages_penalty,
84                                       bool ragged,
85                                       bool ragged_last);
86 Spacing_result
87 space_systems_on_best_pages (vector<Line_details> const&,
88                              Real page_height,
89                              Real odd_pages_penalty,
90                              bool ragged,
91                              bool ragged_last);
92
93 #endif /* PAGE_SPACING_HH */