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