source file of the GNU LilyPond music typesetter
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "axis-group-interface.hh"
#include "directional-element-interface.hh"
#include "engraver.hh"
#include "hairpin.hh"
+#include "international.hh"
#include "interval.hh"
#include "note-column.hh"
#include "paper-column.hh"
+#include "pointer-group-interface.hh"
#include "script-interface.hh"
+#include "self-alignment-interface.hh"
#include "side-position-interface.hh"
#include "staff-symbol-referencer.hh"
#include "warn.hh"
-#include "self-alignment-interface.hh"
-#include "pointer-group-interface.hh"
#include "translator.icc"
Drul_array<Music *> accepted_spanevents_drul_;
- Link_array<Note_column> pending_columns_;
- Link_array<Grob> pending_elements_;
+ vector<Note_column*> pending_columns_;
+ vector<Grob*> pending_elements_;
void typeset_all ();
TRANSLATOR_DECLARATIONS (Dynamic_engraver);
- DECLARE_ACKNOWLEDGER(script);
- DECLARE_ACKNOWLEDGER(note_column);
-
+ DECLARE_ACKNOWLEDGER (accidental);
+ DECLARE_ACKNOWLEDGER (script);
+ DECLARE_ACKNOWLEDGER (stem_tremolo);
+ DECLARE_ACKNOWLEDGER (note_column);
+ DECLARE_ACKNOWLEDGER (slur);
protected:
virtual void finalize ();
virtual bool try_music (Music *event);
- PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
- PRECOMPUTED_VIRTUAL void process_music ();
+ void stop_translation_timestep ();
+ void process_music ();
};
Dynamic_engraver::Dynamic_engraver ()
{
Music *rq = accepted_spanevents_drul_[START];
line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm () : SCM_EOL);
-
if (script_ev_)
rq = script_ev_;
}
if (Direction d = to_dir (script_ev_->get_property ("direction")))
set_grob_direction (line_spanner_, d);
+ else if (Direction d = to_dir (line_spanner_->get_property ("direction")))
+ set_grob_direction (script_, d);
Axis_group_interface::add_element (line_spanner_, script_);
}
cresc_->set_bound (RIGHT, script_);
add_bound_item (line_spanner_, script_);
}
-
+
finished_cresc_ = cresc_;
cresc_ = 0;
current_cresc_ev_ = 0;
{
if (current_cresc_ev_)
{
- String msg = _ ("already have a decrescendo");
+ string msg = _ ("already have a decrescendo");
if (current_cresc_ev_->is_mus_type ("decrescendo-event"))
msg = _ ("already have a crescendo");
TODO: Use symbols.
*/
- String start_type
+ string start_type
= ly_symbol2string (current_cresc_ev_->get_property ("name"));
-
- /*
- ugh. Use push/pop?
- */
+
if (start_type == "DecrescendoEvent")
start_type = "decrescendo";
else if (start_type == "CrescendoEvent")
start_type = "crescendo";
+
+
- SCM s = get_property ((start_type + "Spanner").to_str0 ());
+ /*
+ UGH. TODO: should read from original event, so appearance
+ may be altered with \tweak.
+ */
+ SCM s = get_property ((start_type + "Spanner").c_str ());
if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin"))
{
cresc_ = make_spanner ("Hairpin", accepted_spanevents_drul_[START]->self_scm ());
finished_cresc_);
}
cresc_->set_property ("grow-direction",
- scm_int2num ((start_type == "crescendo")
- ? BIGGER : SMALLER));
+ scm_from_int ((start_type == "crescendo")
+ ? BIGGER : SMALLER));
}
/*
cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanevents_drul_[START]->self_scm ());
cresc_->set_property ("style", s);
context ()->set_property ((start_type
- + "Spanner").to_str0 (), SCM_EOL);
- s = get_property ((start_type + "Text").to_str0 ());
+ + "Spanner").c_str (), SCM_EOL);
+ s = get_property ((start_type + "Text").c_str ());
/*
FIXME: use get_markup () to check type.
*/
{
cresc_->set_property ("edge-text",
scm_cons (s, scm_makfrom0str ("")));
- context ()->set_property ((start_type + "Text").to_str0 (),
+ context ()->set_property ((start_type + "Text").c_str (),
SCM_EOL);
}
}
finished_line_spanner_ = line_spanner_;
line_spanner_ = 0;
}
-
+
typeset_all ();
if (cresc_ && !cresc_->get_bound (LEFT))
{
if (finished_cresc_)
{
- if (!finished_cresc_->get_bound (RIGHT))
+ bool use_bar = to_boolean (get_property ("hairpinToBarline"))
+ && scm_is_string (get_property ("whichBar"))
+ && !script_ev_;
+
+
+ if (!finished_cresc_->get_bound (RIGHT)
+ || use_bar)
{
+ Grob *column_bound = unsmob_grob (use_bar
+ ? get_property ("currentCommandColumn")
+ : get_property ("currentMusicalColumn"));
+
finished_cresc_->set_bound (RIGHT, script_
? script_
- : unsmob_grob (get_property ("currentMusicalColumn")));
+ : column_bound);
if (finished_line_spanner_)
add_bound_item (finished_line_spanner_,
}
}
+
+void
+Dynamic_engraver::acknowledge_accidental (Grob_info info)
+{
+ if (line_spanner_)
+ Side_position_interface::add_support (line_spanner_, info.grob ());
+}
+
+
+void
+Dynamic_engraver::acknowledge_stem_tremolo (Grob_info info)
+{
+ if (line_spanner_)
+ Side_position_interface::add_support (line_spanner_, info.grob ());
+}
+
+
+void
+Dynamic_engraver::acknowledge_slur (Grob_info info)
+{
+ if (line_spanner_)
+ Side_position_interface::add_support (line_spanner_, info.grob ());
+}
+
+
void
Dynamic_engraver::acknowledge_note_column (Grob_info info)
{
if (script_ && !script_->get_parent (X_AXIS))
{
extract_grob_set (info.grob (), "note-heads", heads);
- if (heads.size())
+ 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);
-
+ Self_alignment_interface::set_center_parent (script_, X_AXIS);
}
}
}
if (finished_cresc_ && !finished_cresc_->get_bound (RIGHT))
- {
- finished_cresc_->set_bound (RIGHT, info.grob ());
- }
+ finished_cresc_->set_bound (RIGHT, info.grob ());
}
void
Side_position_interface::add_support (line_spanner_, info.grob ());
}
-
-ADD_ACKNOWLEDGER(Dynamic_engraver,script);
-ADD_ACKNOWLEDGER(Dynamic_engraver,note_column);
+ADD_ACKNOWLEDGER (Dynamic_engraver, accidental);
+ADD_ACKNOWLEDGER (Dynamic_engraver, script);
+ADD_ACKNOWLEDGER (Dynamic_engraver, note_column);
+ADD_ACKNOWLEDGER (Dynamic_engraver, slur);
+ADD_ACKNOWLEDGER (Dynamic_engraver, stem_tremolo);
ADD_TRANSLATOR (Dynamic_engraver,
- /* descr */
+ /* doc */
"This engraver creates hairpins, dynamic texts, and their vertical\n"
"alignments. The symbols are collected onto a DynamicLineSpanner grob\n"
"which takes care of vertical positioning. ",
- /* creats*/ "DynamicLineSpanner DynamicText Hairpin TextSpanner",
- /* accepts */ "absolute-dynamic-event crescendo-event decrescendo-event",
- /* acks */ "note-column-interface script-interface",
- /* reads */ "",
+ /* create */ "DynamicLineSpanner DynamicText Hairpin TextSpanner",
+ /* accept */ "absolute-dynamic-event crescendo-event decrescendo-event",
+ /* read */ "",
/* write */ "");