2 stem-beam-reg.cc -- part of GNU LilyPond
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 #include "musical-request.hh"
8 #include "stem-beam-reg.hh"
11 #include "grouping.hh"
12 #include "text-spanner.hh"
14 #include "grouping.hh"
15 #include "note-head.hh"
16 #include "time-description.hh"
18 Stem_beam_register::Stem_beam_register()
20 do_post_move_processing();
29 Stem_beam_register::do_try_request(Request
*req_l
)
32 Musical_req
* mus_l
= req_l
->musical();
33 /* Debiele puntkomma's. Laat je er eentje per ongeluk achter een
34 if(..) staan, lijkt het net op een luis in gcc.
42 if ( mus_l
->beam() ) {
43 if (bool(beam_p_
) == bool(mus_l
->beam()->spantype
== Span_req::START
))
46 if (beam_req_l_
&& Beam_req::compare(*beam_req_l_
, *mus_l
->beam()))
49 beam_req_l_
= mus_l
->beam();
53 if ( mus_l
->stem() ) {
54 if (current_grouping
&& !current_grouping
->child_fit_b(
55 get_staff_info().time_C_
->whole_in_measure_
))
58 if (stem_req_l_
&& Stem_req::compare(*stem_req_l_
, *mus_l
->stem()))
61 stem_req_l_
= mus_l
->stem();
68 Stem_beam_register::do_process_requests()
71 if (beam_req_l_
->spantype
== Span_req::STOP
) {
76 start_req_l_
= beam_req_l_
;
77 beam_p_
->left_col_l_
= get_staff_info().musical_pcol_l();
78 current_grouping
= new Rhythmic_grouping
;
79 if (beam_req_l_
->nplet
) {
80 Text_spanner
* t
= new Text_spanner();
81 Text_def
*defp
= new Text_def
;
82 t
->set_support(beam_p_
);
84 defp
->text_str_
= beam_req_l_
->nplet
;
85 defp
->style_str_
="italic";
94 stem_p_
= new Stem(8);
96 current_grouping
->add_child(
97 get_staff_info().time_C_
->whole_in_measure_
,
98 stem_req_l_
->duration());
100 stem_p_
->flag_i_
= stem_req_l_
->duration_
.type_i_
;
103 if (stem_req_l_
->duration_
.type_i_
<= 4)
104 stem_req_l_
->warning( "stem doesn't fit in Beam");
106 beam_p_
->add(stem_p_
);
107 stem_p_
->print_flag_b_
= false;
109 stem_p_
->print_flag_b_
= true;
112 announce_element(Score_elem_info(stem_p_
, stem_req_l_
));
117 Stem_beam_register::acknowledge_element(Score_elem_info info
)
122 if (info
.elem_l_
->name() == Note_head::static_name() &&
123 stem_req_l_
->duration()
124 == info
.req_l_
->musical()->rhythmic()->duration()){
125 Note_head
* n_l
= (Note_head
*)info
.elem_l_
->item();
130 Stem_beam_register::do_pre_move_processing()
134 stem_p_
->dir_i_
= default_dir_i_
;
136 typeset_element(stem_p_
);
139 if (beam_p_
&& end_beam_b_
) {
140 Rhythmic_grouping
const * rg_C
= get_staff_info().rhythmic_C_
;
141 rg_C
->extend(current_grouping
->interval());
142 beam_p_
->set_grouping(*rg_C
, *current_grouping
);
143 beam_p_
->right_col_l_
= get_staff_info().musical_pcol_l();
144 typeset_element(beam_p_
);
145 delete current_grouping
;
146 current_grouping
= 0;
152 Stem_beam_register::do_post_move_processing()
160 Stem_beam_register::~Stem_beam_register()
163 start_req_l_
->warning("unterminated beam");
167 Stem_beam_register::set_feature(Feature i
)
169 if (i
.type_
== "vdir")
170 default_dir_i_
= i
.value_
;
173 IMPLEMENT_STATIC_NAME(Stem_beam_register
);
174 IMPLEMENT_IS_TYPE_B1(Stem_beam_register
,Request_register
);
175 ADD_THIS_REGISTER(Stem_beam_register
);