]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-breaking.hh
* scm/page.scm (make-page): make it friendlier to call (esp. from C++)
[lilypond.git] / lily / include / page-breaking.hh
1 /*
2   page-breaking.hh -- declare a superclass and utility
3   functions for several different page-breaking algorithms
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2006 Joe Neeman <joeneeman@gmail.com>
8 */
9
10 #ifndef PAGE_BREAKING_HH
11 #define PAGE_BREAKING_HH
12
13 #include "constrained-breaking.hh"
14 #include "lily-guile.hh"
15
16 /* Either a paper-score, markup or header.
17  */
18 struct System_spec
19 {
20   System_spec (Paper_score*, int);
21   System_spec (Prob*);
22   System_spec ();
23
24   Paper_score *pscore_;
25   Prob *prob_;
26
27   vsize score_break_count_; /* for scores, this is the number of start-points our line-
28                                breaker has */
29 };
30
31 struct Break_position
32 {
33   vsize sys_; /* the index in our all_ list */
34   vsize score_break_; /* if sys_ is a score, then we start at the score_brk_'th
35                          possible page-break in the score */
36
37   Break_position (vsize s=VPOS, vsize brk=VPOS)
38   {
39     sys_ = s;
40     score_break_ = brk;
41   }
42 };
43
44 class Page_breaking
45 {
46 public:
47   virtual SCM solve () = 0;
48
49   Page_breaking (Paper_book *pb, bool allow_intra_score_breaks);
50   virtual ~Page_breaking ();
51
52 protected:
53   std::vector<Break_position> breaks_;
54   std::vector<System_spec> all_;
55   std::vector<Constrained_breaking> line_breaking_;
56
57   Paper_book *book_;
58
59   Real page_height (int page_number, bool last);
60   vsize next_system (vsize starting_break_index) const;
61
62   void create_system_list (bool allow_intra_score_breaks);
63   std::vector<vsize> find_page_break_indices (Paper_score *pscore);
64
65   SCM make_pages (vector<vsize> lines_per_page, SCM lines);
66
67   void calc_system_count_bounds (vsize start, vsize end,
68                                  vector<vsize> *min,
69                                  vector<vsize> *max);
70
71   void divide_systems (vsize system_count, vector<vsize> const &min,
72                                            vector<vsize> const &max,
73                                            vector<vector<vsize> > *result,
74                                            vector<vsize> *cur);
75
76   void line_breaker_args (vsize i, vsize *break_st, vsize *break_end);
77   vsize get_min_systems (vsize sys, vsize break_start, vsize break_end);
78   vsize get_max_systems (vsize sys, vsize break_start, vsize break_end);
79   vector<Column_x_positions> get_line_breaks (vsize sys, vsize sys_count, vsize st, vsize end);
80   vector<Line_details> get_line_details (vsize start_break, vsize end_break, vector<vsize> const &div);
81 };
82 #endif /* PAGE_BREAKING_HH */