2 trill-spanner-engraver.cc -- implement Trill_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
10 C&P from text-spanner.cc
12 - todo: ending should be detected automatically? a new note
13 automatically is the end of the trill?
16 #include "engraver.hh"
18 #include "international.hh"
19 #include "note-column.hh"
20 #include "side-position-interface.hh"
21 #include "stream-event.hh"
24 #include "translator.icc"
26 class Trill_spanner_engraver : public Engraver
29 TRANSLATOR_DECLARATIONS (Trill_spanner_engraver);
31 virtual void finalize ();
32 DECLARE_ACKNOWLEDGER (note_column);
33 DECLARE_TRANSLATOR_LISTENER (trill_span);
34 void stop_translation_timestep ();
35 void process_music ();
40 Stream_event *current_event_;
41 Drul_array<Stream_event *> event_drul_;
45 Trill_spanner_engraver::Trill_spanner_engraver ()
50 event_drul_[START] = 0;
51 event_drul_[STOP] = 0;
54 IMPLEMENT_TRANSLATOR_LISTENER (Trill_spanner_engraver, trill_span);
56 Trill_spanner_engraver::listen_trill_span (Stream_event *ev)
58 Direction d = to_dir (ev->get_property ("span-direction"));
59 ASSIGN_EVENT_ONCE (event_drul_[d], ev);
63 Trill_spanner_engraver::process_music ()
65 if (event_drul_[STOP])
68 event_drul_[STOP]->origin ()->warning (_ ("cannot find start of trill spanner"));
77 if (event_drul_[START])
80 event_drul_[START]->origin ()->warning (_ ("already have a trill spanner"));
83 current_event_ = event_drul_[START];
84 span_ = make_spanner ("TrillSpanner", event_drul_[START]->self_scm ());
85 Side_position_interface::set_axis (span_, Y_AXIS);
86 event_drul_[START] = 0;
92 Trill_spanner_engraver::acknowledge_note_column (Grob_info info)
94 Spanner *spans[2] ={span_, finished_};
95 for (int i = 0; i < 2; i++)
99 Side_position_interface::add_support (spans[i], info.grob ());
100 add_bound_item (spans[i], info.grob ());
106 Trill_spanner_engraver::typeset_all ()
110 if (!finished_->get_bound (RIGHT))
112 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
113 finished_->set_bound (RIGHT, e);
120 Trill_spanner_engraver::stop_translation_timestep ()
122 if (span_ && !span_->get_bound (LEFT))
124 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
125 span_->set_bound (LEFT, e);
129 event_drul_[START] = 0;
130 event_drul_[STOP] = 0;
134 Trill_spanner_engraver::finalize ()
144 ADD_ACKNOWLEDGER (Trill_spanner_engraver, note_column);
145 ADD_TRANSLATOR (Trill_spanner_engraver,
146 /* doc */ "Create trill spanner from an event.",
147 /* create */ "TrillSpanner",