*/
class Dynamic_engraver : public Engraver
{
- Item * text_p_;
+ Item * script_p_;
Spanner * finished_cresc_p_;
Spanner * cresc_p_;
- Text_script_req* text_req_l_;
+ Dynamic_script_req* script_req_l_;
Span_req * current_cresc_req_;
Drul_array<Span_req*> accepted_spanreqs_drul_;
Dynamic_engraver::Dynamic_engraver ()
{
- text_p_ = 0;
+ script_p_ = 0;
finished_cresc_p_ = 0;
line_spanner_ = 0;
finished_line_spanner_ = 0;
current_cresc_req_ = 0;
cresc_p_ =0;
- text_req_l_ = 0;
+ script_req_l_ = 0;
accepted_spanreqs_drul_[START] = 0;
accepted_spanreqs_drul_[STOP] = 0;
}
void
Dynamic_engraver::do_post_move_processing ()
{
- text_req_l_ = 0;
+ script_req_l_ = 0;
accepted_spanreqs_drul_[START] = 0;
accepted_spanreqs_drul_[STOP] = 0;
}
bool
Dynamic_engraver::do_try_music (Music * m)
{
- if (Text_script_req* d = dynamic_cast <Text_script_req*> (m))
+ if (Dynamic_script_req* d = dynamic_cast <Dynamic_script_req*> (m))
{
- if (d->style_str_ == "dynamic")
- {
- text_req_l_ = d;
- return true;
- }
+ script_req_l_ = d;
+ return true;
}
else if (Span_req* s = dynamic_cast <Span_req*> (m))
{
if (line_spanner_)
line_spanner_->suicide ();
line_spanner_ = 0;
+ if (cresc_p_)
+ cresc_p_->suicide ();
+ cresc_p_ = 0;
}
else if ((s->span_type_str_ == "crescendo"
|| s->span_type_str_ == "decrescendo"))
void
Dynamic_engraver::do_process_music ()
{
- if (accepted_spanreqs_drul_[START] || accepted_spanreqs_drul_[STOP] || text_req_l_)
+ if (accepted_spanreqs_drul_[START] || accepted_spanreqs_drul_[STOP] || script_req_l_)
{
if (!line_spanner_)
{
- line_spanner_ = new Spanner (get_property ("basicDynamicLineSpannerProperties"));
+ line_spanner_ = new Spanner (get_property ("DynamicLineSpanner"));
Side_position::set_axis (line_spanner_, Y_AXIS);
Axis_group_interface::set_interface (line_spanner_);
Axis_group_interface::set_axes (line_spanner_, Y_AXIS, Y_AXIS);
Request * rq = accepted_spanreqs_drul_[START];
- if (text_req_l_) rq = text_req_l_ ;
+ if (script_req_l_) rq = script_req_l_ ;
announce_element (line_spanner_, rq);
*/
else if (accepted_spanreqs_drul_[STOP]
- && !accepted_spanreqs_drul_[START] && !text_req_l_)
+ && !accepted_spanreqs_drul_[START] && !script_req_l_)
{
finished_line_spanner_ = line_spanner_;
line_spanner_ = 0;
maybe we should leave dynamic texts to the text-engraver and
simply acknowledge them?
*/
- if (text_req_l_)
+ if (script_req_l_)
{
- String loud = text_req_l_->text_str_;
-
- text_p_ = new Item (get_property ("basicDynamicTextProperties"));
- text_p_->set_elt_property ("text", ly_str02scm (loud.ch_C ()));
- if (Direction d=text_req_l_->get_direction ())
+ script_p_ = new Item (get_property ("DynamicText"));
+ script_p_->set_elt_property ("text", script_req_l_->text_);
+ if (Direction d = script_req_l_->get_direction ())
Directional_element_interface::set (line_spanner_, d);
- Axis_group_interface::add_element (line_spanner_, text_p_);
+ Axis_group_interface::add_element (line_spanner_, script_p_);
- text_p_->add_offset_callback (Side_position::aligned_on_self,
- Y_AXIS);
- announce_element (text_p_, text_req_l_);
+ announce_element (script_p_, script_req_l_);
}
if (accepted_spanreqs_drul_[STOP])
else
{
current_cresc_req_ = accepted_spanreqs_drul_[START];
- cresc_p_ = new Spanner (get_property ("basicCrescendoProperties"));
- Crescendo::set_interface (cresc_p_);
- cresc_p_->set_elt_property
- ("grow-direction",
- gh_int2scm ((accepted_spanreqs_drul_[START]->span_type_str_ == "crescendo")
- ? BIGGER : SMALLER));
-
- SCM s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Text").ch_C());
- if (gh_string_p (s))
- {
- cresc_p_->set_elt_property ("start-text", s);
- daddy_trans_l_->set_property (accepted_spanreqs_drul_[START]->span_type_str_
- + "Text", SCM_UNDEFINED);
- }
-
- s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Spanner").ch_C());
-
/*
TODO: Use symbols.
*/
- if (gh_string_p (s)) //&& ly_scm2string (s) != "hairpin")
+ SCM s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Spanner").ch_C());
+
+ if (!gh_string_p (s) || ly_scm2string (s) == "hairpin")
+ {
+ cresc_p_ = new Spanner (get_property ("Crescendo"));
+ cresc_p_->set_elt_property ("grow-direction",
+ gh_int2scm ((accepted_spanreqs_drul_[START]->span_type_str_ == "crescendo")
+ ? BIGGER : SMALLER));
+
+ }
+ /*
+ This is a convenient (and legacy) interface to TextSpanners
+ for use in (de)crescendi.
+ Hmm.
+ */
+ else
{
- cresc_p_->set_elt_property ("spanner", s);
+ cresc_p_ = new Spanner (get_property ("TextSpanner"));
+ cresc_p_->set_elt_property ("type", s);
daddy_trans_l_->set_property (accepted_spanreqs_drul_[START]->span_type_str_
+ "Spanner", SCM_UNDEFINED);
+ s = get_property ((accepted_spanreqs_drul_[START]->span_type_str_ + "Text").ch_C());
+ if (gh_string_p (s))
+ {
+ cresc_p_->set_elt_property ("edge-text",
+ gh_cons (s, ly_str02scm ("")));
+ daddy_trans_l_->set_property (accepted_spanreqs_drul_[START]->span_type_str_
+ + "Text", SCM_UNDEFINED);
+ }
}
-
+
Score_element *cc = unsmob_element (get_property ("currentMusicalColumn"));
cresc_p_->set_bound (LEFT, cc);
-
- /*
- We know how wide the text is, if we can be sure that the
- text already has relevant pointers into the paperdef,
- and it has its font-size property set.
-
- Since font-size may be set by a context higher up, we
- can not be sure of the size.
-
-
- We shouldn't try to do this stuff here, the Item should
- do it when the score is finished. We could maybe
- set a callback to have the Item do the alignment if
- it is not a special symbol, like Crescendo.
- */
-
-
- if (text_p_)
+ if (script_p_)
{
- index_set_cell (cresc_p_->get_elt_property ("dynamic-drul"),
- LEFT, text_p_->self_scm ());
-
- if (finished_cresc_p_
- // I don't see why, but we need this check
- && gh_pair_p (finished_cresc_p_->get_elt_property ("dynamic-drul")))
- index_set_cell (finished_cresc_p_->get_elt_property ("dynamic-drul"),
- RIGHT, text_p_->self_scm ());
+ Side_position::set_direction (script_p_, LEFT);
+ Side_position::set_axis (script_p_, X_AXIS);
+ Side_position::add_support (script_p_, cresc_p_);
}
Axis_group_interface::add_element (line_spanner_, cresc_p_);
- cresc_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0));
- cresc_p_->add_offset_callback
- (Side_position::aligned_on_self, Y_AXIS);
announce_element (cresc_p_, accepted_spanreqs_drul_[START]);
}
}
finished_cresc_p_ =0;
}
- if (text_p_)
+ if (script_p_)
{
- typeset_element (text_p_);
- text_p_ = 0;
+ typeset_element (script_p_);
+ script_p_ = 0;
}
if (finished_line_spanner_)
{