2 stem-beam-reg.cc -- part of 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"
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();
30 Stem_beam_register::try_request(Request*req_l)
32 if ( req_l->beam() ) {
33 if (bool(beam_p_ ) == bool(req_l->beam()->spantype == Span_req::START))
36 if (beam_req_l_ && Beam_req::compare(*beam_req_l_ , *req_l->beam()))
39 beam_req_l_ = req_l->beam();
43 if ( req_l->stem() ) {
44 if (current_grouping && !current_grouping->child_fit_b(
45 get_staff_info().time_C_->whole_in_measure_))
48 if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem()))
51 stem_req_l_ = req_l->stem();
58 Stem_beam_register::process_requests()
61 if (beam_req_l_->spantype == Span_req::STOP) {
66 start_req_l_ = beam_req_l_;
68 current_grouping = new Rhythmic_grouping;
69 if (beam_req_l_->nplet) {
70 Text_spanner* t = new Text_spanner();
71 t->set_support(beam_p_);
73 t->spec.text_str_ = beam_req_l_->nplet;
74 t->spec.style_str_="italic";
82 stem_p_ = new Stem(10);
84 current_grouping->add_child(
85 get_staff_info().time_C_->whole_in_measure_,
86 stem_req_l_->duration());
88 stem_p_->flag_i_ = stem_req_l_->duration_.type_i_;
91 if (stem_req_l_->duration_.type_i_<= 4)
92 stem_req_l_->warning( "stem doesn't fit in Beam");
94 beam_p_->add(stem_p_);
95 stem_p_->print_flag_b_ = false;
97 stem_p_->print_flag_b_ = true;
100 announce_element(Score_elem_info(stem_p_, stem_req_l_));
105 Stem_beam_register::acknowledge_element(Score_elem_info info)
110 if (info.elem_l_->name() == Notehead::static_name() &&
111 stem_req_l_->duration() == info.req_l_->rhythmic()->duration()){
112 Notehead * n_l= (Notehead*)info.elem_l_->item();
117 Stem_beam_register::pre_move_processing()
121 stem_p_->dir_i_ = default_dir_i_;
123 typeset_element(stem_p_);
126 if (beam_p_ && end_beam_b_) {
127 Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
128 rg_C->extend(current_grouping->interval());
129 beam_p_->set_grouping(*rg_C, *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 start_req_l_->warning("unterminated beam");
153 Stem_beam_register::set_feature(Feature i)
155 if (i.type_ == "vdir")
156 default_dir_i_ = i.value_;
159 IMPLEMENT_STATIC_NAME(Stem_beam_register);
160 ADD_THIS_REGISTER(Stem_beam_register);