2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.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
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_tremolo);
31 DECLARE_ACKNOWLEDGER (stem);
32 DECLARE_ACKNOWLEDGER (rhythmic_head);
36 Text_engraver::try_music (Music *m)
38 if (m->is_mus_type ("text-script-event"))
47 Text_engraver::acknowledge_rhythmic_head (Grob_info inf)
49 for (vsize i = 0; i < texts_.size (); i++)
52 Side_position_interface::add_support (t, inf.grob ());
57 if (Side_position_interface::get_axis (t) == X_AXIS
58 && !t->get_parent (Y_AXIS))
59 t->set_parent (inf.grob (), Y_AXIS);
60 else if (Side_position_interface::get_axis (t) == Y_AXIS
61 && !t->get_parent (X_AXIS))
62 t->set_parent (inf.grob (), X_AXIS);
67 Text_engraver::acknowledge_stem (Grob_info inf)
69 for (vsize i = 0; i < texts_.size (); i++)
70 Side_position_interface::add_support (texts_[i], inf.grob ());
74 Text_engraver::acknowledge_stem_tremolo (Grob_info info)
76 for (vsize i = 0; i < texts_.size (); i++)
77 Side_position_interface::add_support (texts_[i], info.grob ());
81 Text_engraver::process_acknowledged ()
85 for (vsize i = 0; i < evs_.size (); i++)
89 // URG: Text vs TextScript
90 Item *text = make_item ("TextScript", r->self_scm ());
93 Side_position_interface::set_axis (text, ax);
97 SCM s = text->get_property ("script-priority");
98 if (scm_is_number (s))
99 priority = scm_to_int (s);
101 /* see script-engraver.cc */
104 text->set_property ("script-priority", scm_from_int (priority));
106 Direction dir = to_dir (r->get_property ("direction"));
108 set_grob_direction (text, dir);
110 SCM mark = r->get_property ("text");
112 text->set_property ("text", mark);
113 texts_.push_back (text);
118 Text_engraver::stop_translation_timestep ()
124 Text_engraver::Text_engraver ()
128 #include "translator.icc"
130 ADD_ACKNOWLEDGER (Text_engraver, stem);
131 ADD_ACKNOWLEDGER (Text_engraver, stem_tremolo);
132 ADD_ACKNOWLEDGER (Text_engraver, rhythmic_head);
133 ADD_TRANSLATOR (Text_engraver,
134 /* doc */ "Create text-scripts",
135 /* create */ "TextScript",
136 /* accept */ "text-script-event",