lilypond-1.5.9
[lilypond.git] / lily / script-column.cc
blob68e21514a70c8d6982142ded5596204ccd0f6559
1 /*
2 script-column.cc -- implement Script_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9 #include "script-column.hh"
10 #include "side-position-interface.hh"
12 #include "group-interface.hh"
14 void
15 Script_column::add_staff_sided (Grob *me, Item *i)
17 SCM p = i->get_grob_property ("script-priority");
18 if (!gh_number_p (p))
19 return;
21 Pointer_group_interface::add_element (me, "scripts",i);
23 me->add_dependency (i);
26 static int
27 staff_side_compare (Grob * const &i1,
28 Grob * const &i2)
30 SCM p1 = i1->get_grob_property ("script-priority");
31 SCM p2 = i2->get_grob_property ("script-priority");
33 return gh_scm2int (p1) - gh_scm2int (p2);
36 MAKE_SCHEME_CALLBACK (Script_column,before_line_breaking,1);
38 SCM
39 Script_column::before_line_breaking (SCM smob)
41 Grob* me = unsmob_grob (smob);
42 Drul_array<Link_array<Grob> > arrs;
43 Link_array<Grob> staff_sided
44 = Pointer_group_interface__extract_elements (me, (Grob*)0, "scripts");
47 for (int i=0; i < staff_sided.size (); i++)
49 arrs[Side_position_interface::get_direction (staff_sided[i])]
50 .push (staff_sided[i]);
53 Direction d = DOWN;
54 do {
55 Link_array<Grob> &arr (arrs[d]);
57 arr.sort (staff_side_compare);
59 Grob * last = 0;
60 for (int i=0; i < arr.size (); i++)
63 if (last)
64 Side_position_interface::add_support (arr[i],last);
66 arr[i]->remove_grob_property ("script-priority");
67 last = arr[i];
70 } while (flip (&d) != DOWN);
72 return SCM_UNSPECIFIED;