2 text-spanner-engraver.cc -- implement Text_spanner_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "dimensions.hh"
10 #include "musical-request.hh"
11 #include "paper-column.hh"
12 #include "note-column.hh"
14 #include "side-position-interface.hh"
15 #include "engraver.hh"
16 #include "group-interface.hh"
17 #include "directional-element-interface.hh"
18 #include "translator-group.hh"
19 #include "axis-group-interface.hh"
22 class Text_spanner_engraver : public Engraver
25 TRANSLATOR_DECLARATIONS(Text_spanner_engraver);
27 virtual void finalize ();
28 virtual void acknowledge_grob (Grob_info);
29 virtual bool try_music (Music *);
30 virtual void stop_translation_timestep ();
31 virtual void start_translation_timestep ();
32 virtual void process_music ();
37 Span_req *current_req_;
38 Drul_array<Span_req*> req_drul_;
45 Text_spanner_engraver::Text_spanner_engraver ()
55 Text_spanner_engraver::start_translation_timestep ()
62 Text_spanner_engraver::try_music (Music *m)
64 if (Span_req *s = dynamic_cast <Span_req*> (m))
66 String t = ly_scm2string (s->get_mus_property ("span-type"));
77 req_drul_[s->get_span_dir ()] = s;
85 Text_spanner_engraver::process_music ()
91 req_drul_[STOP]->origin ()->warning
92 (_ ("can't find start of text spanner"));
102 if (req_drul_[START])
106 req_drul_[START]->origin ()->warning(_ ("already have a text spanner"));
110 current_req_ = req_drul_[START];
111 span_ = new Spanner (get_property ("TextSpanner"));
113 /* Ugh. Reset (de)cresc. specific properties */
114 span_->set_grob_property ("outer", SCM_BOOL_T);
115 span_->set_grob_property ("if-text-padding", gh_double2scm (0));
116 span_->set_grob_property ("width-correct", gh_double2scm (0));
118 Side_position_interface::set_axis (span_, Y_AXIS);
119 announce_grob (span_, req_drul_[START]->self_scm());
120 req_drul_[START] = 0;
126 Text_spanner_engraver::acknowledge_grob (Grob_info info)
128 Spanner * spans[2] ={span_, finished_};
129 for (int i = 0; i < 2 ; i++)
131 if (spans[i] && Note_column::has_interface (info.grob_))
133 Side_position_interface::add_support (spans[i], info.grob_);
134 add_bound_item (spans[i], dynamic_cast<Item*> (info.grob_));
140 Text_spanner_engraver::typeset_all ()
144 Side_position_interface::add_staff_support (finished_);
146 if (!finished_->get_bound (RIGHT))
148 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
149 span_->set_bound (RIGHT, e);
151 typeset_grob (finished_);
157 Text_spanner_engraver::stop_translation_timestep ()
159 if (span_ && !span_->get_bound (LEFT))
161 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
162 span_->set_bound (LEFT, e);
169 Text_spanner_engraver::finalize ()
174 current_req_->origin ()->warning (_ ("unterminated text spanner"));
180 ENTER_DESCRIPTION(Text_spanner_engraver,
181 /* descr */ "Create text spanner from a Span_req.",
182 /* creats*/ "TextSpanner",
183 /* acks */ "note-column-interface",