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