2 separating-group-spanner.cc -- implement Separating_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "separating-group-spanner.hh"
11 #include "separation-item.hh"
12 #include "paper-column.hh"
13 #include "output-def.hh"
14 #include "dimensions.hh"
15 #include "pointer-group-interface.hh"
18 Separating_group_spanner::find_rods (Item *r,
19 vector<Grob*> const &separators,
25 This is an inner loop: look for the first normal (unbroken) Left
26 grob. This looks like an inner loop (ie. quadratic total), but in
27 most cases, the interesting L will just be the first entry of
28 NEXT, making it linear in most of the cases.
30 for (; idx != VPOS; idx--)
32 Item *l = dynamic_cast<Item *> (separators[idx]);
33 Item *lb = l->find_prebroken_piece (RIGHT);
37 Separation_item::set_distance (Drul_array<Item*> (lb, r), padding);
40 if (Separation_item::set_distance (Drul_array<Item *> (l, r), padding))
44 this grob doesn't cause a constraint. We look further until we
50 MAKE_SCHEME_CALLBACK (Separating_group_spanner, set_spacing_rods, 1);
52 Separating_group_spanner::set_spacing_rods (SCM smob)
54 Grob *me = unsmob_grob (smob);
57 Ugh: padding is added doubly, also for SeparationItem
59 Real padding = robust_scm2double (me->get_property ("padding"), 0.1);
61 extract_grob_set (me, "elements", elts);
62 for (vsize i = elts.size (); i-- > 1;)
64 Item *r = dynamic_cast<Item *> (elts[i]);
68 if (Separation_item::width (r).is_empty ())
72 = dynamic_cast<Item *> (r->find_prebroken_piece (LEFT));
74 find_rods (r, elts, i - 1, padding);
76 find_rods (rb, elts, i - 1, padding);
79 return SCM_UNSPECIFIED;
83 Separating_group_spanner::add_spacing_unit (Grob *me, Item *i)
85 Pointer_group_interface::add_unordered_grob (me, ly_symbol2scm ("elements"), i);
88 ADD_INTERFACE (Separating_group_spanner,
89 "A spanner that calculates spacing constraints (\"rods\") "
90 "using the @code{separation-item-interface} grobs in @code{elements}.",