* python/lilylib.py (setup_temp): temporary directories are mode 700.
[lilypond.git] / lily / separating-group-spanner.cc
blob567371967a4e3d42eaffe5c89ac5bea46e5e82f7
1 /*
2 separating-group-spanner.cc -- implement Separating_group_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
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"
17 void
18 Separating_group_spanner::find_rods (Item * r, SCM next)
22 This is an inner loop: look for the first normal (unbroken) Left
23 grob. This looks like an inner loop (ie. quadratic total), but in
24 most cases, the interesting L will just be the first entry of
25 NEXT, making it linear in most of the cases.
27 if (Separation_item::width (r).empty_b ())
28 return;
30 for(; gh_pair_p (next); next = ly_cdr (next))
32 Item *l = dynamic_cast<Item*> (unsmob_grob (ly_car( next)));
33 Item *lb = l->find_prebroken_piece (RIGHT);
35 if (lb)
37 Interval li (Separation_item::width (lb));
38 Interval ri (Separation_item::conditional_width (r, lb));
39 if (!li.empty_b () && !ri.empty_b())
41 Rod rod;
43 rod.item_l_drul_[LEFT] = lb;
44 rod.item_l_drul_[RIGHT] = r;
46 rod.distance_ = li[RIGHT] - ri[LEFT];
47 rod.add_to_cols ();
51 Interval li (Separation_item::width (l));
52 Interval ri (Separation_item::conditional_width (r, l));
53 if (!li.empty_b () && !ri.empty_b())
55 Rod rod;
57 rod.item_l_drul_[LEFT] =l;
58 rod.item_l_drul_[RIGHT]=r;
60 rod.distance_ = li[RIGHT] - ri[LEFT];
62 rod.add_to_cols ();
63 break;
67 this grob doesn't cause a constraint. We look further until we
68 find one that does.
74 MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods_and_seqs,1);
75 SCM
76 Separating_group_spanner::set_spacing_rods_and_seqs (SCM smob)
78 set_spacing_rods (smob);
80 return SCM_UNSPECIFIED;
83 MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods,1);
84 SCM
85 Separating_group_spanner::set_spacing_rods (SCM smob)
87 Grob*me = unsmob_grob (smob);
89 for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s) && gh_pair_p (ly_cdr (s)); s = ly_cdr (s))
92 Order of elements is reversed!
94 SCM elt = ly_car (s);
95 Item *r = unsmob_item (elt);
97 if (!r)
98 continue;
100 Item *rb
101 = dynamic_cast<Item*> (r->find_prebroken_piece (LEFT));
103 find_rods (r, ly_cdr (s));
104 if (rb)
105 find_rods (rb, ly_cdr (s));
108 return SCM_UNSPECIFIED ;
111 void
112 Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i)
114 Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), i);
115 me->add_dependency (i);
122 ADD_INTERFACE (Separating_group_spanner,"separation-spanner-interface",
123 "Spanner that containing @code{separation-item-interface} grobs to calculate rods",
124 "");