]> git.donarmstrong.com Git - lilypond.git/blob - src/complexcolumn.cc
22e695016a3e62ecd035665292e809ef18f30b68
[lilypond.git] / src / complexcolumn.cc
1 /*
2   complexcolumn.cc -- implement Complex_column
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "voice.hh"
9 #include "debug.hh"
10 #include "complexcolumn.hh"
11 #include "pscore.hh"
12 #include "request.hh"
13 #include "pscore.hh"
14 #include "sccol.hh"
15 #include "complexstaff.hh"
16 #include "misc.hh"
17
18 void
19 Complex_column::typeset_musical_item(Item *i)
20 {
21     assert(i);
22     Score_column * sccol_l = musical_column_l_;
23     staff_l_->pscore_l_->typeset_item(i, sccol_l->pcol_l_,
24                                       staff_l_->pstaff_l_);
25 }
26
27 Complex_column::Complex_column(Complex_staff *staff_l)
28 {
29     staff_l_ = staff_l;
30 }
31
32 void
33 Complex_column::setup_one_request(Request * j)
34 {
35     if (j->nonmus()) // ugh
36         first_l_arr_.push(j);
37     else if (j->musical())
38         second_l_arr_.push(j);
39 }
40
41 /**
42   align items in #item_l_arr#, return the width.
43  */
44 Interval
45 align_items(Array<Item*> item_l_arr)
46 {
47     Interval wid(0,0);
48     for  (int i =0; i < item_l_arr.size(); i++) {
49         Interval item_width= item_l_arr[i]->width();
50         item_l_arr[i]->translate(Offset( wid.right - item_width.left ,0));
51         wid.unite(item_width);
52     }
53     return wid;
54 }
55
56 void 
57 translate_items(Real x,  Array<Item*> item_l_arr)
58 {
59     for  (int i =0; i < item_l_arr.size(); i++) 
60         item_l_arr[i]->translate(Offset(x, 0));
61 }
62 /*
63   UGR
64   This still sux
65   */
66 void
67 Complex_column::typeset_breakable_items(Array<Item *> &pre_p_arr,
68                                         Array<Item *> &nobreak_p_arr,
69                                         Array<Item *> &post_p_arr)
70 {
71     PCol * c= command_column_l_->pcol_l_;
72     PScore *ps_l=staff_l_->pscore_l_;
73     if (!c->breakable_b()) {      
74         for  (int i =0; i < pre_p_arr.size(); i++)
75             delete pre_p_arr[i];
76         pre_p_arr.set_size(0);
77         for  (int i =0; i < post_p_arr.size(); i++)
78             delete post_p_arr[i];
79         post_p_arr.set_size(0);
80     }
81
82       
83     for  (int i =0; i < pre_p_arr.size(); i++) {
84         ps_l->typeset_item(pre_p_arr[i], c, staff_l_->pstaff_l_,0);
85     }
86     for  (int i =0; i < nobreak_p_arr.size(); i++) {
87         ps_l->typeset_item(nobreak_p_arr[i], c, staff_l_->pstaff_l_,1);
88     }
89     for  (int i =0; i < post_p_arr.size(); i++) {
90         ps_l->typeset_item(post_p_arr[i], c, staff_l_->pstaff_l_,2);
91     }
92
93     Interval pre_wid= align_items(pre_p_arr);
94     translate_items( -pre_wid.right, pre_p_arr);
95     align_items(nobreak_p_arr);
96     Interval post_wid =align_items(post_p_arr);
97     translate_items (-post_wid.left , post_p_arr);
98
99     pre_p_arr.set_size(0);
100         post_p_arr.set_size(0);
101    nobreak_p_arr.set_size(0);
102 }