2 score-grav.cc -- implement Score_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "super-elem.hh"
10 #include "scoreline.hh"
13 #include "score-grav.hh"
15 #include "musical-request.hh"
16 #include "score-column.hh"
17 #include "command-request.hh"
18 #include "paper-def.hh"
21 Score_engraver::Score_engraver()
32 Score_engraver::prepare (Moment w
)
34 Global_translator::prepare (w
);
35 set_columns (new Score_column (w
), new Score_column (w
));
38 post_move_processing();
42 Score_engraver::finish()
45 *mlog
<< "[" << breaks_i_
<< "]" << flush
;
52 Score_engraver::do_creation_processing()
54 scoreline_l_
= pscore_p_
->super_elem_l_
->line_of_score_l_
;
55 scoreline_l_
->set_bounds(LEFT
,get_staff_info().command_pcol_l ());
56 command_column_l_
->breakable_b_
= true;
57 Engraver_group_engraver::do_creation_processing();
61 Score_engraver::do_removal_processing()
63 Engraver_group_engraver::do_removal_processing();
64 scoreline_l_
->set_bounds(RIGHT
,get_staff_info().command_pcol_l ());
65 command_column_l_
->breakable_b_
= true;
72 Score_engraver::process()
76 pre_move_processing();
81 Score_engraver::announce_element (Score_elem_info info
)
83 announce_info_arr_
.push (info
);
84 info
.origin_grav_l_arr_
.push (this);
88 Score_engraver::do_announces()
90 /* All elements are propagated to the top upon announcement. If
91 something was created during one run of
92 Engraver_group_engraver::do_announces, then
93 announce_info_arr_.size() will be nonzero again
96 while (announce_info_arr_
.size())
98 for (int i
=0; i
< announce_info_arr_
.size(); i
++)
104 if (announce_info_arr_
[i
].req_l_
)
106 Musical_req
*m
= announce_info_arr_
[i
].req_l_
->musical();
107 if (m
&& m
->rhythmic())
109 musical_column_l_
->add_duration (m
->duration());
112 Engraver_group_engraver::do_announces();
118 Score_engraver::typeset_element (Score_elem
*elem_p
)
120 elem_p_arr_
.push(elem_p
);
124 Score_engraver::typeset_all()
126 for (int i
=0; i
< elem_p_arr_
.size(); i
++)
128 Score_elem
* elem_p
= elem_p_arr_
[i
];
129 if (elem_p
->spanner())
131 Spanner
*s
= elem_p
->spanner ();
132 pscore_p_
->typeset_unbroken_spanner (s
);
137 do something sensible if spanner not
142 if (!s
->spanned_drul_
[d
])
144 s
->set_bounds(d
, command_column_l_
);
145 ::warning ("Unbound spanner (type " + String (s
->name ()) + ")");
147 } while (flip(&d
) != LEFT
);
151 Item
*item_p
= elem_p
->item();
152 pscore_p_
->typeset_element (item_p
);
153 if (!item_p
->axis_group_l_a_
[X_AXIS
]) {
154 if (item_p
->breakable_b_
)
155 command_column_l_
->add_element(item_p
);
157 musical_column_l_
->add_element(item_p
);
160 scoreline_l_
->add (elem_p
);
166 Score_engraver::do_pre_move_processing()
168 if (break_penalty_i_
> Break_req::DISALLOW
)
170 get_staff_info().command_pcol_l ()-> breakable_b_
= true;
173 *mlog
<< "[" << breaks_i_
<< "]" << flush
;
175 // this generates all items.
176 Engraver_group_engraver::do_pre_move_processing();
182 Score_engraver::set_columns (Score_column
*new_command_l
,
183 Score_column
*new_musical_l
)
185 if (command_column_l_
&& command_column_l_
->linked_b())
187 pscore_p_
->add_column (command_column_l_
);
188 scoreline_l_
->add (command_column_l_
);
192 delete command_column_l_
;
193 command_column_l_
=0;
197 command_column_l_
= new_command_l
;
198 command_column_l_
->musical_b_
= false;
200 if (musical_column_l_
&& musical_column_l_
->linked_b())
202 pscore_p_
->add_column (musical_column_l_
);
203 scoreline_l_
->add (musical_column_l_
);
207 delete musical_column_l_
;
208 musical_column_l_
= 0;
213 musical_column_l_
= new_musical_l
;
214 musical_column_l_
->musical_b_
= true;
220 Score_engraver::get_staff_info() const
222 Staff_info inf
= Engraver_group_engraver::get_staff_info();
224 inf
.command_l_
= command_column_l_
;
225 inf
.musical_l_
= musical_column_l_
;
233 Score_engraver::get_output_p ()
235 Music_output
* o
= pscore_p_
;
241 Score_engraver::do_try_request (Request
*r
)
243 bool gotcha
= Engraver_group_engraver::do_try_request (r
);
245 if (gotcha
|| !r
->command ())
248 Command_req
* c
= r
->command ();
251 Break_req
* b
= (Break_req
*)c
->linebreak ();
252 if (b
->penalty_i_
<= Break_req::DISALLOW
)
253 break_penalty_i_
= b
->penalty_i_
;
254 else if (b
->penalty_i_
>= Break_req::FORCE
)
256 command_column_l_
->break_penalty_i_
= b
->penalty_i_
;
263 IMPLEMENT_IS_TYPE_B1(Score_engraver
,Engraver_group_engraver
);
264 ADD_THIS_TRANSLATOR(Score_engraver
);
267 Score_engraver::do_add_processing ()
269 Translator_group::do_add_processing ();
270 assert (output_def_l_
->is_type_b (Paper_def::static_name ()));
271 assert (!daddy_trans_l_
);
272 pscore_p_
= new Paper_score
;
273 pscore_p_
->paper_l_
= (Paper_def
*)output_def_l_
;