2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "directional-element-interface.hh"
10 #include "engraver.hh"
11 #include "side-position-interface.hh"
13 #include "rhythmic-head.hh"
14 #include "text-interface.hh"
17 typeset directions that are plain text.
19 class Text_engraver : public Engraver
21 Link_array<Music> evs_;
22 Link_array<Item> texts_;
24 TRANSLATOR_DECLARATIONS (Text_engraver);
26 virtual bool try_music (Music *m);
27 void stop_translation_timestep ();
28 void process_acknowledged ();
30 DECLARE_ACKNOWLEDGER (stem);
31 DECLARE_ACKNOWLEDGER (rhythmic_head);
35 Text_engraver::try_music (Music *m)
37 if (m->is_mus_type ("text-script-event"))
46 Text_engraver::acknowledge_rhythmic_head (Grob_info inf)
48 for (int i = 0; i < texts_.size (); i++)
51 Side_position_interface::add_support (t, inf.grob ());
56 if (Side_position_interface::get_axis (t) == X_AXIS
57 && !t->get_parent (Y_AXIS))
58 t->set_parent (inf.grob (), Y_AXIS);
59 else if (Side_position_interface::get_axis (t) == Y_AXIS
60 && !t->get_parent (X_AXIS))
61 t->set_parent (inf.grob (), X_AXIS);
66 Text_engraver::acknowledge_stem (Grob_info inf)
68 for (int i = 0; i < texts_.size (); i++)
69 Side_position_interface::add_support (texts_[i], inf.grob ());
73 Text_engraver::process_acknowledged ()
77 for (int i = 0; i < evs_.size (); i++)
81 // URG: Text vs TextScript
82 Item *text = make_item ("TextScript", r->self_scm ());
85 Side_position_interface::set_axis (text, ax);
89 SCM s = text->get_property ("script-priority");
90 if (scm_is_number (s))
91 priority = scm_to_int (s);
93 /* see script-engraver.cc */
96 text->set_property ("script-priority", scm_from_int (priority));
98 Direction dir = to_dir (r->get_property ("direction"));
100 set_grob_direction (text, dir);
102 SCM mark = r->get_property ("text");
104 text->set_property ("text", mark);
110 Text_engraver::stop_translation_timestep ()
116 Text_engraver::Text_engraver ()
120 #include "translator.icc"
122 ADD_ACKNOWLEDGER (Text_engraver, stem);
123 ADD_ACKNOWLEDGER (Text_engraver, rhythmic_head);
124 ADD_TRANSLATOR (Text_engraver,
125 /* doc */ "Create text-scripts",
126 /* create */ "TextScript",
127 /* accept */ "text-script-event",