lilypond-0.1.37
[lilypond.git] / lily / script-column.cc
blob6f9359aef7c46fce45dd5b706746c304097dc62a
1 /*
2 script-column.cc -- implement Script_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "script-column.hh"
10 #include "debug.hh"
11 #include "script.hh"
12 #include "note-head.hh"
13 #include "stem.hh"
16 IMPLEMENT_IS_TYPE_B1(Script_column,Horizontal_vertical_group_item);
19 void
20 Script_column::add (Script*s_l)
22 script_l_arr_.push (s_l);
23 add_dependency (s_l);
24 add_element (s_l);
28 void
29 Script_column::do_print() const
31 #ifndef NPRINT
32 DOUT << "scripts: " << script_l_arr_.size() << '\n';
33 #endif
36 static int
37 idx (bool inside, int dir)
39 int j = (dir+1);
40 if (!inside)
41 j ++;
42 return j;
45 void
46 Script_column::do_pre_processing()
48 if (!script_l_arr_.size())
49 return;
51 /* up+inside, up+outside, down+inside, down+outside */
52 Array<Script*> placed_l_arr_a[4];
53 for (int i=0; i < script_l_arr_.size(); i++)
55 Script*s_l = script_l_arr_[i];
56 placed_l_arr_a[idx (s_l->inside_staff_b_ , s_l->dir_) ].push (s_l);
59 for (int j =0; j <4; j++)
61 placed_l_arr_a[j].sort (Script::compare);
65 for (int j =0; j < 4; j++)
67 if (placed_l_arr_a[j].size())
68 for (int i=0; i < support_l_arr_.size(); i++)
69 placed_l_arr_a[j][0]->add_support (support_l_arr_[i]);
72 Item * support_l=0;
73 int j = 0;
74 for (; j < 2; j++)
76 for (int i=0; i < placed_l_arr_a[j].size(); i++)
78 if (support_l)
79 placed_l_arr_a[j][i]->add_support (support_l);
80 support_l = placed_l_arr_a[j][i];
83 support_l = 0;
84 for (; j < 4; j++)
86 for (int i=0; i < placed_l_arr_a[j].size(); i++)
88 if (support_l)
89 placed_l_arr_a[j][i]->add_support (support_l);
90 support_l = placed_l_arr_a[j][i];
96 void
97 Script_column::add_support (Item*i_l)
99 support_l_arr_.push (i_l);
100 add_dependency (i_l);
101 add_element (i_l);
104 void
105 Script_column::do_substitute_dependency (Score_elem*o,Score_elem*n)
107 if (o->item())
109 script_l_arr_.substitute ((Script*)o->item(),(Script*) (n?n->item ():0));
110 support_l_arr_.substitute (o->item(), (n?n->item ():0));