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-grav.hh"
11 #include "grouping.hh"
12 #include "text-spanner.hh"
14 #include "grouping.hh"
15 #include "note-head.hh"
16 #include "time-description.hh"
17 #include "duration-convert.hh"
19 Stem_beam_engraver::Stem_beam_engraver()
21 do_post_move_processing();
30 Stem_beam_engraver::do_try_request (Request
*req_l
)
33 Musical_req
* mus_l
= req_l
->musical();
34 /* Debiele puntkomma's. Laat je er eentje per ongeluk achter een
35 if (..) staan, lijkt het net op een luis in gcc.
45 if (bool (beam_p_
) == bool (mus_l
->beam()->spantype
== Span_req::START
))
48 if (beam_req_l_
&& beam_req_l_
->equal_b (mus_l
))
51 beam_req_l_
= mus_l
->beam();
57 if (current_grouping
&& !current_grouping
->child_fit_b (
58 get_staff_info().time_C_
->whole_in_measure_
))
61 if (stem_req_l_
&& !stem_req_l_
->equal_b (mus_l
) )
64 stem_req_l_
= mus_l
->stem();
71 Stem_beam_engraver::do_process_requests()
75 if (beam_req_l_
->spantype
== Span_req::STOP
)
83 start_req_l_
= beam_req_l_
;
84 beam_p_
->left_col_l_
= get_staff_info().musical_pcol_l ();
85 current_grouping
= new Rhythmic_grouping
;
86 if (beam_req_l_
->nplet
)
88 Text_spanner
* t
= new Text_spanner();
89 Text_def
*defp
= new Text_def
;
90 t
->set_support (beam_p_
);
92 defp
->text_str_
= beam_req_l_
->nplet
;
93 defp
->style_str_
="italic";
95 announce_element (Score_elem_info (t
,0));
98 announce_element ( Score_elem_info (beam_p_
, 0));
105 stem_p_
= new Stem (8);
106 if (current_grouping
)
107 current_grouping
->add_child (
108 get_staff_info().time_C_
->whole_in_measure_
,
109 stem_req_l_
->duration());
111 stem_p_
->flag_i_
= Duration_convert::type2_i
112 (stem_req_l_
->duration_
.durlog_i_
); // should change rep. of flags too.
116 if (stem_req_l_
->duration_
.durlog_i_
<= 2)
117 stem_req_l_
->warning ("stem doesn't fit in Beam");
119 beam_p_
->add (stem_p_
);
120 stem_p_
->print_flag_b_
= false;
124 stem_p_
->print_flag_b_
= true;
127 announce_element (Score_elem_info (stem_p_
, stem_req_l_
));
132 Stem_beam_engraver::acknowledge_element (Score_elem_info info
)
137 if (info
.elem_l_
->name() == Note_head::static_name () &&
138 stem_req_l_
->duration()
139 == info
.req_l_
->musical()->rhythmic ()->duration ())
141 Note_head
* n_l
= (Note_head
*)info
.elem_l_
->item();
146 Stem_beam_engraver::do_pre_move_processing()
151 stem_p_
->dir_i_
= default_dir_i_
;
153 typeset_element (stem_p_
);
156 if (beam_p_
&& end_beam_b_
)
158 Rhythmic_grouping
const * rg_C
= get_staff_info().rhythmic_C_
;
159 rg_C
->extend (current_grouping
->interval());
160 beam_p_
->set_grouping (*rg_C
, *current_grouping
);
161 beam_p_
->right_col_l_
= get_staff_info().musical_pcol_l ();
162 typeset_element (beam_p_
);
163 delete current_grouping
;
164 current_grouping
= 0;
170 Stem_beam_engraver::do_post_move_processing()
178 Stem_beam_engraver::~Stem_beam_engraver()
181 start_req_l_
->warning ("unterminated beam");
185 Stem_beam_engraver::set_feature (Feature i
)
187 if (i
.type_
== "vdir")
188 default_dir_i_
= i
.value_
;
192 IMPLEMENT_IS_TYPE_B1(Stem_beam_engraver
,Engraver
);
193 ADD_THIS_ENGRAVER(Stem_beam_engraver
);