2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "spaceable-grob.hh"
26 #include "pointer-group-interface.hh"
28 #include "paper-column.hh"
29 #include "international.hh"
32 Spaceable_grob::get_minimum_distances (Grob *me)
34 return me->get_object ("minimum-distances");
37 /*todo: merge code of spring & rod?
40 Spaceable_grob::add_rod (Grob *me, Grob *p, Real d)
42 // printf ("rod %lf\n", d);
47 programming_error ("infinite rod");
49 SCM mins = get_minimum_distances (me);
50 SCM newdist = scm_from_double (d);
51 for (SCM s = mins; scm_is_pair (s); s = scm_cdr (s))
53 SCM dist = scm_car (s);
54 if (scm_car (dist) == p->self_scm ())
56 scm_set_cdr_x (dist, scm_max (scm_cdr (dist),
62 if (Paper_column::get_rank (p) < Paper_column::get_rank (me))
63 programming_error ("Adding reverse rod");
65 mins = scm_cons (scm_cons (p->self_scm (), newdist), mins);
66 me->set_object ("minimum-distances", mins);
70 Spaceable_grob::add_spring (Grob *me, Grob *other, Spring sp)
72 SCM ideal = me->get_object ("ideal-distances");
74 ideal = scm_cons (scm_cons (sp.smobbed_copy (), other->self_scm ()), ideal);
75 me->set_object ("ideal-distances", ideal);
79 Spaceable_grob::get_spring (Grob *this_col, Grob *next_col)
83 for (SCM s = this_col->get_object ("ideal-distances");
84 !spring && scm_is_pair (s);
87 if (scm_is_pair (scm_car (s))
88 && Grob::unsmob (scm_cdar (s)) == next_col
89 && Spring::is_smob (scm_caar (s)))
90 spring = Spring::unsmob (scm_caar (s));
94 programming_error (to_string ("No spring between column %d and next one",
95 Paper_column::get_rank (this_col)));
97 return spring ? *spring : Spring ();
100 ADD_INTERFACE (Spaceable_grob,
101 "A layout object that takes part in the spacing problem.",
104 "allow-loose-spacing "