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