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 virtual void stop_translation_timestep ();
22 virtual void process_music ();
28 Drul_array<Music*> req_drul_;
33 Text_spanner_engraver::Text_spanner_engraver ()
43 Text_spanner_engraver::try_music (Music *m)
45 if (m->is_mus_type ("text-span-event"))
47 Direction d = to_dir (m->get_property ("span-direction"));
56 Text_spanner_engraver::process_music ()
62 req_drul_[STOP]->origin ()->warning (_ ("can't find start of text spanner"));
76 req_drul_[START]->origin ()->warning (_ ("already have a text spanner"));
80 current_req_ = req_drul_[START];
81 span_ = make_spanner ("TextSpanner", req_drul_[START]->self_scm ());
84 Side_position_interface::set_axis (span_, Y_AXIS);
91 Text_spanner_engraver::acknowledge_grob (Grob_info info)
93 Spanner * spans[2] ={span_, finished_};
94 for (int i = 0; i < 2 ; i++)
96 if (spans[i] && Note_column::has_interface (info.grob_))
98 Side_position_interface::add_support (spans[i], info.grob_);
99 add_bound_item (spans[i], dynamic_cast<Item*> (info.grob_));
105 Text_spanner_engraver::typeset_all ()
109 if (!finished_->get_bound (RIGHT))
111 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
112 finished_->set_bound (RIGHT, e);
119 Text_spanner_engraver::stop_translation_timestep ()
121 if (span_ && !span_->get_bound (LEFT))
123 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
124 span_->set_bound (LEFT, e);
128 req_drul_[START] = 0;
133 Text_spanner_engraver::finalize ()
138 current_req_->origin ()->warning (_ ("unterminated text spanner"));
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",