]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-layout-problem.hh
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[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   static SCM get_spacing_spec (Grob *before, Grob *after);
28
29 protected:
30   void append_system (System*, Spring const&, Real padding);
31   void append_prob (Prob*, Spring const&, Real padding);
32
33   void solve_rod_spring_problem (bool ragged);
34   SCM find_system_offsets ();
35   void distribute_loose_lines (vector<Grob*> const&, vector<Real> const&, Real, Real);
36   void add_loose_lines_as_spaceable_lines (vector<Grob*> const&,
37                                            vector<Real> const&,
38                                            vsize start, vsize end);
39
40   static Grob* find_vertical_alignment (System*);
41   static void build_system_skyline (vector<Grob*> const&, vector<Real> const&, Skyline* up, Skyline* down);
42   static vector<Grob*> filter_dead_elements (vector<Grob*> const&);
43
44   // This is a union (in spirit).
45   // Either staves must be empty or prob must be null.
46   typedef struct Element {
47     Prob *prob;
48     vector<Grob*> staves;
49     vector<Real> min_offsets;
50
51     Element (vector<Grob*> const& a, vector<Real> const& o)
52     {
53       staves = a;
54       min_offsets = o;
55       prob = 0;
56     }
57
58     Element (Prob *p)
59     {
60       prob = p;
61     }
62   } Element;
63
64   static Interval first_staff_extent (Element const&);
65   static Interval last_staff_extent (Element const&);
66   static Interval prob_extent (Prob*);
67   static SCM get_details (Element const&);
68   static SCM details_get_property (SCM details, const char*);
69   static void alter_spring_from_spacing_spec (SCM spec, Spring* spring);
70   static void mark_as_spaceable (Grob*);
71
72   vector<Spring> springs_;
73   vector<Element> elements_;
74   vector<Real> solution_;
75   Skyline bottom_skyline_;
76   Real page_height_;
77   Real header_height_;
78   Real footer_height_;
79 };
80
81 #endif /* PAGE_LAYOUT_HH */