/*
script-engraver.cc -- implement Script_engraver
- (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#include "script.hh"
#include "side-position-interface.hh"
#include "musical-request.hh"
#include "stem.hh"
#include "rhythmic-head.hh"
#include "engraver.hh"
+#include "note-column.hh"
-class Script_engraver : public Engraver {
+class Script_engraver : public Engraver
+{
Link_array<Grob> script_p_arr_;
Link_array<Articulation_req> script_req_l_arr_;
public:
- VIRTUAL_COPY_CONS (Translator);
-
+ TRANSLATOR_DECLARATIONS(Script_engraver);
protected:
virtual bool try_music (Music*);
virtual void initialize ();
virtual void acknowledge_grob (Grob_info);
};
-
void
Script_engraver::initialize ()
{
}
// todo -> use result of articulation-to-scriptdef directly as basic prop list.
Grob *p =new Item (get_property ("Script"));
- art = gh_cdr (art);
- p->set_grob_property ("molecule",
- gh_car (art));
+ art = ly_cdr (art);
+ p->set_grob_property ("script-molecule", ly_car (art));
- art = gh_cdr (art);
- bool follow_staff = gh_scm2bool (gh_car (art));
- art = gh_cdr (art);
- SCM relative_stem_dir = gh_car (art);
- art = gh_cdr (art);
+ art = ly_cdr (art);
+ bool follow_staff = gh_scm2bool (ly_car (art));
+ art = ly_cdr (art);
+ SCM relative_stem_dir = ly_car (art);
+ art = ly_cdr (art);
SCM force_dir = l->get_mus_property ("direction");
- if (isdir_b (force_dir) && !to_dir (force_dir))
- force_dir = gh_car (art);
+ if (ly_dir_p (force_dir) && !to_dir (force_dir))
+ force_dir = ly_car (art);
- art = gh_cdr (art);
- SCM priority = gh_car (art);
+ art = ly_cdr (art);
+ SCM priority = ly_car (art);
-
- if (isdir_b (force_dir) && to_dir (force_dir))
+ if (ly_dir_p (force_dir) && to_dir (force_dir))
p->set_grob_property ("direction", force_dir);
else if (to_dir (relative_stem_dir))
p->set_grob_property ("side-relative-direction", relative_stem_dir);
-
/*
SCM axisprop = get_property ("scriptHorizontal");
bool xaxis = to_boolean (axisprop);
Side_position_interface::set_axis (p, xaxis ? X_AXIS : Y_AXIS);
-
+
if (!follow_staff && ! xaxis)
p->set_grob_property ("staff-support", SCM_BOOL_T);
script_p_arr_.push (p);
- announce_grob (p, l);
+ announce_grob (p, l->self_scm());
}
}
void
Script_engraver::acknowledge_grob (Grob_info inf)
{
- bool them_grace = to_boolean (inf.elem_l_->get_grob_property ("grace"));
- bool us_grace = to_boolean (get_property ("weAreGraceContext"));
-
- if (us_grace != them_grace)
- return;
-
- if (Stem::has_interface (inf.elem_l_))
+ if (Stem::has_interface (inf.grob_l_))
{
for (int i=0; i < script_p_arr_.size (); i++)
{
Grob*e = script_p_arr_[i];
- e->set_grob_property ("direction-source", inf.elem_l_->self_scm ());
- e->add_dependency (inf.elem_l_);
- Side_position_interface::add_support (e, inf.elem_l_);
+ e->set_grob_property ("direction-source", inf.grob_l_->self_scm ());
+ e->add_dependency (inf.grob_l_);
+ Side_position_interface::add_support (e, inf.grob_l_);
}
}
- else if (Rhythmic_head::has_interface (inf.elem_l_))
+ else if (Rhythmic_head::has_interface (inf.grob_l_))
{
for (int i=0; i < script_p_arr_.size (); i++)
{
Grob *e = script_p_arr_[i];
- if (!e->parent_l (X_AXIS))
+ if (Side_position_interface::get_axis (e) == X_AXIS
+ && !e->get_parent (Y_AXIS))
{
- e->set_parent (inf.elem_l_, X_AXIS);
+ e->set_parent (inf.grob_l_, Y_AXIS);
+ e->add_dependency (inf.grob_l_); // ??
}
- if (Side_position_interface::get_axis (e) == X_AXIS
- && !e->parent_l (Y_AXIS))
- e->set_parent (inf.elem_l_, Y_AXIS);
+ Side_position_interface::add_support (e,inf.grob_l_);
+ }
+ }
+ else if (Note_column::has_interface (inf.grob_l_))
+ {
+
+ /*
+ We make note column the parent of the script. That's not
+ correct, but due to seconds in a chord, noteheads may be
+ swapped around horizontally. We don't know which note head to
+ put it on, so we postpone this decision to
+ Script_interface::before_line_breaking ().
+
+ */
+ for (int i=0; i < script_p_arr_.size (); i++)
+ {
+ Grob *e = script_p_arr_[i];
- Side_position_interface::add_support (e,inf.elem_l_);
+ if (!e->get_parent (X_AXIS) &&
+ Side_position_interface::get_axis (e) == Y_AXIS)
+ {
+ e->set_parent (inf.grob_l_, X_AXIS);
+ }
}
- }
+ }
}
void
{
for (int i=0; i < script_p_arr_.size (); i++)
{
+
+ /*
+ TODO: junk staff-support.
+ */
Grob * sc = script_p_arr_[i];
if (to_boolean (sc->get_grob_property ("staff-support")))
{
script_req_l_arr_.clear ();
}
-ADD_THIS_TRANSLATOR (Script_engraver);
+Script_engraver::Script_engraver(){}
+
+ENTER_DESCRIPTION(Script_engraver,
+/* descr */ " Handles note ornaments generated by @code{\\script}.
+",
+/* creats*/ "Script",
+/* acks */ "stem-interface rhythmic-head-interface note-column-interface",
+/* reads */ "scriptDefinitions scriptHorizontal",
+/* write */ "");