2 dynamic-reg.cc -- implement Dynamic_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "crescendo.hh"
10 #include "dynamic-grav.hh"
11 #include "musical-request.hh"
12 #include "text-item.hh"
14 #include "paper-def.hh"
15 #include "score-column.hh"
16 #include "staff-sym.hh"
17 #include "note-column.hh"
19 Dynamic_engraver::Dynamic_engraver()
21 do_post_move_processing();
24 to_end_cresc_p_
= cresc_p_
= 0;
29 Dynamic_engraver::do_post_move_processing()
31 dynamic_req_l_arr_
.clear();
35 Dynamic_engraver::do_try_request (Request
* r
)
37 Musical_req
* m
= r
->musical();
40 Dynamic_req
* d
= m
->dynamic ();
44 if (cresc_p_
&& d
->span_dynamic ()
45 && d
->span_dynamic ()->spantype
== Span_req::START
)
49 for (int i
=0; i
< dynamic_req_l_arr_
.size (); i
++)
50 if (d
->equal_b (dynamic_req_l_arr_
[i
]))
54 dynamic_req_l_arr_
.push (m
->dynamic());
58 Dynamic_engraver::do_process_requests()
60 Crescendo
* new_cresc_p
=0;
61 for (int i
=0; i
< dynamic_req_l_arr_
.size(); i
++)
63 Dynamic_req
*dreq_l
= dynamic_req_l_arr_
[i
];
64 if (dreq_l
->absdynamic())
66 Text_def
* td_p
= new Text_def
;
67 td_p
->align_i_
= CENTER
;
68 String loud
= dreq_l
->absdynamic()->loudness_str ();
69 td_p
->text_str_
= paper()->lookup_l ()->dynamic (loud
).tex_
;
70 td_p
->style_str_
= "dynamic";
72 assert (!dynamic_p_
) ; // TODO
74 dynamic_p_
= new Text_item (td_p
);
75 announce_element (Score_elem_info (dynamic_p_
, dreq_l
));
77 else if (dreq_l
->span_dynamic())
80 Span_dynamic_req
* span_l
= dreq_l
->span_dynamic();
81 if (span_l
->spantype
== Span_req::STOP
)
85 span_l
->warning (_("Can't find cresc to end "));
89 assert (!to_end_cresc_p_
);
90 to_end_cresc_p_
=cresc_p_
;
94 else if (span_l
->spantype
== Span_req::START
)
96 cresc_req_l_
= span_l
;
97 assert (!new_cresc_p
);
98 new_cresc_p
= new Crescendo
;
99 new_cresc_p
->grow_dir_
= span_l
->dynamic_dir_
;
100 announce_element (Score_elem_info (new_cresc_p
, span_l
));
107 cresc_p_
= new_cresc_p
;
108 cresc_p_
->set_bounds(LEFT
,get_staff_info().musical_l ());
111 cresc_p_
->dyn_b_drul_
[LEFT
] = true;
117 Dynamic_engraver::do_pre_move_processing()
119 Staff_symbol
* s_l
= get_staff_info().staff_sym_l_
;
123 to_end_cresc_p_
->dyn_b_drul_
[RIGHT
]=true;
125 to_end_cresc_p_
->set_bounds(RIGHT
,get_staff_info().musical_l ());
126 to_end_cresc_p_
->add_support (s_l
);
127 typeset_element (to_end_cresc_p_
);
133 dynamic_p_
->add_support (s_l
);
134 typeset_element (dynamic_p_
);
140 IMPLEMENT_IS_TYPE_B1(Dynamic_engraver
,Engraver
);
141 ADD_THIS_TRANSLATOR(Dynamic_engraver
);
144 Dynamic_engraver::do_removal_processing ()
148 typeset_element (cresc_p_
);
150 cresc_req_l_
->warning (_("unended crescendo"));
155 typeset_element (to_end_cresc_p_
);
160 typeset_element (dynamic_p_
);
166 Dynamic_engraver::acknowledge_element (Score_elem_info i
)
168 if (i
.elem_l_
->is_type_b (Note_column::static_name ()))
171 dynamic_p_
->add_support (i
.elem_l_
);
174 to_end_cresc_p_
->add_support (i
.elem_l_
);
177 cresc_p_
->add_support (i
.elem_l_
);