]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/simple-spacer.hh
Run grand-replace (issue 3765)
[lilypond.git] / lily / include / simple-spacer.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
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 SIMPLE_SPACER_HH
21 #define SIMPLE_SPACER_HH
22
23 #include "std-vector.hh"
24 #include "lily-proto.hh"
25 #include "spring.hh"
26 #include "smobs.hh"
27
28 class Simple_spacer
29 {
30 public:
31   Simple_spacer ();
32
33   void solve (Real line_len, bool ragged);
34   void add_rod (int l, int r, Real dist);
35   void add_spring (Spring const &);
36   Real range_ideal_len (int l, int r) const;
37   Real range_stiffness (int l, int r, bool stretch) const;
38   Real configuration_length (Real) const;
39   vector<Real> spring_positions () const;
40
41   void set_force (Real force);
42   Real force () const;
43   Real force_penalty (bool ragged) const;
44   bool fits () const;
45
46   DECLARE_SIMPLE_SMOBS (Simple_spacer);
47
48 private:
49   Real expand_line ();
50   Real compress_line ();
51   Real rod_force (int l, int r, Real dist);
52
53   vector<Spring> springs_;
54   Real line_len_;
55   Real force_;
56   bool ragged_;
57   bool fits_;
58 };
59
60 /* returns a vector of dimensions breaks.size () * breaks.size () */
61 vector<Real> get_line_forces (vector<Grob *> const &columns,
62                               Real line_len,
63                               Real indent,
64                               bool ragged);
65
66 Column_x_positions get_line_configuration (vector<Grob *> const &columns,
67                                            Real line_len,
68                                            Real indent,
69                                            bool ragged);
70
71 #endif /* SIMPLE_SPACER_HH */
72