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_acknowledged_grobs ();
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_acknowledged_grobs ()
91 req_drul_[STOP]->origin ()->warning
92 (_ ("can't find start of text spanner"));
97 Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
98 span_->set_bound (RIGHT, e);
107 if (req_drul_[START])
111 req_drul_[START]->origin ()->warning
112 (_ ("already have a text spanner"));
116 current_req_ = req_drul_[START];
117 span_ = new Spanner (get_property ("TextSpanner"));
119 /* Ugh. Reset (de)cresc. specific properties */
120 span_->set_grob_property ("outer", SCM_BOOL_T);
121 span_->set_grob_property ("if-text-padding", gh_double2scm (0));
122 span_->set_grob_property ("width-correct", gh_double2scm (0));
124 Side_position_interface::set_axis (span_, Y_AXIS);
125 Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
126 span_->set_bound (LEFT, e);
128 announce_grob (span_, req_drul_[START]->self_scm());
129 req_drul_[START] = 0;
135 Text_spanner_engraver::acknowledge_grob (Grob_info info)
137 if (span_ && Note_column::has_interface (info.grob_))
139 Side_position_interface::add_support (span_, info.grob_);
140 add_bound_item (span_, dynamic_cast<Item*> (info.grob_));
145 Text_spanner_engraver::typeset_all ()
149 Side_position_interface::add_staff_support (finished_);
150 typeset_grob (finished_);
156 Text_spanner_engraver::stop_translation_timestep ()
162 Text_spanner_engraver::finalize ()
167 current_req_->origin ()->warning (_ ("unterminated text spanner"));
173 ENTER_DESCRIPTION(Text_spanner_engraver,
174 /* descr */ "Create text spanner from a Span_req ",
175 /* creats*/ "TextSpanner",
176 /* acks */ "note-column-interface",