]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/simple-spacer.hh
90784e4c743cff3b5692f95a36101698f977af36
[lilypond.git] / lily / include / simple-spacer.hh
1 /*
2   simple-spacer.hh -- declare Simple_spacer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef SIMPLE_SPACER_HH
10 #define SIMPLE_SPACER_HH
11
12 #include "std-vector.hh"
13 #include "lily-proto.hh"
14 #include "spring.hh"
15 #include "smobs.hh"
16
17 class Simple_spacer
18 {
19 public:
20   Simple_spacer ();
21
22   void solve (Real line_len, bool ragged);
23   void add_rod (int l, int r, Real dist);
24   void add_spring (Spring const&);
25   Real range_ideal_len (int l, int r) const;
26   Real range_stiffness (int l, int r, bool stretch) const;
27   Real configuration_length (Real) const;
28   vector<Real> spring_positions () const;
29
30   Real force () const;
31   Real force_penalty (bool ragged) const;
32   bool fits () const;
33
34   DECLARE_SIMPLE_SMOBS (Simple_spacer);
35
36 private:
37   Real expand_line ();
38   Real compress_line ();
39   Real rod_force (int l, int r, Real dist);
40
41   vector<Spring> springs_;
42   Real line_len_;
43   Real force_;
44   bool ragged_;
45   bool fits_;
46 };
47
48 /* returns a vector of dimensions breaks.size () * breaks.size () */
49 vector<Real> get_line_forces (vector<Grob*> const &columns,
50                               Real line_len,
51                               Real indent,
52                               bool ragged);
53
54 Column_x_positions get_line_configuration (vector<Grob*> const &columns,
55                                            Real line_len,
56                                            Real indent,
57                                            bool ragged);
58
59 #endif /* SIMPLE_SPACER_HH */
60