2 score-reg.cc -- implement Score_register
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 #include "super-elem.hh"
9 #include "scoreline.hh"
11 #include "score-elem.hh"
12 #include "bar.hh" // needed for Bar::static_name
13 #include "staffline.hh"
14 #include "score-reg.hh"
18 #include "musical-request.hh"
19 #include "score-column.hh"
23 Score_register::set_score(Score
*s
)
25 Global_acceptor::set_score(s
);
26 scoreline_l_
= s
->pscore_p_
->super_elem_l_
->line_of_score_l_
;
29 Score_register::Score_register()
38 Score_register::prepare(Moment w
)
40 Score_column
* c1
= new Score_column(w
);
41 Score_column
* c2
= new Score_column(w
);
43 c1
->musical_b_
= false;
44 c2
->musical_b_
= true;
46 score_l_
->cols_
.bottom().add(c1
);
47 score_l_
->cols_
.bottom().add(c2
);
51 post_move_processing();
54 Score_register::finish()
57 do_removal_processing();
61 Score_register::do_creation_processing()
63 scoreline_l_
->left_col_l_
= get_staff_info().command_pcol_l();
64 scoreline_l_
->left_col_l_
->set_breakable();
65 Register_group_register::do_creation_processing();
69 Score_register::set_cols(Score_column
*c1
,Score_column
*c2
)
71 command_column_l_
= c1
;
72 musical_column_l_
= c2
;
76 Score_register::do_removal_processing()
78 Register_group_register::do_removal_processing();
79 scoreline_l_
->right_col_l_
= get_staff_info().command_pcol_l();
80 scoreline_l_
->right_col_l_
->set_breakable();
85 Score_register::process()
89 pre_move_processing();
94 Score_register::announce_element(Score_elem_info info
)
96 info
.origin_reg_l_arr_
.push(this);
97 if (info
.elem_l_
->name() == Bar::static_name()) {
98 get_staff_info().command_pcol_l()->set_breakable();
99 } else if ( info
.elem_l_
->is_type_b( Line_of_staff::static_name() ) &&
100 !scoreline_l_
->contains_b( info
.elem_l_
) )
102 scoreline_l_
->add(info
.elem_l_
);
104 announce_info_arr_
.push(info
);
107 Score_register::do_announces()
109 /* All elements are propagated to the top upon announcement. If
110 something was created during one run of
111 Register_group_register::do_announces, then
112 announce_info_arr_.size() will be nonzero again
115 while (announce_info_arr_
.size()) {
116 for (int i
=0; i
<announce_info_arr_
.size(); i
++)
122 if (announce_info_arr_
[i
].req_l_
) {
123 Musical_req
*m
= announce_info_arr_
[i
].req_l_
->musical();
124 if (m
&&m
->rhythmic()) {
125 musical_column_l_
->add_duration( m
->duration());
128 Register_group_register::do_announces();
134 Score_register::typeset_element(Score_elem
*elem_p
)
136 musical_item_p_arr_
.push(elem_p
);
140 Score_register::typeset_breakable_item(Item
* nobreak_p
)
143 nobreak_item_p_arr_
.push(nobreak_p
);
148 Score_register::typeset_all()
150 PCol
* c
= get_staff_info().command_pcol_l();
151 PScore
*ps_l
= score_l_
->pscore_p_
;
153 for (int i
=0; i
< nobreak_item_p_arr_
.size(); i
++) {
154 ps_l
->typeset_item(nobreak_item_p_arr_
[i
], c
, 0);
155 scoreline_l_
->add(nobreak_item_p_arr_
[i
]);
157 nobreak_item_p_arr_
.set_size(0);
159 for (int i
=0; i
< musical_item_p_arr_
.size(); i
++) {
160 PCol
* m
= get_staff_info().musical_pcol_l();
161 Score_elem
*elem_p
= musical_item_p_arr_
[i
];
163 scoreline_l_
->add(elem_p
);
164 if (elem_p
->spanner()) {
165 ps_l
->typeset_unbroken_spanner(elem_p
->spanner());
166 } else if (elem_p
->item()) {
167 ps_l
->typeset_item(elem_p
->item(), m
, 0);
171 musical_item_p_arr_
.set_size(0);
176 Score_register::do_pre_move_processing()
178 // this generates all items.
179 Register_group_register::do_pre_move_processing();
186 Score_register::get_staff_info()const
190 inf
.command_l_
= command_column_l_
;
191 inf
.musical_l_
= musical_column_l_
;
196 Score_register::paper()const
198 return score_l_
->paper_p_
;
204 Score_register::do_try_request(Request
*r
)
207 for (int i
=0; !gotcha
&& i
< nongroup_l_arr_
.size() ; i
++)
208 gotcha
= nongroup_l_arr_
[i
]->try_request(r
);
213 IMPLEMENT_IS_TYPE_B1(Score_register
,Register_group_register
);
214 IMPLEMENT_STATIC_NAME(Score_register
);
215 ADD_THIS_REGISTER(Score_register
);