2 spaceable-grob.cc -- implement Spaceable_grob
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "spaceable-grob.hh"
14 #include "group-interface.hh"
17 Spaceable_grob::get_minimum_distances (Grob*me)
19 return me->get_grob_property ("minimum-distances");
22 /*todo: merge code of spring & rod?
25 Spaceable_grob::add_rod (Grob *me , Grob * p, Real d)
27 SCM mins = get_minimum_distances (me);
28 SCM newdist = gh_double2scm (d);
29 for (SCM s = mins; gh_pair_p (s); s = ly_cdr (s))
31 SCM dist = ly_car (s);
32 if (ly_car (dist) == p->self_scm ())
34 gh_set_cdr_x (dist, scm_max (ly_cdr (dist),
40 mins = gh_cons (gh_cons (p->self_scm (), newdist), mins);
41 me->set_grob_property ("minimum-distances", mins);
45 Spaceable_grob::add_spring (Grob*me, Grob * p, Real d, Real strength, bool expand_only)
47 if (d < 0.0 || strength <= 0.0)
49 programming_error ("Adding reverse spring! Setting to unit spring");
55 SCM mins = me->get_grob_property ("ideal-distances");
56 for (SCM s = mins; gh_pair_p (s); s = ly_cdr (s))
58 Spring_smob * sp = unsmob_spring(ly_car (s));
61 programming_error ("already have that spring");
68 spring.strength_f_ = strength;
69 spring.distance_f_ = d;
70 spring.expand_only_b_ = expand_only;
73 Group_interface::add_thing (me, ly_symbol2scm ("ideal-distances"), spring.smobbed_copy ());
78 Spaceable_grob::remove_interface (Grob*me)
80 me->remove_grob_property ("minimum-distances");
81 me->remove_grob_property ("ideal-distances");
86 ADD_INTERFACE (Spaceable_grob,"spaceable-grob-interface",
87 "A grob (a Paper_column) that takes part in the
89 "measure-length penalty minimum-distances ideal-distances
90 left-neighbors right-neighbors");