/*
script-engraver.cc -- implement Script_engraver
- (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "script.hh"
#include "engraver.hh"
#include "note-column.hh"
#include "translator-group.hh"
+#include "warn.hh"
struct Script_tuple
{
TRANSLATOR_DECLARATIONS(Script_engraver);
protected:
virtual bool try_music (Music*);
- virtual void initialize ();
virtual void stop_translation_timestep ();
- virtual void start_translation_timestep ();
virtual void process_music ();
virtual void acknowledge_grob (Grob_info);
};
-void
-Script_engraver::initialize ()
-{
- scripts_.clear ();
-}
-
bool
Script_engraver::try_music (Music *r)
{
if (r->is_mus_type ("articulation-event"))
{
+ /*
+ Discard double articulations.
+ This is necessary for part-combining.
+ */
+ for (int j = 0; j < scripts_.size (); j++)
+ if (gh_equal_p (scripts_[j]. event_->get_mus_property ("articulation-type"),
+ r->get_mus_property ("articulation-type")
+ ))
+ return true;
+
Script_tuple t;
t.event_ =r;
scripts_.push (t);
+
return true;
}
return false;
little space by tacking the props onto the Script grob (i.e. make
ScriptStaccato , ScriptMarcato, etc. )
*/
-Grob *make_script_from_event (SCM * descr, Translator_group*tg, Music * event,
- int index)
+void make_script_from_event (Grob *p,
+ SCM * descr, Translator_group*tg,
+ SCM art_type,
+ int index)
{
SCM alist = tg->get_property ("scriptDefinitions");
- SCM art = scm_assoc (event->get_mus_property ("articulation-type"), alist);
+ SCM art = scm_assoc (art_type, alist);
if (art == SCM_BOOL_F)
{
- String a = ly_scm2string (event->get_mus_property ("articulation-type"));
- event->origin ()->warning (_f ("Don't know how to interpret articulation `%s'", a.to_str0 ()));
- return 0 ;
+ warning (_("Don't know how to interpret articulation:"));
+ warning (_("Scheme encoding: "));
+ scm_write (art_type, scm_current_error_port ());
+ return ;
}
art = gh_cdr (art);
-
- Grob *p =new Item (tg->get_property ("Script"));
+
*descr = art;
- SCM force_dir = event->get_mus_property ("direction");
- if (ly_dir_p (force_dir) && to_dir (force_dir))
- p->set_grob_property ("direction", force_dir);
copy_property (p, ly_symbol2scm ("script-molecule"), art);
copy_property (p, ly_symbol2scm ("direction"), art);
Side_position_interface::set_axis (p, Y_AXIS);
p->set_grob_property ("script-priority", gh_int2scm (prio));
- return p;
}
void
{
Music* l=scripts_[i].event_;
- Grob * p = make_script_from_event (&scripts_[i].description_, daddy_trans_, l, i);
+ Grob * p = make_item ("Script");
+
+ make_script_from_event (p, &scripts_[i].description_, daddy_trans_,
+ l->get_mus_property ("articulation-type"),
+ i);
scripts_[i].script_ = p;
+
+
+ SCM force_dir = l->get_mus_property ("direction");
+ if (is_direction (force_dir) && to_dir (force_dir))
+ p->set_grob_property ("direction", force_dir);
+
if (p)
announce_grob (p, l->self_scm());
}
SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"), scripts_[i].description_);
if (gh_pair_p (follow) && to_boolean (gh_cdr (follow)))
- sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
- else
- Side_position_interface::add_staff_support (sc);
+ {
+ sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
+ sc->set_grob_property ("staff-padding", SCM_EOL);
+ }
typeset_grob (sc);
}
scripts_.clear ();
}
-void
-Script_engraver::start_translation_timestep ()
-{
- scripts_.clear ();
-}
-
Script_engraver::Script_engraver(){}