2 separating-group-spanner.cc -- implement Separating_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 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 Separating_group_spanner::find_rods (Item
* r
, SCM next
)
20 Interval
ri (Separation_item::my_width (r
));
25 This is an inner loop, however, in most cases, the interesting L
26 will just be the first entry of NEXT, making it linear in most of
28 for(; gh_pair_p (next
); next
= gh_cdr (next
))
30 Item
*l
= dynamic_cast<Item
*> (unsmob_grob (gh_car( next
)));
31 Item
*lb
= l
->find_prebroken_piece (RIGHT
);
35 Interval
li (Separation_item::my_width (lb
));
41 rod
.item_l_drul_
[LEFT
] = lb
;
42 rod
.item_l_drul_
[RIGHT
] = r
;
44 rod
.distance_f_
= li
[RIGHT
] - ri
[LEFT
];
51 Interval
li (Separation_item::my_width (l
));
56 rod
.item_l_drul_
[LEFT
] =l
;
57 rod
.item_l_drul_
[RIGHT
]=r
;
59 rod
.distance_f_
= li
[RIGHT
] - ri
[LEFT
];
68 this grob doesn't cause a constraint. We look further until we
69 find one that does. */
74 MAKE_SCHEME_CALLBACK (Separating_group_spanner
,set_spacing_rods
,1);
76 Separating_group_spanner::set_spacing_rods (SCM smob
)
78 Grob
*me
= unsmob_grob (smob
);
80 for (SCM s
= me
->get_grob_property ("elements"); gh_pair_p (s
) && gh_pair_p (gh_cdr (s
)); s
= gh_cdr (s
))
83 Order of elements is reversed!
86 Item
*r
= dynamic_cast<Item
*> (unsmob_grob (elt
));
92 = dynamic_cast<Item
*> (r
->find_prebroken_piece (LEFT
));
94 find_rods (r
, gh_cdr (s
));
96 find_rods (rb
, gh_cdr (s
));
100 We've done our job, so we get lost.
102 for (SCM s
= me
->get_grob_property ("elements"); gh_pair_p (s
); s
= gh_cdr (s
))
104 Item
* it
=dynamic_cast<Item
*> (unsmob_grob (gh_car (s
)));
105 if (it
&& it
->broken_b ())
107 it
->find_prebroken_piece (LEFT
) ->suicide ();
108 it
->find_prebroken_piece (RIGHT
)->suicide ();
113 return SCM_UNSPECIFIED
;
117 Separating_group_spanner::add_spacing_unit (Grob
* me
,Item
*i
)
119 Pointer_group_interface::add_element (me
, "elements",i
);
120 me
->add_dependency (i
);
125 Separating_group_spanner::set_interface (Grob
*)
130 Separating_group_spanner::has_interface (Grob
*)