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 PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
28 PRECOMPUTED_VIRTUAL void process_acknowledged ();
29 virtual void acknowledge_grob (Grob_info);
33 Text_engraver::try_music (Music *m)
35 if (m->is_mus_type ("text-script-event"))
44 Text_engraver::acknowledge_grob (Grob_info inf)
46 if (Rhythmic_head::has_interface (inf.grob ()))
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);
65 if (Stem::has_interface (inf.grob ()))
67 for (int i = 0; i < texts_.size (); i++)
69 Side_position_interface::add_support (texts_[i], inf.grob ());
75 Text_engraver::process_acknowledged ()
79 for (int i = 0; i < evs_.size (); i++)
83 // URG: Text vs TextScript
84 Item *text = make_item ("TextScript", r->self_scm ());
87 Side_position_interface::set_axis (text, ax);
91 SCM s = text->get_property ("script-priority");
92 if (scm_is_number (s))
93 priority = scm_to_int (s);
95 /* see script-engraver.cc */
98 text->set_property ("script-priority", scm_int2num (priority));
100 Direction dir = to_dir (r->get_property ("direction"));
102 set_grob_direction (text, dir);
104 SCM mark = r->get_property ("text");
106 text->set_property ("text", mark);
112 Text_engraver::stop_translation_timestep ()
118 Text_engraver::Text_engraver ()
122 #include "translator.icc"
124 ADD_TRANSLATOR (Text_engraver,
125 /* descr */ "Create text-scripts",
126 /* creats*/ "TextScript",
127 /* accepts */ "text-script-event",
128 /* acks */ "rhythmic-head-interface stem-interface",