]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-engraver.cc
Run grand-replace for 2010.
[lilypond.git] / lily / text-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1998--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "directional-element-interface.hh"
21 #include "engraver.hh"
22 #include "rhythmic-head.hh"
23 #include "side-position-interface.hh"
24 #include "stem.hh"
25 #include "stream-event.hh"
26 #include "text-interface.hh"
27 #include "item.hh"
28
29 #include "translator.icc"
30
31 /**
32    typeset directions that are  plain text.
33 */
34 class Text_engraver : public Engraver
35 {
36   vector<Stream_event *> evs_;
37   vector<Grob*> texts_;
38 public:
39   TRANSLATOR_DECLARATIONS (Text_engraver);
40 protected:
41   void stop_translation_timestep ();
42   void process_acknowledged ();
43
44   DECLARE_TRANSLATOR_LISTENER (text_script);
45 };
46
47 IMPLEMENT_TRANSLATOR_LISTENER (Text_engraver, text_script);
48 void
49 Text_engraver::listen_text_script (Stream_event *ev)
50 {
51   evs_.push_back (ev);
52 }
53
54 void
55 Text_engraver::process_acknowledged ()
56 {
57   if (texts_.size ())
58     return;
59   for (vsize i = 0; i < evs_.size (); i++)
60     {
61       Stream_event *r = evs_[i];
62
63       // URG: Text vs TextScript
64       Item *text = make_item ("TextScript", r->self_scm ());
65
66       int priority = robust_scm2int (text->get_property ("script-priority"),
67                                      200);
68
69       /* see script-engraver.cc */
70       priority += i;
71
72       text->set_property ("script-priority", scm_from_int (priority));
73
74       Direction dir = to_dir (r->get_property ("direction"));
75       if (dir)
76         set_grob_direction (text, dir);
77
78       SCM mark = r->get_property ("text");
79
80       text->set_property ("text", mark);
81       texts_.push_back (text);
82     }
83 }
84
85 void
86 Text_engraver::stop_translation_timestep ()
87 {
88   texts_.clear ();
89   evs_.clear ();
90 }
91
92 Text_engraver::Text_engraver ()
93 {
94 }
95
96 ADD_TRANSLATOR (Text_engraver,
97                 /* doc */
98                 "Create text scripts.",
99
100                 /* create */
101                 "TextScript ",
102
103                 /* read */
104                 "",
105
106                 /* write */
107                 ""
108                 );