(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "warn.hh"
+
+#include "axis-group-interface.hh"
+#include "context.hh"
#include "dimensions.hh"
-#include "hairpin.hh"
-#include "event.hh"
-#include "paper-column.hh"
-#include "note-column.hh"
-#include "item.hh"
-#include "side-position-interface.hh"
+#include "directional-element-interface.hh"
#include "engraver.hh"
+#include "event.hh"
#include "group-interface.hh"
-#include "directional-element-interface.hh"
-#include "context.hh"
-#include "axis-group-interface.hh"
+#include "hairpin.hh"
+#include "interval.hh"
+#include "item.hh"
+#include "slur.hh"
+#include "note-column.hh"
+#include "paper-column.hh"
#include "script-interface.hh"
+#include "side-position-interface.hh"
+#include "staff-symbol-referencer.hh"
+#include "warn.hh"
/*
TODO:
*/
class Dynamic_engraver : public Engraver
{
- Item * script_;
+ Item *script_;
Spanner *line_spanner_;
+ Spanner *slur_;
Spanner *cresc_;
Spanner *finished_line_spanner_;
Dynamic_engraver::Dynamic_engraver ()
{
script_ = 0;
+ slur_ = 0;
finished_cresc_ = 0;
line_spanner_ = 0;
finished_line_spanner_ = 0;
}
bool
-Dynamic_engraver::try_music (Music * m)
+Dynamic_engraver::try_music (Music *m)
{
if (m->is_mus_type ("absolute-dynamic-event"))
{
start_type = "crescendo";
SCM s = get_property ((start_type + "Spanner").to_str0 ());
- if (!ly_c_symbol_p (s) || s == ly_symbol2scm ("hairpin"))
+ if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin"))
{
cresc_ = make_spanner ("Hairpin", accepted_spanreqs_drul_[START]->self_scm ());
+ if (finished_cresc_)
+ {
+ Pointer_group_interface::add_grob (finished_cresc_,
+ ly_symbol2scm ("adjacent-hairpins"),
+ cresc_);
+
+ Pointer_group_interface::add_grob (cresc_,
+ ly_symbol2scm ("adjacent-hairpins"),
+ finished_cresc_);
+ }
cresc_->set_property ("grow-direction",
scm_int2num ((start_type == "crescendo")
? BIGGER : SMALLER));
/*
FIXME: use get_markup () to check type.
*/
- if (ly_c_string_p (s) || ly_c_pair_p (s))
+ if (scm_is_string (s) || ly_c_pair_p (s))
{
cresc_->set_property ("edge-text",
scm_cons (s, scm_makfrom0str ("")));
typeset_all ();
if (!current_cresc_ev_)
{
+
finished_line_spanner_ = line_spanner_;
- line_spanner_ =0;
+ line_spanner_ = 0;
typeset_all ();
}
void
Dynamic_engraver::typeset_all ()
-{
+{
if (finished_cresc_)
{
if (!finished_cresc_->get_bound (RIGHT))
finished_cresc_->set_bound (RIGHT, script_
? script_
: unsmob_grob (get_property ("currentMusicalColumn")));
-
+
if (finished_line_spanner_)
add_bound_item (finished_line_spanner_,
finished_cresc_->get_bound (RIGHT));
}
void
-Dynamic_engraver::acknowledge_grob (Grob_info i)
+Dynamic_engraver::acknowledge_grob (Grob_info info)
{
if (!line_spanner_)
- return ;
-
- if (Note_column::has_interface (i.grob_))
+ return;
+
+ 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_,i.grob_);
- add_bound_item (line_spanner_,dynamic_cast<Item*> (i.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 (i.grob_->get_property ("note-heads"));
+ SCM head = scm_last_pair (info.grob_->get_property ("note-heads"));
if (ly_c_pair_p (head))
script_->set_parent (unsmob_grob (ly_car (head)), X_AXIS);
}
-
}
- else if (Script_interface::has_interface (i.grob_) && script_)
+ else if (Script_interface::has_interface (info.grob_) && script_)
{
- SCM p = i.grob_->get_property ("script-priority");
+ SCM p = info.grob_->get_property ("script-priority");
/*
UGH.
DynamicText doesn't really have a script-priority field.
*/
- if (ly_c_number_p (p)
- && ly_scm2int (p) < ly_scm2int (script_->get_property ("script-priority")))
- {
- Side_position_interface::add_support (line_spanner_, i.grob_);
-
- }
+ 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_);
}
+ else if (Slur::has_interface (info.grob_))
+ slur_ = dynamic_cast<Spanner*> (info.grob_);
}
ENTER_DESCRIPTION (Dynamic_engraver,
/* creats*/ "DynamicLineSpanner DynamicText Hairpin TextSpanner",
/* accepts */ "absolute-dynamic-event crescendo-event decrescendo-event",
-/* acks */ "note-column-interface script-interface",
+/* acks */ "note-column-interface script-interface slur-interface",
/* reads */ "",
/* write */ "");