]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/simple-spacer.hh
Run grand-replace for 2012
[lilypond.git] / lily / include / simple-spacer.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2012 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   bool minimal_;
34
35   void solve (Real line_len, bool ragged);
36   void add_rod (int l, int r, Real dist);
37   void add_spring (Spring const &);
38   Real range_ideal_len (int l, int r) const;
39   Real range_stiffness (int l, int r, bool stretch) const;
40   Real configuration_length (Real) const;
41   vector<Real> spring_positions () const;
42
43   void set_force (Real force);
44   Real force () const;
45   Real line_len () const;
46   Real force_penalty (bool ragged) const;
47   bool fits () const;
48
49   DECLARE_SIMPLE_SMOBS (Simple_spacer);
50
51 private:
52
53   Real expand_line ();
54   Real compress_line ();
55   Real rod_force (int l, int r, Real dist);
56
57   vector<Spring> springs_;
58   Real line_len_;
59   Real force_;
60   bool ragged_;
61   bool fits_;
62 };
63
64 Column_x_positions get_line_configuration (vector<Grob *> const &columns,
65                                            Real line_len,
66                                            Real indent,
67                                            bool ragged);
68
69 #endif /* SIMPLE_SPACER_HH */
70