2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "international.hh"
12 #include "note-column.hh"
13 #include "side-position-interface.hh"
15 #include "stream-event.hh"
17 #include "translator.icc"
19 class Text_spanner_engraver : public Engraver
22 TRANSLATOR_DECLARATIONS (Text_spanner_engraver);
24 virtual void finalize ();
25 DECLARE_TRANSLATOR_LISTENER (text_span);
26 void stop_translation_timestep ();
27 void process_music ();
32 Stream_event *current_event_;
33 Drul_array<Stream_event *> event_drul_;
37 Text_spanner_engraver::Text_spanner_engraver ()
42 event_drul_[START] = 0;
43 event_drul_[STOP] = 0;
46 IMPLEMENT_TRANSLATOR_LISTENER (Text_spanner_engraver, text_span);
48 Text_spanner_engraver::listen_text_span (Stream_event *ev)
50 Direction d = to_dir (ev->get_property ("span-direction"));
51 ASSIGN_EVENT_ONCE (event_drul_[d], ev);
55 Text_spanner_engraver::process_music ()
57 if (event_drul_[STOP])
60 event_drul_[STOP]->origin ()->warning (_ ("cannot find start of text spanner"));
69 if (event_drul_[START])
72 event_drul_[START]->origin ()->warning (_ ("already have a text spanner"));
75 current_event_ = event_drul_[START];
76 span_ = make_spanner ("TextSpanner", event_drul_[START]->self_scm ());
78 Side_position_interface::set_axis (span_, Y_AXIS);
79 event_drul_[START] = 0;
85 Text_spanner_engraver::typeset_all ()
89 if (!finished_->get_bound (RIGHT))
91 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
92 finished_->set_bound (RIGHT, e);
99 Text_spanner_engraver::stop_translation_timestep ()
101 if (span_ && !span_->get_bound (LEFT))
103 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
104 span_->set_bound (LEFT, e);
108 event_drul_[START] = 0;
109 event_drul_[STOP] = 0;
113 Text_spanner_engraver::finalize ()
118 current_event_->origin ()->warning (_ ("unterminated text spanner"));
124 ADD_TRANSLATOR (Text_spanner_engraver,
126 "Create text spanner from an event.",