]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-walker.cc
release: 0.0.64
[lilypond.git] / lily / staff-walker.cc
1 /*
2   staff-walker.cc -- implement Staff_walker
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "proto.hh"
10 #include "plist.hh"
11 #include "grouping.hh"
12 #include "staff.hh"
13 #include "musical-request.hh"
14 #include "staff-walker.hh"
15 #include "staff-column.hh"
16 #include "score-column.hh"
17 #include "debug.hh"
18 #include "time-description.hh"
19 #include "command-request.hh"
20 #include "grouping.hh"
21 #include "score-walker.hh"
22
23 Staff_walker::~Staff_walker()
24 {
25     do_pre_move();
26 }
27
28 Staff_walker::Staff_walker(Staff_walker const &s)
29     :PCursor<Staff_column*> (s)
30 {
31     assert(false);
32 }
33
34 Staff_walker::Staff_walker(Staff * s, PScore*ps )
35     : PCursor<Staff_column*> (s->cols_)
36 {
37     staff_l_ = s;
38     pscore_l_ = ps;
39     
40     // should be in tdes. TODO
41     default_grouping = new Rhythmic_grouping(MInterval(0, 1), 4); 
42     score_walk_l_ = 0;
43 }
44
45 Moment
46 Staff_walker::when() const
47 {
48     return ptr()->when();
49 }
50
51 void
52 Staff_walker::process_timing_reqs()
53 {
54     ptr()->update_time(time_, default_grouping);
55 }
56
57 void
58 Staff_walker::operator++(int i)
59 {
60     Moment last = when();
61
62     do_pre_move();
63     PCursor<Staff_column*>::operator++(i);
64     if (ok() ) {
65         Moment delta_t = when() - last;
66         assert(delta_t >Moment(0));
67         time_.add( delta_t );
68     }
69     do_post_move();
70 }
71
72 void
73 Staff_walker::process()
74 {
75     process_timing_reqs();    
76     process_requests();
77 }
78
79 void 
80 Staff_walker::allow_break()
81 {
82     score_walk_l_->allow_break(this);
83 }
84