]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-layout-problem.hh
Run grand-replace (issue 3765)
[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--2014 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 #include "stencil.hh"
26
27 class Page_layout_problem
28 {
29 public:
30   Page_layout_problem (Paper_book *, SCM page, SCM systems);
31
32   SCM solution (bool ragged);
33   SCM fixed_force_solution (Real force);
34   void set_header_height (Real);
35   void set_footer_height (Real);
36   Real force () const;
37   static bool read_spacing_spec (SCM spec, Real *dest, SCM sym);
38   static bool is_spaceable (Grob *g);
39   static SCM get_details (Grob *g);
40   static vector<Grob *> get_footnote_grobs (SCM lines);
41   static vsize get_footnote_count (SCM lines);
42   static SCM get_footnotes_from_lines (SCM lines);
43   static void add_footnotes_to_lines (SCM lines, int counter, Paper_book *pb);
44   static Stencil get_footnote_separator_stencil (Output_def *paper);
45   static SCM get_spacing_spec (Grob *before, Grob *after, bool pure, int start, int end);
46   static Real get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end);
47   static Stencil add_footnotes_to_footer (SCM footnotes, Stencil foot, Paper_book *pb);
48
49 protected:
50   void append_system (System *, Spring const &, Real indent, Real padding);
51   void append_prob (Prob *, Spring const &, Real padding);
52
53   void solve_rod_spring_problem (bool ragged, Real fixed_force);
54   SCM find_system_offsets ();
55   void distribute_loose_lines (vector<Grob *> const &, vector<Real> const &, Real, Real);
56
57   static void build_system_skyline (vector<Grob *> const &, vector<Real> const &, Skyline *up, Skyline *down);
58   static vector<Grob *> filter_dead_elements (vector<Grob *> const &);
59
60   // This is a union (in spirit).
61   // Either staves must be empty or prob must be null.
62   typedef struct Element
63   {
64     Prob *prob;
65     vector<Grob *> staves;
66     vector<Real> min_offsets;
67     // Store the appropriate '*-*-spacing 'padding, and skyline-distance,
68     //  considering indentation, from the previous system.
69     Real min_distance;
70     Real padding;
71
72     Element (vector<Grob *> const &a, vector<Real> const &o, Real m, Real p)
73     {
74       staves = a;
75       min_offsets = o;
76       min_distance = m;
77       padding = p;
78       prob = 0;
79     }
80
81     Element (Prob *p, Real pad)
82     {
83       prob = p;
84       padding = pad;
85     }
86   } Element;
87
88   static Interval first_staff_extent (Element const &);
89   static Interval last_staff_extent (Element const &);
90   static Interval prob_extent (Prob *);
91   static SCM get_details (Element const &);
92   static SCM details_get_property (SCM details, const char *);
93   static void alter_spring_from_spacing_spec (SCM spec, Spring *spring);
94   static void mark_as_spaceable (Grob *);
95
96   vector<Spring> springs_;
97   vector<Element> elements_;
98   vector<Real> solution_;
99   Real force_;
100   Skyline bottom_skyline_;
101   Real bottom_loose_baseline_;
102   Real page_height_;
103   Real header_height_;
104   Real footer_height_;
105   Real header_padding_;
106   Real footer_padding_;
107   Real in_note_padding_;
108   Direction in_note_direction_;
109 };
110
111 #endif /* PAGE_LAYOUT_HH */