2 stem-beam-reg.cc -- part of LilyPond
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 #include "musicalrequest.hh"
8 #include "stem-beam-reg.hh"
11 #include "grouping.hh"
12 #include "text-spanner.hh"
13 #include "complex-walker.hh"
14 #include "complex-staff.hh"
16 #include "grouping.hh"
17 #include "notehead.hh"
19 Stem_beam_register::Stem_beam_register()
21 post_move_processing();
24 set_feature(Features::dir(0));
29 Stem_beam_register::try_request(Request
*req_l
)
31 if ( req_l
->beam() ) {
32 if (bool(beam_p_
) == bool(req_l
->beam()->spantype
== Span_req::START
))
35 if (beam_req_l_
&& Beam_req::compare(*beam_req_l_
, *req_l
->beam()))
38 beam_req_l_
= req_l
->beam();
42 if ( req_l
->stem() ) {
43 if (current_grouping
&& !current_grouping
->child_fit_query(
44 get_staff_info().time_c_l_
->whole_in_measure_
))
47 if (stem_req_l_
&& Stem_req::compare(*stem_req_l_
, *req_l
->stem()))
50 stem_req_l_
= req_l
->stem();
57 Stem_beam_register::process_requests()
60 if (beam_req_l_
->spantype
== Span_req::STOP
) {
65 start_req_l_
= beam_req_l_
;
67 current_grouping
= new Rhythmic_grouping
;
68 if (beam_req_l_
->nplet
) {
69 Text_spanner
* t
= new Text_spanner();
70 t
->set_support(beam_p_
);
72 t
->spec
.text_str_
= beam_req_l_
->nplet
;
73 t
->spec
.style_str_
="italic";
81 stem_p_
= new Stem(4);
83 current_grouping
->add_child(
84 get_staff_info().time_c_l_
->whole_in_measure_
,
85 stem_req_l_
->duration());
87 stem_p_
->flag
= stem_req_l_
->balltype
;
90 if (stem_req_l_
->balltype
<= 4)
91 warning( "stem doesn't fit in Beam",
92 stem_req_l_
->defined_ch_c_l_
);
94 beam_p_
->add(stem_p_
);
95 stem_p_
->print_flag
= false;
97 stem_p_
->print_flag
= true;
100 announce_element(Staff_elem_info(stem_p_
, stem_req_l_
));
105 Stem_beam_register::acknowledge_element(Staff_elem_info info
)
110 if (info
.elem_p_
->name() == Notehead::static_name() &&
111 stem_req_l_
->duration() == info
.req_l_
->rhythmic()->duration())
113 stem_p_
->add((Notehead
*)info
.elem_p_
);
117 Stem_beam_register::pre_move_processing()
121 stem_p_
->dir
= default_dir_i_
;
123 typeset_element(stem_p_
);
126 if (beam_p_
&& end_beam_b_
) {
127 const Rhythmic_grouping
* rg_c_l
= get_staff_info().rhythmic_c_l_
;
128 rg_c_l
->extend(current_grouping
->interval());
129 beam_p_
->set_grouping(*rg_c_l
, *current_grouping
);
130 typeset_element(beam_p_
);
131 delete current_grouping
;
132 current_grouping
= 0;
138 Stem_beam_register::post_move_processing()
146 Stem_beam_register::~Stem_beam_register()
149 warning("unterminated beam", start_req_l_
->defined_ch_c_l_
);
153 Stem_beam_register::set_feature(Features i
)
155 default_dir_i_
= i
.direction_i_
;