2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1998--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "directional-element-interface.hh"
21 #include "engraver.hh"
23 #include "note-column.hh"
24 #include "pointer-group-interface.hh"
25 #include "side-position-interface.hh"
26 #include "stream-event.hh"
27 #include "text-interface.hh"
29 #include "translator.icc"
32 typeset directions that are plain text.
35 class Text_engraver : public Engraver
37 vector<Stream_event *> evs_;
38 vector<Grob *> scripts_;
40 TRANSLATOR_DECLARATIONS (Text_engraver);
42 void stop_translation_timestep ();
43 void process_music ();
45 DECLARE_ACKNOWLEDGER (note_column);
46 DECLARE_TRANSLATOR_LISTENER (text_script);
49 IMPLEMENT_TRANSLATOR_LISTENER (Text_engraver, text_script);
51 Text_engraver::listen_text_script (Stream_event *ev)
57 Text_engraver::process_music ()
59 for (vsize i = 0; i < evs_.size (); i++)
61 Stream_event *ev = evs_[i];
63 Item *script = make_item ("TextScript", ev->self_scm ());
64 scripts_.push_back (script);
66 int priority = robust_scm2int (script->get_property ("script-priority"),
69 /* see script-engraver.cc */
72 script->set_property ("script-priority", scm_from_int (priority));
74 Direction dir = to_dir (ev->get_property ("direction"));
76 set_grob_direction (script, dir);
78 SCM mark = ev->get_property ("text");
80 script->set_property ("text", mark);
85 Text_engraver::acknowledge_note_column (Grob_info info)
87 // Make note column (or rest, if there are no heads) the parent of the script.
88 extract_grob_set (info.grob (), "note-heads", heads);
89 Grob *x_parent = (heads.size ()
91 : Grob::unsmob (info.grob ()->get_object ("rest")));
93 for (vsize i = 0; i < scripts_.size (); i++)
95 Grob *el = scripts_[i];
97 if (el && !el->get_parent (X_AXIS) && x_parent)
98 el->set_parent (x_parent, X_AXIS);
103 Text_engraver::stop_translation_timestep ()
109 Text_engraver::Text_engraver ()
113 ADD_ACKNOWLEDGER (Text_engraver, note_column);
115 ADD_TRANSLATOR (Text_engraver,
117 "Create text scripts.",