#include "beam.hh"
#include "musical-request.hh"
#include "grouping.hh"
-#include "text-spanner.hh"
-#include "text-def.hh"
+#include "p-col.hh"
Beam_engraver::Beam_engraver()
{
Musical_req* mus_l = r->musical();
if (!mus_l)
return false;
-
- Beam_req * b = mus_l->beam();
+ Beam_req* b = mus_l->beam ();
if (!b)
return false;
-
+
if (bool (beam_p_) == bool (b->spantype == Span_req::START))
return false;
-
+
Direction d = (!beam_p_) ? LEFT : RIGHT;
if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (mus_l))
return false;
-
+
span_reqs_drul_[d] = b;
return true;
}
void
Beam_engraver::do_process_requests()
{
- if ( !beam_p_ && span_reqs_drul_[LEFT]) {
- current_grouping_p_ = new Rhythmic_grouping;
- beam_p_ = new Beam;
- if (span_reqs_drul_[LEFT]->nplet)
- {
- Text_spanner* t = new Text_spanner();
- Text_def *defp = new Text_def;
- t->set_support (beam_p_);
- defp->align_i_ = 0;
- defp->text_str_ = span_reqs_drul_[LEFT]->nplet;
- defp->style_str_="italic";
- t->spec_p_ = defp;
- announce_element (Score_elem_info (t,0));
- typeset_element (t);
- }
- announce_element (Score_elem_info (beam_p_, span_reqs_drul_[LEFT]));
- }
+ if (beam_p_ || !span_reqs_drul_[LEFT])
+ return;
+
+ current_grouping_p_ = new Rhythmic_grouping;
+ beam_p_ = new Beam;
+
+ Scalar prop = get_property ("beamslopedamping");
+ if (prop.isnum_b ())
+ beam_p_->damping_i_ = prop;
+
+ prop = get_property ("beamquantisaton");
+ if (prop.isnum_b ())
+ beam_p_->quantisation_ = (Beam::Quantise)(int)prop;
+
+ announce_element (Score_elem_info (beam_p_, span_reqs_drul_[LEFT]));
}
void
Beam_engraver::do_pre_move_processing()
{
- if (beam_p_ && span_reqs_drul_[RIGHT]) {
- Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
- rg_C->extend (current_grouping_p_->interval());
- beam_p_->set_grouping (*rg_C, *current_grouping_p_);
- typeset_element (beam_p_);
- beam_p_ = 0;
-
- delete current_grouping_p_;
- current_grouping_p_ = 0;
-
- span_reqs_drul_[RIGHT] =
- span_reqs_drul_[LEFT] = 0;
- }
+ if (!beam_p_ || !span_reqs_drul_[RIGHT])
+ return;
+
+ Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
+ rg_C->extend (current_grouping_p_->interval());
+ beam_p_->set_grouping (*rg_C, *current_grouping_p_);
+ typeset_element (beam_p_);
+ beam_p_ = 0;
+
+ delete current_grouping_p_;
+ current_grouping_p_ = 0;
+
+ span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
}
void
Beam_engraver::do_removal_processing()
{
- if (beam_p_)
+ if (beam_p_)
{
- span_reqs_drul_[LEFT]->warning ("unterminated beam");
+ span_reqs_drul_[LEFT]->warning (_("unterminated beam"));
typeset_element (beam_p_);
beam_p_ =0;
}
void
Beam_engraver::acknowledge_element (Score_elem_info i)
{
- if (beam_p_ && i.elem_l_->is_type_b (Stem::static_name()))
+ if (!beam_p_ || !i.elem_l_->is_type_b (Stem::static_name ()))
+ return;
+
+ Stem* s = (Stem*)i.elem_l_->item();
+ Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic ();
+ if (rhythmic_req->duration_.durlog_i_<= 2)
+ {
+ rhythmic_req->warning (_("Stem doesn't fit in Beam"));
+ return;
+ }
+
+ /*
+ TODO: do something sensible if it doesn't fit in the beam.
+ */
+ Moment start = get_staff_info().time_C_->whole_in_measure_;
+
+ if (!current_grouping_p_->child_fit_b (start))
+ {
+ String s (_("please fix me: Stem at ")
+ + String(now_moment ()) + _(" does not fit in beam"));
+ if (i.req_l_)
+ i.req_l_->warning(s);
+ else
+ warning (s);
+ }
+ else
{
- Stem * s = (Stem*)i.elem_l_->item();
- Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic ();
- if (rhythmic_req->duration_.durlog_i_<= 2)
- {
- rhythmic_req->warning ("Stem doesn't fit in Beam");
- return ;
- }
-
- /*
- TODO: do something sensible if it doesn't fit in the beam.
- */
- current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_,
- rhythmic_req->duration());
- /*
- TODO
- should change rep. of flags too.k
- */
- s->flag_i_ = Duration_convert::type2_i
- (rhythmic_req->duration_.durlog_i_);
- s->print_flag_b_ = false;
+ current_grouping_p_->add_child (start, rhythmic_req->duration ());
+ s->flag_i_ = rhythmic_req->duration_.durlog_i_;
beam_p_->add (s);
}
-}
-
+}
IMPLEMENT_IS_TYPE_B1(Beam_engraver, Engraver);
-ADD_THIS_ENGRAVER(Beam_engraver);
+ADD_THIS_TRANSLATOR(Beam_engraver);