2 dynamic-reg.cc -- implement Dynamic_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 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();
38 if (!m
|| !m
->dynamic())
40 dynamic_req_l_arr_
.push (m
->dynamic());
44 Dynamic_engraver::do_process_requests()
46 Crescendo
* new_cresc_p
=0;
47 for (int i
=0; i
< dynamic_req_l_arr_
.size(); i
++)
49 Dynamic_req
*dreq_l
= dynamic_req_l_arr_
[i
];
50 if (dreq_l
->absdynamic())
52 Text_def
* td_p
= new Text_def
;
54 String loud
= dreq_l
->absdynamic()->loudness_str ();
55 td_p
->text_str_
= paper()->lookup_l ()->dynamic (loud
).tex_
;
56 td_p
->style_str_
= "dynamic";
58 assert (!dynamic_p_
) ; // TODO
60 dynamic_p_
= new Text_item (td_p
);
61 announce_element (Score_elem_info (dynamic_p_
, dreq_l
));
63 else if (dreq_l
->span_dynamic())
66 Span_dynamic_req
* span_l
= dreq_l
->span_dynamic();
67 if (span_l
->spantype
== Span_req::STOP
)
71 span_l
->warning (_("Can't find cresc to end "));
75 assert (!to_end_cresc_p_
);
76 to_end_cresc_p_
=cresc_p_
;
80 else if (span_l
->spantype
== Span_req::START
)
82 cresc_req_l_
= span_l
;
83 assert (!new_cresc_p
);
84 new_cresc_p
= new Crescendo
;
85 new_cresc_p
->grow_dir_
= span_l
->dynamic_dir_
;
86 announce_element (Score_elem_info (new_cresc_p
, span_l
));
93 cresc_p_
= new_cresc_p
;
94 cresc_p_
->set_bounds(LEFT
,get_staff_info().musical_l ());
97 cresc_p_
->dyn_b_drul_
[LEFT
] = true;
103 Dynamic_engraver::do_pre_move_processing()
105 Staff_symbol
* s_l
= get_staff_info().staff_sym_l_
;
109 dynamic_p_
->add_support (s_l
);
110 typeset_element (dynamic_p_
);
116 to_end_cresc_p_
->dyn_b_drul_
[RIGHT
]=true;
118 to_end_cresc_p_
->set_bounds(RIGHT
,get_staff_info().musical_l ());
119 to_end_cresc_p_
->add_support (s_l
);
120 typeset_element (to_end_cresc_p_
);
126 IMPLEMENT_IS_TYPE_B1(Dynamic_engraver
,Engraver
);
127 ADD_THIS_TRANSLATOR(Dynamic_engraver
);
130 Dynamic_engraver::do_removal_processing ()
134 typeset_element (cresc_p_
);
139 typeset_element (to_end_cresc_p_
);
140 cresc_req_l_
->warning (_("unended crescendo"));
145 typeset_element (dynamic_p_
);
151 Dynamic_engraver::acknowledge_element (Score_elem_info i
)
153 if (i
.elem_l_
->name() == Note_column::static_name ())
155 if (dynamic_p_
) dynamic_p_
->add_support (i
.elem_l_
);
157 to_end_cresc_p_
->add_support (i
.elem_l_
);
159 cresc_p_
->add_support (i
.elem_l_
);