]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/simple-spacer.hh
release: 1.5.5
[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--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef SIMPLE_SPACER_HH
11 #define SIMPLE_SPACER_HH
12
13 #include "parray.hh"
14 #include "lily-proto.hh"
15
16
17 struct Spring_description
18 {
19   Real ideal_f_;
20   Real hooke_f_;
21   bool active_b_;
22
23   Real block_force_f_;
24
25   Real length (Real force) const;
26   Spring_description ();
27
28   bool sane_b () const;
29 };
30
31 /**
32    A simple spacing constraint solver. The approach:
33
34    Stretch the line uniformly until none of the constraints (rods)
35    block.  It then is very wide.
36
37
38       Compress until the next constraint blocks,
39
40       Mark the springs over the constrained part to be non-active.
41       
42    Repeat with the smaller set of non-active constraints, until all
43    constraints blocked, or until the line is as short as desired.
44
45    This is much simpler, and much much faster than full scale
46    Constrained QP. On the other hand, a situation like this will not
47    be typeset as dense as possible, because
48
49    c4                   c4           c4                  c4
50    veryveryverylongsyllable2         veryveryverylongsyllable2
51    " "4                 veryveryverylongsyllable2        syllable4
52
53
54    can be further compressed to
55
56
57    c4    c4                        c4   c4
58    veryveryverylongsyllable2       veryveryverylongsyllable2
59    " "4  veryveryverylongsyllable2      syllable4
60
61
62    Perhaps this is not a bad thing, because the 1st looks better anyway.  */
63 struct Simple_spacer
64 {
65   Array<Spring_description> springs_;
66
67   Real force_f_;
68   Real indent_f_;
69   Real line_len_f_;
70   Real default_space_f_;
71
72
73   Simple_spacer ();
74   
75   void solve (Column_x_positions *) const;
76   void add_columns (Link_array<Grob>);
77   void my_solve_linelen ();
78   void my_solve_natural_len ();
79   Real active_springs_stiffness () const;
80   Real range_stiffness (int, int) const;
81   void add_rod (int l, int r, Real dist);
82   Real range_ideal_len (int l, int r)const;
83   Real active_blocking_force ()const;
84   Real configuration_length ()const;
85   void set_active_states ();
86   bool active_b () const;
87 };
88
89 #endif /* SIMPLE_SPACER_HH */
90