2 score-walker.cc -- implement Score_walker
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "score-walker.hh"
13 #include "staff-walker.hh"
15 #include "score-column.hh"
17 Score_walker::Score_walker(Score
*s
)
18 :PCursor
<Score_column
*> (s
->cols_
)
21 for (iter_top(s
->staffs_
,i
); i
.ok(); i
++) {
22 Staff_walker
* w_p
=i
->get_walker_p();
23 w_p
->score_walk_l_
=this;
24 walker_p_arr_
.push(w_p
);
33 Score_walker::reinit()
35 disallow_break_walk_l_arr
= walker_p_arr_
;
36 disallow_break_count_
= disallow_break_walk_l_arr
.size();
40 /** Advance the cursor, and all Staff_walkers contained in this. Reset
43 Score_walker::operator ++(int )
45 Moment last
= ptr()->when();
47 PCursor
<Score_column
*>::operator++(0);
48 if (ok() && ptr()->when() == last
)
49 PCursor
<Score_column
*>::operator++(0);
51 bool last_b
= (!ok()); // ughh
52 for (int i
=0; i
< walker_p_arr_
.size(); i
++) {
53 if (walker_p_arr_
[i
]->ok() &&
54 (last_b
|| walker_p_arr_
[i
]->when() < when())) {
56 walker_p_arr_
[i
]->operator++(0);
61 /** Allow the command_column to be breakable for one staff. If all
62 staffs allow, then allow a break here. */
64 Score_walker::allow_break(Staff_walker
*w
)
66 for (int i
=0; i
< disallow_break_walk_l_arr
.size(); i
++) {
67 if (w
== disallow_break_walk_l_arr
[i
]) {
68 disallow_break_count_
--;
69 disallow_break_walk_l_arr
[i
] =0;
71 if (!disallow_break_count_
) {
72 PCursor
<Score_column
*> col_cursor
= *this;
73 if (ptr()->musical_b())
75 col_cursor
->set_breakable();
82 Score_walker::break_allowed_b()
84 return !disallow_break_count_
;
94 Score_walker::process()
96 for (int i
=0; i
< walker_p_arr_
.size(); i
++) {
97 Staff_walker
*w
= walker_p_arr_
[i
];
98 if ( w
->ok() && w
->when() == when() ) {
99 walker_p_arr_
[i
]->process();
102 if (break_allowed_b()){
104 if (! (breaks_i_
% 8))
105 *mlog
<< "[" <<breaks_i_
<<"]"<<flush
;
109 Score_walker::~Score_walker()
111 *mlog
<< "[" <<breaks_i_
<<"]"<<flush
;
112 for (int i
=0; i
< walker_p_arr_
.size(); i
++)
113 delete walker_p_arr_
[i
];