]> git.donarmstrong.com Git - lilypond.git/blob - src/complexprint.cc
release: 0.0.27
[lilypond.git] / src / complexprint.cc
1 #include "keyitem.hh"
2
3 #include "request.hh"
4 #include "pscore.hh"
5 #include "paper.hh"
6 #include "complexstaff.hh"
7 #include "sccol.hh"
8 #include "debug.hh"
9 #include "linepstaff.hh"
10 #include "clefitem.hh"
11 #include "bar.hh"
12 #include "meter.hh"
13 const NO_LINES = 5;
14
15 Item *
16 Complex_staff::get_TYPESET_item(Command *com)
17 {
18     Item *s=0;
19     Array<Scalar> arg( com->args);
20     String type =arg[0];
21     arg.del(0);
22     if (com->args[0] == "KEY") {
23         return new Keyitem(NO_LINES);   // urgh. depends on clef.
24     } else if (type ==  "BAR" ) {
25         s = new Bar(com->args[1]);      
26     } else if (type == "METER") {
27         s = new Meter(arg);
28     } else if (type == "CLEF" || type == "CURRENTCLEF") {
29         Clef_item * c = new Clef_item;
30         s = c;
31         c->change = (type == "CLEF");   
32     }else{
33         WARN << "ignoring TYPESET command for " << type << '\n';
34     }
35     return s;
36 }
37
38
39
40 Interval
41 citemlist_width(const Array<Item*> &its)
42 {
43     Interval iv ;
44     iv.set_empty();
45      
46     for (int j =0; j < its.size(); j++){
47         iv.unite (its[j]->width());
48
49     }
50     return iv;
51 }
52
53 void
54 Complex_column::typeset_item(Item *i, int breakst)
55 {
56     assert(i);
57     
58     staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
59                                   staff_l_->theline_l_,breakst);
60     
61     if (breakst == BREAK_PRE - BREAK_PRE) {
62         
63         Array<Item*> to_move(
64             staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
65                                           score_column_l_->pcol_l_->prebreak_p_));
66         Interval column_wid = citemlist_width(to_move);
67         assert(!column_wid.empty());
68
69         for (int j=0; j < to_move.size(); j++) {
70             to_move[j]->translate(Offset(-column_wid.right, 0));
71         }
72     }
73 }    
74 /*
75   UGGGG
76   */
77 void
78 Complex_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH!
79 {
80     assert(i);
81     PCol * c=score_column_l_->pcol_l_;
82     if (breakst == 0)
83         c = c->prebreak_p_;
84     else if (breakst == 2)
85         c = c->postbreak_p_;
86     
87     Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
88                                                       c));    
89     typeset_item(i, breakst);
90
91     Interval column_wid = citemlist_width(to_move);
92     if (column_wid.empty())
93         column_wid = Interval(0,0);
94     i->translate(Offset(column_wid[dir] - i->width()[-dir], 0));
95 }
96
97 void
98 Complex_staff::set_output(PScore* ps )
99 {
100     theline_l_ = new Linestaff(NO_LINES,ps); // theline_l_ is added to pscore later.
101     pscore_l_ = ps;
102     pscore_l_->add(theline_l_);
103 }
104
105