2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "note-column.hh"
10 #include "side-position-interface.hh"
11 #include "engraver.hh"
13 class Text_spanner_engraver : public Engraver
16 TRANSLATOR_DECLARATIONS (Text_spanner_engraver);
18 virtual void finalize ();
19 virtual void acknowledge_grob (Grob_info);
20 virtual bool try_music (Music *);
21 PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
22 PRECOMPUTED_VIRTUAL void process_music ();
28 Drul_array<Music *> req_drul_;
32 Text_spanner_engraver::Text_spanner_engraver ()
42 Text_spanner_engraver::try_music (Music *m)
44 if (m->is_mus_type ("text-span-event"))
46 Direction d = to_dir (m->get_property ("span-direction"));
55 Text_spanner_engraver::process_music ()
61 req_drul_[STOP]->origin ()->warning (_ ("can't find start of text spanner"));
75 req_drul_[START]->origin ()->warning (_ ("already have a text spanner"));
79 current_req_ = req_drul_[START];
80 span_ = make_spanner ("TextSpanner", req_drul_[START]->self_scm ());
82 Side_position_interface::set_axis (span_, Y_AXIS);
89 Text_spanner_engraver::acknowledge_grob (Grob_info info)
91 Spanner *spans[2] ={span_, finished_};
92 for (int i = 0; i < 2; i++)
94 if (spans[i] && Note_column::has_interface (info.grob ()))
96 Side_position_interface::add_support (spans[i], info.grob ());
97 add_bound_item (spans[i], dynamic_cast<Item *> (info.grob ()));
103 Text_spanner_engraver::typeset_all ()
107 if (!finished_->get_bound (RIGHT))
109 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
110 finished_->set_bound (RIGHT, e);
117 Text_spanner_engraver::stop_translation_timestep ()
119 if (span_ && !span_->get_bound (LEFT))
121 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
122 span_->set_bound (LEFT, e);
126 req_drul_[START] = 0;
131 Text_spanner_engraver::finalize ()
136 current_req_->origin ()->warning (_ ("unterminated text spanner"));
142 #include "translator.icc"
144 ADD_TRANSLATOR (Text_spanner_engraver,
145 /* descr */ "Create text spanner from a Music.",
146 /* creats*/ "TextSpanner",
147 /* accepts */ "text-span-event",
148 /* acks */ "note-column-interface",