2 pitched-trill-engraver.cc -- implement Pitched_trill_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "engraver.hh"
13 #include "pointer-group-interface.hh"
14 #include "axis-group-interface.hh"
16 #include "note-head.hh"
18 #include "side-position-interface.hh"
22 class Pitched_trill_engraver : public Engraver
25 TRANSLATOR_DECLARATIONS(Pitched_trill_engraver);
28 DECLARE_ACKNOWLEDGER ( note_head);
29 DECLARE_ACKNOWLEDGER ( dots);
30 DECLARE_ACKNOWLEDGER ( text_spanner);
31 void process_music ();
32 virtual bool try_music (Music*);
33 void stop_translation_timestep ();
38 Item *trill_accidental_;
40 Link_array<Grob> heads_;
42 void make_trill (Music *);
46 Pitched_trill_engraver::Pitched_trill_engraver ()
50 trill_accidental_ = 0;
54 Pitched_trill_engraver::acknowledge_dots (Grob_info info)
56 heads_.push (info.grob ());
59 Pitched_trill_engraver::acknowledge_note_head (Grob_info info)
61 heads_.push (info.grob ());
65 Pitched_trill_engraver::acknowledge_text_spanner (Grob_info info)
67 Music *mus = info.music_cause ();
69 && mus->is_mus_type ("trill-span-event")
70 && to_dir (mus->get_property ("span-direction")) == START
71 && unsmob_pitch (mus->get_property ("trill-pitch")))
76 Pitched_trill_engraver::make_trill (Music *mus)
78 SCM scm_pitch = mus->get_property ("trill-pitch");
79 Pitch *p = unsmob_pitch (scm_pitch);
81 SCM keysig = get_property ("localKeySignature");
83 SCM key = scm_cons (scm_from_int (p->get_octave ()),
84 scm_from_int (p->get_notename ()));
86 SCM handle = scm_assoc (key, keysig);
88 = (handle == SCM_BOOL_F)
89 || p->get_alteration () == 0;
93 programming_error ("already have a trill head.");
97 trill_head_ = make_item ("TrillPitchHead", mus->self_scm ());
98 SCM c0scm = get_property ("middleCPosition");
100 int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0;
102 trill_head_->set_property ("staff-position",
103 scm_from_int (unsmob_pitch (scm_pitch)->steps ()
106 trill_group_ = make_item ("TrillPitchGroup", mus->self_scm());
108 Axis_group_interface::add_element (trill_group_, trill_head_);
112 trill_accidental_ = make_item ("TrillPitchAccidental", mus->self_scm ());
114 // fixme: naming -> alterations
115 trill_accidental_->set_property ("accidentals", scm_list_1 (scm_from_int (p->get_alteration ())));
116 Side_position_interface::add_support (trill_accidental_, trill_head_);
117 trill_head_->set_object ("accidental-grob", trill_accidental_->self_scm ());
118 trill_group_->set_parent (trill_head_, Y_AXIS);
119 Axis_group_interface::add_element (trill_group_, trill_accidental_);
120 trill_accidental_->set_parent (trill_head_, Y_AXIS);
125 Pitched_trill_engraver::stop_translation_timestep ()
128 for (int i = 0; i < heads_.size (); i++)
129 Side_position_interface::add_support (trill_group_, heads_[i]);
134 trill_accidental_ = 0;
138 Pitched_trill_engraver::process_music ()
143 Pitched_trill_engraver::try_music (Music *)
148 #include "translator.icc"
149 ADD_ACKNOWLEDGER (Pitched_trill_engraver, note_head);
150 ADD_ACKNOWLEDGER (Pitched_trill_engraver, dots);
151 ADD_ACKNOWLEDGER (Pitched_trill_engraver, text_spanner);
152 ADD_TRANSLATOR (Pitched_trill_engraver,
153 /* doc */ "Print the bracketed notehead after a notehead with trill.",
154 /* create */ "TrillPitchHead TrillPitchAccidental TrillPitchGroup",