]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-layout-problem.hh
Rewrite the vertical layout of staves/systems.
[lilypond.git] / lily / include / page-layout-problem.hh
1 /*
2   page-layout-problem.hh -- space systems nicely on a page. If systems can
3   be stretched, do that too.
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2009 Joe Neeman <joeneeman@gmail.com>
8 */
9
10 #ifndef PAGE_LAYOUT_HH
11 #define PAGE_LAYOUT_HH
12
13 #include "simple-spacer.hh"
14 #include "skyline.hh"
15
16 class Page_layout_problem
17 {
18 public:
19   Page_layout_problem (Paper_book*, SCM page, SCM systems);
20
21   SCM solution (bool ragged);
22   void set_header_height (Real);
23   void set_footer_height (Real);
24   static bool read_spacing_spec (SCM spec, Real* dest, SCM sym);
25   static bool is_spaceable (Grob *g);
26   static SCM get_details (Grob *g);
27
28 protected:
29   void append_system (System*, Spring const&, Real padding);
30   void append_prob (Prob*, Spring const&, Real padding);
31
32   void solve_rod_spring_problem (bool ragged);
33   SCM find_system_offsets ();
34   void distribute_loose_lines (Grob*, Real, vector<Grob*> const&, vector<Real> const&, Grob*, Real);
35   void add_loose_lines_as_spaceable_lines (vector<Grob*> const&,
36                                            vector<Real> const&,
37                                            vsize start, vsize end);
38
39   static Grob* find_vertical_alignment (System*);
40   static void build_system_skyline (vector<Grob*> const&, vector<Real> const&, Skyline* up, Skyline* down);
41
42   // This is a union (in spirit).
43   // Either staves must be empty or prob must be null.
44   typedef struct Element {
45     Prob *prob;
46     vector<Grob*> staves;
47     vector<Real> min_offsets;
48
49     Element (vector<Grob*> const& a, vector<Real> const& o)
50     {
51       staves = a;
52       min_offsets = o;
53       prob = 0;
54     }
55
56     Element (Prob *p)
57     {
58       prob = p;
59     }
60   } Element;
61
62   static Interval first_staff_extent (Element const&);
63   static Interval last_staff_extent (Element const&);
64   static Interval prob_extent (Prob*);
65   static SCM get_details (Element const&);
66   static SCM details_get_property (SCM details, const char*);
67   static void alter_spring_from_spacing_spec (SCM spec, Spring* spring);
68   static void mark_as_spaceable (Grob*);
69
70   vector<Spring> springs_;
71   vector<Element> elements_;
72   vector<Real> solution_;
73   Skyline bottom_skyline_;
74   Real page_height_;
75   Real header_height_;
76   Real footer_height_;
77 };
78
79 #endif /* PAGE_LAYOUT_HH */