#include "side-position-interface.hh"
#include "staff-symbol-referencer.hh"
#include "warn.hh"
+#include "self-alignment-interface.hh"
+#include "pointer-group-interface.hh"
/*
TODO:
line-spanner
- TODO: this engraver is too complicated. We should split it into
- the handling of the basic grobs and the linespanner
+ the handling of the basic grobs and the linespanner
- TODO: the line-spanner is not killed after the (de)crescs are
finished.
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
virtual bool try_music (Music *req);
- virtual void stop_translation_timestep ();
- virtual void process_music ();
+ PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
+ PRECOMPUTED_VIRTUAL void process_music ();
};
-
Dynamic_engraver::Dynamic_engraver ()
{
script_ = 0;
if (!line_spanner_)
{
Music *rq = accepted_spanreqs_drul_[START];
- line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm (): SCM_EOL);
+ line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm () : SCM_EOL);
if (script_ev_)
rq = script_ev_;
Axis_group_interface::add_element (line_spanner_, script_);
}
- Music *stop_ev = accepted_spanreqs_drul_ [STOP] ?
- accepted_spanreqs_drul_[STOP] : script_ev_;
+ Music *stop_ev = accepted_spanreqs_drul_ [STOP]
+ ? accepted_spanreqs_drul_[STOP] : script_ev_;
if (accepted_spanreqs_drul_[STOP] || script_ev_)
{
{
assert (!finished_cresc_ && cresc_);
- cresc_->set_bound (RIGHT, script_
- ? script_
- : unsmob_grob (get_property ("currentMusicalColumn")));
- add_bound_item (line_spanner_, cresc_->get_bound (RIGHT));
-
+ if (script_)
+ {
+ cresc_->set_bound (RIGHT, script_);
+ add_bound_item (line_spanner_, script_);
+ }
+
finished_cresc_ = cresc_;
cresc_ = 0;
current_cresc_ev_ = 0;
accepted_spanreqs_drul_[STOP]->origin ()->warning (_ ("can't find start of (de)crescendo"));
stop_ev = 0;
}
-
}
if (accepted_spanreqs_drul_[START])
msg = _ ("already have a crescendo");
accepted_spanreqs_drul_[START]->origin ()->warning (msg);
- current_cresc_ev_->origin ()->warning (_ ("Cresc started here"));
+ current_cresc_ev_->origin ()->warning (_ ("cresc starts here"));
}
else
{
cresc_->set_property ("grow-direction",
scm_int2num ((start_type == "crescendo")
? BIGGER : SMALLER));
-
}
/*
void
Dynamic_engraver::stop_translation_timestep ()
{
- typeset_all ();
- if (!current_cresc_ev_)
+ if (!current_cresc_ev_ && line_spanner_)
{
+ assert (!finished_line_spanner_);
finished_line_spanner_ = line_spanner_;
line_spanner_ = 0;
- typeset_all ();
}
+
+ typeset_all ();
if (cresc_ && !cresc_->get_bound (LEFT))
{
if (!line_spanner_)
return;
- if (Note_column::has_interface (info.grob_))
+ if (Note_column::has_interface (info.grob ()))
{
if (line_spanner_
/* Don't refill killed spanner */
&& line_spanner_->is_live ())
{
- Side_position_interface::add_support (line_spanner_, info.grob_);
- add_bound_item (line_spanner_, dynamic_cast<Item *> (info.grob_));
+ Side_position_interface::add_support (line_spanner_, info.grob ());
+ add_bound_item (line_spanner_, dynamic_cast<Item *> (info.grob ()));
}
if (script_ && !script_->get_parent (X_AXIS))
{
- SCM head = scm_last_pair (info.grob_->get_property ("note-heads"));
- if (scm_is_pair (head))
- script_->set_parent (unsmob_grob (scm_car (head)), X_AXIS);
+ extract_grob_set (info.grob (), "note-heads", heads);
+ if (heads.size())
+ {
+ Grob *head = heads[0];
+ script_->set_parent (head, X_AXIS);
+ script_->add_offset_callback (Self_alignment_interface::centered_on_parent_proc,
+ X_AXIS);
+
+ }
}
- if (cresc_ && !cresc_->get_bound (LEFT))
+ if (cresc_)
{
- cresc_->set_bound (LEFT, info.grob_);
- add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
+ if (!cresc_->get_bound (LEFT))
+ {
+ cresc_->set_bound (LEFT, info.grob ());
+ add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
+ }
}
+ if (finished_cresc_ && !finished_cresc_->get_bound (RIGHT))
+ {
+ finished_cresc_->set_bound (RIGHT, info.grob ());
+ }
}
- else if (Script_interface::has_interface (info.grob_) && script_)
+
+ else if (Script_interface::has_interface (info.grob ()) && script_)
{
- SCM p = info.grob_->get_property ("script-priority");
+ SCM p = info.grob ()->get_property ("script-priority");
/*
UGH.
if (scm_is_number (p)
&& scm_to_int (p)
< scm_to_int (script_->get_property ("script-priority")))
- Side_position_interface::add_support (line_spanner_, info.grob_);
+ Side_position_interface::add_support (line_spanner_, info.grob ());
}
}
+#include "translator.icc"
+
ADD_TRANSLATOR (Dynamic_engraver,
/* descr */
"This engraver creates hairpins, dynamic texts, and their vertical\n"