lilypond-1.1.7
[lilypond.git] / src / complexprint.cc
blob6abe7659d2373239b0433566b1ef462ef1a86599
1 #include "keyitem.hh"
3 #include "request.hh"
4 #include "pscore.hh"
5 #include "paperdef.hh"
6 #include "complexstaff.hh"
7 #include "sccol.hh"
8 #include "debug.hh"
10 #include "clefitem.hh"
11 #include "bar.hh"
12 #include "meter.hh"
13 const NO_LINES = 5;
15 Item *
16 Complex_staff::get_TYPESET_item(Command *com)
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';
35 return s;
40 Interval
41 itemlist_width(const Array<Item*> &its)
43 Interval iv ;
44 iv.set_empty();
46 for (int j =0; j < its.size(); j++){
47 iv.unite (its[j]->width());
50 return iv;
53 void
54 Complex_column::typeset_item(Item *i, int breakst)
56 assert(i);
58 staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
59 staff_l_->pstaff_l_,breakst);
61 if (breakst == BREAK_PRE - BREAK_PRE) {
63 Array<Item*> to_move(
64 staff_l_->pscore_l_->select_items(staff_l_->pstaff_l_,
65 score_column_l_->pcol_l_->prebreak_p_));
66 Interval column_wid = itemlist_width(to_move);
67 assert(!column_wid.empty());
69 for (int j=0; j < to_move.size(); j++) {
70 to_move[j]->translate(Offset(-column_wid.right, 0));
75 UGGGG
77 void
78 Complex_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH!
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_;
87 Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->pstaff_l_,
88 c));
89 typeset_item(i, breakst);
91 Interval column_wid = itemlist_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));
97 void
98 Complex_staff::set_output(PScore* pscore_l )
100 pstaff_l_ = new PStaff(pscore_l); // pstaff_l_ is added to pscore later.
101 pscore_l_ = pscore_l;
102 pscore_l_->add(pstaff_l_);