]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-layout-problem.hh
0502ce86783b35fd3fd2585d579c7a54474417ca
[lilypond.git] / lily / include / page-layout-problem.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2009--2010 Joe Neeman <joeneeman@gmail.com>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef PAGE_LAYOUT_HH
21 #define PAGE_LAYOUT_HH
22
23 #include "simple-spacer.hh"
24 #include "skyline.hh"
25
26 class Page_layout_problem
27 {
28 public:
29   Page_layout_problem (Paper_book*, SCM page, SCM systems);
30
31   SCM solution (bool ragged);
32   void set_header_height (Real);
33   void set_footer_height (Real);
34   static bool read_spacing_spec (SCM spec, Real* dest, SCM sym);
35   static bool is_spaceable (Grob *g);
36   static SCM get_details (Grob *g);
37   static SCM get_spacing_spec (Grob *before, Grob *after, bool pure, int start, int end);
38
39 protected:
40   void append_system (System*, Spring const&, Real padding);
41   void append_prob (Prob*, Spring const&, Real padding);
42
43   void solve_rod_spring_problem (bool ragged);
44   SCM find_system_offsets ();
45   void distribute_loose_lines (vector<Grob*> const&, vector<Real> const&, Real, Real);
46
47   static void build_system_skyline (vector<Grob*> const&, vector<Real> const&, Skyline* up, Skyline* down);
48   static vector<Grob*> filter_dead_elements (vector<Grob*> const&);
49
50   // This is a union (in spirit).
51   // Either staves must be empty or prob must be null.
52   typedef struct Element {
53     Prob *prob;
54     vector<Grob*> staves;
55     vector<Real> min_offsets;
56
57     Element (vector<Grob*> const& a, vector<Real> const& o)
58     {
59       staves = a;
60       min_offsets = o;
61       prob = 0;
62     }
63
64     Element (Prob *p)
65     {
66       prob = p;
67     }
68   } Element;
69
70   static Interval first_staff_extent (Element const&);
71   static Interval last_staff_extent (Element const&);
72   static Interval prob_extent (Prob*);
73   static SCM get_details (Element const&);
74   static SCM details_get_property (SCM details, const char*);
75   static void alter_spring_from_spacing_spec (SCM spec, Spring* spring);
76   static void mark_as_spaceable (Grob*);
77
78   vector<Spring> springs_;
79   vector<Element> elements_;
80   vector<Real> solution_;
81   Skyline bottom_skyline_;
82   Real page_height_;
83   Real header_height_;
84   Real footer_height_;
85   Real header_padding_;
86   Real footer_padding_;
87 };
88
89 #endif /* PAGE_LAYOUT_HH */