2 dynamic-reg.cc -- implement Dynamic_register
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-reg.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_register::Dynamic_register()
22 do_post_move_processing();
24 to_end_cresc_p_
= cresc_p_
= 0;
29 Dynamic_register::do_post_move_processing()
31 dynamic_req_l_arr_
.set_size(0);
35 Dynamic_register::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_register::do_process_requests()
46 Crescendo
* new_cresc_p
=0;
47 for (int i
=0; i
< dynamic_req_l_arr_
.size(); i
++) {
48 Dynamic_req
*dreq_l
= dynamic_req_l_arr_
[i
];
49 if (dreq_l
->absdynamic()) {
50 Text_def
* td_p
= new Text_def
;
52 String loud
=Dynamic_req::loudness_str(
53 dreq_l
->absdynamic()->loudness_
);
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
));
62 } else if (dreq_l
->span_dynamic()) {
64 Span_dynamic_req
* span_l
= dreq_l
->span_dynamic();
65 if (span_l
->spantype
== Span_req::STOP
) {
67 span_l
->warning("Can't find cresc to end " );
69 assert(!to_end_cresc_p_
);
70 to_end_cresc_p_
=cresc_p_
;
73 } else if (span_l
->spantype
== Span_req::START
) {
74 cresc_req_l_
= span_l
;
76 new_cresc_p
= new Crescendo
;
77 new_cresc_p
->grow_dir_i_
= span_l
->dynamic_dir_i_
;
78 announce_element(Score_elem_info(new_cresc_p
, span_l
));
84 cresc_p_
= new_cresc_p
;
85 cresc_p_
->left_col_l_
= get_staff_info().musical_l()->pcol_l_
;
87 cresc_p_
->left_dyn_b_
= true;
93 Dynamic_register::do_pre_move_processing()
95 Staff_symbol
* s_l
= get_staff_info().staff_sym_l_
;
97 dynamic_p_
->set_staffsym(s_l
);
98 typeset_element(dynamic_p_
);
101 if ( to_end_cresc_p_
) {
103 to_end_cresc_p_
->right_dyn_b_
=true;
105 to_end_cresc_p_
->right_col_l_
= get_staff_info().musical_l()->pcol_l_
;
106 to_end_cresc_p_
->set_staffsym(s_l
);
107 typeset_element(to_end_cresc_p_
);
113 Dynamic_register::set_feature(Feature i
)
115 if (i
.type_
== "vdir")
119 IMPLEMENT_STATIC_NAME(Dynamic_register
);
120 IMPLEMENT_IS_TYPE_B1(Dynamic_register
,Request_register
);
121 ADD_THIS_REGISTER(Dynamic_register
);
123 Dynamic_register::~Dynamic_register()
126 delete to_end_cresc_p_
;
128 cresc_req_l_
->warning("unended crescendo");
133 Dynamic_register::acknowledge_element(Score_elem_info i
)
135 if (i
.elem_l_
->name() == Note_column::static_name()) {
136 if (dynamic_p_
) dynamic_p_
->add_support(i
.elem_l_
);
138 to_end_cresc_p_
->add_support(i
.elem_l_
);
140 cresc_p_
->add_support(i
.elem_l_
);