lilypond-0.1.54
[lilypond.git] / lily / script-column.cc
blob47a508e2c28c90beb348bbfe2d9480667ba52f0f
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"
14 #include "general-script-def.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->specs_l_->inside_b(),
57 s_l->dir_) ].push (s_l);
60 for (int j =0; j <4; j++)
62 placed_l_arr_a[j].sort (Script::compare);
66 for (int j =0; j < 4; j++)
68 if (placed_l_arr_a[j].size())
69 for (int i=0; i < support_l_arr_.size(); i++)
70 placed_l_arr_a[j][0]->add_support (support_l_arr_[i]);
73 Item * support_l=0;
74 int j = 0;
75 for (; j < 2; j++)
77 for (int i=0; i < placed_l_arr_a[j].size(); i++)
79 if (support_l)
80 placed_l_arr_a[j][i]->add_support (support_l);
81 support_l = placed_l_arr_a[j][i];
84 support_l = 0;
85 for (; j < 4; j++)
87 for (int i=0; i < placed_l_arr_a[j].size(); i++)
89 if (support_l)
90 placed_l_arr_a[j][i]->add_support (support_l);
91 support_l = placed_l_arr_a[j][i];
97 void
98 Script_column::add_support (Item*i_l)
100 support_l_arr_.push (i_l);
101 add_dependency (i_l);
102 add_element (i_l);
105 void
106 Script_column::do_substitute_dependency (Score_elem*o,Score_elem*n)
108 if (o->item())
110 script_l_arr_.substitute ((Script*)o->item(),(Script*) (n?n->item ():0));
111 support_l_arr_.substitute (o->item(), (n?n->item ():0));