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)
48 SCM mins = me->get_grob_property ("ideal-distances");
49 for (SCM s = mins; gh_pair_p (s); s = ly_cdr (s))
51 Spring_smob * sp = unsmob_spring(ly_car (s));
54 programming_error ("already have that spring");
61 spring.strength_f_ = strength;
62 spring.distance_f_ = d;
63 spring.expand_only_b_ = expand_only;
66 Group_interface::add_thing (me, ly_symbol2scm ("ideal-distances"), spring.smobbed_copy ());
71 Spaceable_grob::remove_interface (Grob*me)
73 me->remove_grob_property ("minimum-distances");
74 me->remove_grob_property ("ideal-distances");
79 Spaceable_grob::set_interface (Grob*me)
81 me->set_interface (ly_symbol2scm ("spaceable-grob-interface"));