]> git.donarmstrong.com Git - lilypond.git/blob - lily/script-column.cc
release: 0.0.58
[lilypond.git] / lily / script-column.cc
1 /*
2   script-column.cc -- implement Script_column
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "script-column.hh"
10 #include "debug.hh"
11 #include "script.hh"
12 #include "notehead.hh"
13 #include "stem.hh"
14
15 IMPLEMENT_STATIC_NAME(Script_column);
16
17
18 void
19 Script_column::add(Script*s_l)
20 {
21     script_l_arr_.push(s_l);
22     add_dependency(s_l);
23 }
24
25 void
26 Script_column::translate(Offset o)
27 {
28     for (int i=0; i < script_l_arr_.size(); i++) 
29         script_l_arr_[i]->translate(o);
30     for (int i=0; i < support_l_arr_.size(); i++)
31         support_l_arr_[i]->translate(o);
32 }
33
34
35 void
36 Script_column::do_print()const
37 {
38     mtor << "scripts: " << script_l_arr_.size() << '\n'; 
39 }
40
41 Interval
42 Script_column::do_height()const return r
43 {
44     for (int i=0; i < script_l_arr_.size(); i++) 
45         r.unite(script_l_arr_[i]->height());
46 }
47
48 Interval
49 Script_column::do_width()const 
50 {
51     Interval r;
52     for (int i=0; i < script_l_arr_.size(); i++) 
53         r.unite(script_l_arr_[i]->width());
54     return r;
55 }
56
57 void
58 Script_column::do_pre_processing()
59 {
60     if (!script_l_arr_.size()) 
61         return;
62     /* up+outside, up+inside, down+outside, down+inside */
63     Array<Script*> placed_l_arr_a[4];
64     for (int i=0; i < script_l_arr_.size(); i++) {
65         Script*s_l = script_l_arr_[i];
66         int j = (s_l->dir_i_ >0) ? 0 : 2;
67         if (!s_l->inside_staff_b_) 
68             j ++;
69         
70         placed_l_arr_a[j].push(s_l);
71     }
72     
73     for (int j =0; j <4; j++) {
74         placed_l_arr_a[j].sort( Script::compare);
75     }
76
77
78     for (int j =0; j < 4; j++) {
79         if (placed_l_arr_a[j].size())
80             for (int i=0; i  < support_l_arr_.size(); i++)
81                 placed_l_arr_a[j][0]->add_support( support_l_arr_[i]);
82     }
83     Item * support_l=0;
84     int j = 0;
85     for (; j < 2; j++ ) {
86         for (int i=1; i < placed_l_arr_a[j].size(); i++) {
87             if (support_l)
88                 placed_l_arr_a[j][i]->add_support(support_l);
89             support_l = placed_l_arr_a[j][i];
90         }
91     }
92     support_l = 0;
93     for (; j < 4; j++ ) {
94         for (int i=1; i < placed_l_arr_a[j].size(); i++) {
95             if (support_l)
96                 placed_l_arr_a[j][i]->add_support(support_l);
97             support_l = placed_l_arr_a[j][i];
98         }
99     }
100 }
101
102
103 void
104 Script_column::add_support(Item*i_l)
105 {
106     support_l_arr_.push(i_l);
107     add_dependency(i_l);
108 }