flower-1.0.2
[lilypond.git] / rhythmstaf.cc
bloba7fade6fc5f487378434f554eab1f7c59798f18c
1 #include "request.hh"
2 #include "debug.hh"
3 #include "linestaff.hh"
4 #include "staff.hh"
5 #include "pstaff.hh"
6 #include "pscore.hh"
7 #include "command.hh"
8 #include "molecule.hh"
9 #include "rhythmstaf.hh"
10 #include "symbol.hh"
13 Rhythmic_column::Rhythmic_column(Score_column*s, Rhythmic_staff *rs)
14 : Staff_column(s)
16 the_note = 0;
17 staff_ = rs;
21 void
22 Rhythmic_staff::set_output(PScore* ps )
24 theline = new Linestaff(1);
25 pscore_ = ps;
26 pscore_->add(theline);
29 // should integrate handling of BREAK commands into Staff_column
30 void
31 Rhythmic_column::process_commands( )
33 int breakstat = BREAK_END;
34 for (int i = 0 ; i < s_commands.sz(); i++) {
35 Command *com = s_commands[i];
36 switch (com->code){
37 case INTERPRET:
38 break;
39 case BREAK_PRE:
40 case BREAK_MIDDLE:
41 case BREAK_POST:
42 case BREAK_END:
43 score_column->set_breakable();
44 breakstat = com->code;
45 break;
47 case TYPESET:
48 typeset_command ( com , breakstat);
49 break;
50 default :
51 break;
56 /**
57 accept:
59 BREAK: all
60 TYPESET: bar, meter
66 void
67 Rhythmic_column::process_requests()
69 for (int i = 0 ; i < v_elts.sz(); i ++)
70 for (PCursor<Request *> rqc(v_elts[i]->reqs); rqc.ok(); rqc++) {
71 Request *rq= rqc;
72 switch(rq->tag){
73 case Request::NOTE:
74 case Request::REST:
75 if (the_note){
76 WARN << "too many notes.\n";
77 return;
79 the_note = rq;
80 break;
82 default:
83 return;
90 void
91 Rhythmic_column::typeset_command(Command *com, int breakst)
93 Item *i = new Item;
94 const Symbol*s=0;
96 if (com -> args[0] == "BAR" ) {
97 s = Symbol::find_bar(com->args[1]);
98 } else
99 assert(false);
101 i->output=new Molecule(Atom(s));
102 staff_->pscore_->typeset_item(i, score_column->pcol,
103 staff_->theline,breakst);
106 void
107 Rhythmic_column::typeset_req(Request *rq)
109 Item *i = new Item;
110 const Symbol*s=0;
112 switch(rq->tag){
113 case Request::NOTE:
114 s = Symbol::find_ball(rq->note()->balltype);
115 break;
116 case Request::REST:
117 s = Symbol::find_rest(rq->rest()->balltype);
118 break;
119 default:
120 assert(false);
121 break;
123 i->output = new Molecule(Atom(s));
125 staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline,0 );
128 void
129 Rhythmic_staff::grant_requests()
131 for (PCursor<Staff_column*> cc(cols); cc.ok(); cc++) {
132 Rhythmic_column *rp = (Rhythmic_column*)*cc;
133 if (rp->the_note)
134 rp->typeset_req( rp->the_note);
138 Staff_column*
139 Rhythmic_staff::create_col(Score_column*s)
141 Rhythmic_column *rc = new Rhythmic_column(s,this);
143 return rc;
146 Staff *
147 get_new_rhythmstaff()
149 return new Rhythmic_staff;