summaryrefslogtreecommitdiff
path: root/src/simplewalker.cc
blob: ad9019ac3369ece76f8999f2c2da80768e78e221 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "request.hh"
#include "beam.hh"
#include "pscore.hh"
#include "simplestaff.hh"
#include "sccol.hh"
#include "stem.hh"
#include "notehead.hh"
#include "rest.hh"
#include "debug.hh"

void
Simple_walker::process_command(Command*com)
{
    switch (com->code){
    case BREAK_PRE:
    case BREAK_MIDDLE:
    case BREAK_POST:
    case BREAK_END:
	(*this)->score_column->set_breakable();
	break_status = com->code- BREAK_PRE;
	break;
    case INTERPRET:
	break;
	
    case TYPESET:
    {
	Item* i = staff()->get_TYPESET_item(com);	
	col()->typeset_item(i, break_status);
    }
	break;
   
    default :
	break;
    }	
}

void
Simple_walker::process_requests()
{
    Simple_column*c = col();
    Simple_staff *s = staff();
    if (c->beam_&& c->beam_->spantype == Span_req::START) {
	if (beam_)
	    error("Too many beams");
	beam_ = new Beam;
    }
    
    if (c->stem_) {
	stem_ = s->get_stem(c->stem_->stem());
	c->typeset_item(stem_);
    }
    
    for (int i = 0; i <  c->notes.sz(); i ++)  {
	Rhythmic_req*rq = c->notes[i];
	if (rq->note()) {
	    Notehead*n = s->get_notehead(rq->note());
	    stem_->add(n);
	    noteheads.add(n);
	}
	
	if (rq->rest()) {
	    c->typeset_item( s->get_rest(rq->rest()) );
	}
    }
    
    
    if (beam_) {
	beam_->add(stem_);
    }
    
    if (c->beam_&& c->beam_->spantype == Span_req::STOP) {
	pscore_->typeset_spanner(beam_, s->theline);
	beam_ = 0;
    }
    for (int i = 0; i < noteheads.sz(); i++) {
	c->typeset_item(noteheads[i]);
    }
    noteheads.set_size(0);

    if (stem_) {
	stem_ = 0;
    }
}

Simple_walker::Simple_walker(Simple_staff*s)
    : Staff_walker(s, s->theline->pscore_)
{
    stem_ = 0;
    beam_ =0;
}



Simple_staff*
Simple_walker::staff()
{
    return (Simple_staff*) staff_;
}

Simple_column*
Simple_walker::col()
{
    return (Simple_column*) *(*this);
}