source file of the GNU LilyPond music typesetter
- (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 1998--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "engraver.hh"
#include "side-position-interface.hh"
#include "stem.hh"
#include "stream-event.hh"
+#include "item.hh"
#include "warn.hh"
#include "translator.icc"
+
+
struct Finger_tuple
{
Grob *head_;
class New_fingering_engraver : public Engraver
{
vector<Finger_tuple> fingerings_;
+ vector<Finger_tuple> stroke_fingerings_;
vector<Finger_tuple> articulations_;
vector<Finger_tuple> string_numbers_;
void stop_translation_timestep ();
DECLARE_ACKNOWLEDGER (rhythmic_head);
DECLARE_ACKNOWLEDGER (stem);
- void add_fingering (Grob *, Stream_event *, Stream_event *);
+ void add_fingering (Grob *, SCM,
+ vector<Finger_tuple> *,
+ Stream_event *, Stream_event *);
void add_script (Grob *, Stream_event *, Stream_event *);
void add_string (Grob *, Stream_event *, Stream_event *);
void position_scripts (SCM orientations, vector<Finger_tuple> *);
continue;
if (ev->in_event_class ("fingering-event"))
- add_fingering (inf.grob (), ev, note_ev);
+ add_fingering (inf.grob (),
+ ly_symbol2scm ("Fingering"),
+ &fingerings_,
+ ev, note_ev);
else if (ev->in_event_class ("text-script-event"))
- ev->origin ()->warning (_ ("can't add text scripts to individual note heads"));
+ ev->origin ()->warning (_ ("cannot add text scripts to individual note heads"));
else if (ev->in_event_class ("script-event"))
add_script (inf.grob (), ev, note_ev);
else if (ev->in_event_class ("string-number-event"))
- add_string (inf.grob (), ev, note_ev);
+ add_fingering (inf.grob (),
+ ly_symbol2scm ("StringNumber"), &string_numbers_,
+ ev, note_ev);
+ else if (ev->in_event_class ("stroke-finger-event"))
+ add_fingering (inf.grob (),
+ ly_symbol2scm ("StrokeFinger"), &stroke_fingerings_,
+ ev, note_ev);
else if (ev->in_event_class ("harmonic-event"))
{
inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic"));
Finger_tuple ft;
Grob *g = make_item ("Script", event->self_scm ());
- make_script_from_event (g, context (), event->get_property ("articulation-type"), 0);
- if (g)
- {
- ft.script_ = g;
- ft.script_->set_parent (head, X_AXIS);
-
- articulations_.push_back (ft);
- }
+ make_script_from_event (g, context (),
+ event->get_property ("articulation-type"), 0);
+ ft.script_ = g;
+ ft.script_->set_parent (head, X_AXIS);
+
+ articulations_.push_back (ft);
}
void
New_fingering_engraver::add_fingering (Grob *head,
+ SCM grob_sym,
+ vector<Finger_tuple> *tuple_vector,
Stream_event *event,
Stream_event *hevent)
{
Finger_tuple ft;
- ft.script_ = make_item ("Fingering", event->self_scm ());
+ ft.script_ = internal_make_item (grob_sym, event->self_scm (),
+ ly_symbol2string (grob_sym).c_str (),
+ __FILE__, __LINE__, __FUNCTION__
+ );
Side_position_interface::add_support (ft.script_, head);
- /*
- TODO:
-
- Should add support for thumb. It's a little involved, since
- the thumb lives in a different font. Maybe it should be moved?
- */
-
ft.finger_event_ = event;
ft.note_event_ = hevent;
ft.head_ = head;
- fingerings_.push_back (ft);
-}
-
-void
-New_fingering_engraver::add_string (Grob *head,
- Stream_event *event,
- Stream_event *hevent)
-{
- Finger_tuple ft;
-
- ft.script_ = make_item ("StringNumber", event->self_scm ());
-
- Side_position_interface::add_support (ft.script_, head);
-
- ft.finger_event_ = event;
- ft.note_event_ = hevent;
- ft.head_ = head;
-
- string_numbers_.push_back (ft);
+ tuple_vector->push_back (ft);
}
void
Grob *f = ft.script_;
f->set_parent (ft.head_, X_AXIS);
f->set_parent (ft.head_, Y_AXIS);
-
+ f->set_property ("avoid-slur", SCM_BOOL_F);
+ if (hordir == LEFT
+ && unsmob_grob (ft.head_->get_object ("accidental-grob")))
+ Side_position_interface::add_support (f,
+ unsmob_grob (ft.head_->get_object ("accidental-grob")));
+
Self_alignment_interface::set_align_self (f, Y_AXIS);
Self_alignment_interface::set_center_parent (f, Y_AXIS);
Side_position_interface::set_axis (f, X_AXIS);
void
New_fingering_engraver::stop_translation_timestep ()
{
- position_all();
+ position_all ();
stem_ = 0;
heads_.clear ();
}
string_numbers_.clear ();
}
+ if (stroke_fingerings_.size ())
+ {
+ position_scripts (get_property ("strokeFingerOrientations"),
+ &stroke_fingerings_);
+ stroke_fingerings_.clear ();
+ }
+
for (vsize i = articulations_.size (); i--;)
{
Grob *script = articulations_[i].script_;
"This engraver is ill-named, since it "
"also takes care of articulations and harmonic note heads",
/* create */
- "Fingering",
- /* accept */ "",
+ "Fingering "
+ "StringNumber "
+ "StrokeFinger "
+ "Script "
+ ,
/* read */
"fingeringOrientations "
+ "strokeFingerOrientations "
"stringNumberOrientations "
,