2 separating-group-spanner.cc -- implement Separating_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "separating-group-spanner.hh"
11 #include "separation-item.hh"
12 #include "paper-column.hh"
13 #include "paper-def.hh"
14 #include "dimensions.hh"
15 #include "group-interface.hh"
18 do_rod (Item
*l
, Item
*r
)
22 Interval
li (Separation_item::my_width (l
));
23 Interval
ri (Separation_item::my_width (r
));
25 rod
.item_l_drul_
[LEFT
] =l
;
26 rod
.item_l_drul_
[RIGHT
]=r
;
28 if (li
.empty_b () || ri
.empty_b ())
31 rod
.distance_f_
= li
[RIGHT
] - ri
[LEFT
];
37 MAKE_SCHEME_CALLBACK(Separating_group_spanner
,set_spacing_rods
);
39 Separating_group_spanner::set_spacing_rods (SCM smob
)
41 Score_element
*me
= unsmob_element (smob
);
43 for (SCM s
= me
->get_elt_property ("elements"); gh_pair_p (s
) && gh_pair_p (gh_cdr (s
)); s
= gh_cdr (s
))
46 Order of elements is reversed!
48 SCM elt
= gh_cadr (s
);
49 SCM next_elt
= gh_car (s
);
51 Item
*l
= dynamic_cast<Item
*> (unsmob_element (elt
));
52 Item
*r
= dynamic_cast<Item
*> (unsmob_element ( next_elt
));
58 = dynamic_cast<Item
*>(l
->find_prebroken_piece (RIGHT
));
61 = dynamic_cast<Item
*>(r
->find_prebroken_piece (LEFT
));
82 We've done our job, so we get lost.
84 for (SCM s
= me
->get_elt_property ("elements"); gh_pair_p (s
); s
= gh_cdr (s
))
86 Item
* it
=dynamic_cast<Item
*>(unsmob_element (gh_car (s
)));
87 if (it
&& it
->broken_b ())
89 it
->find_prebroken_piece (LEFT
) ->suicide ();
90 it
->find_prebroken_piece (RIGHT
)->suicide ();
95 return SCM_UNSPECIFIED
;
99 Separating_group_spanner::add_spacing_unit (Score_element
* me
,Item
*i
)
101 Pointer_group_interface (me
, "elements").add_element (i
);
102 me
->add_dependency (i
);
107 Separating_group_spanner::set_interface (Score_element
*me
)
109 me
->set_elt_property ("elements", SCM_EOL
);