2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "directional-element-interface.hh"
11 #include "engraver.hh"
12 #include "side-position-interface.hh"
14 #include "rhythmic-head.hh"
15 #include "text-item.hh"
18 typeset directions that are plain text.
20 class Text_engraver : public Engraver
22 Link_array<Music> evs_;
23 Link_array<Item> texts_;
25 TRANSLATOR_DECLARATIONS (Text_engraver);
27 virtual bool try_music (Music* m);
28 virtual void stop_translation_timestep ();
29 virtual void process_acknowledged_grobs ();
30 virtual void acknowledge_grob (Grob_info);
34 Text_engraver::try_music (Music *m)
36 if (m->is_mus_type ("text-script-event"))
45 Text_engraver::acknowledge_grob (Grob_info inf)
47 if (Rhythmic_head::has_interface (inf.grob_))
49 for (int 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);
66 if (Stem::has_interface (inf.grob_))
68 for (int i = 0; i < texts_.size (); i++)
70 Side_position_interface::add_support (texts_[i],inf.grob_);
76 Text_engraver::process_acknowledged_grobs ()
80 for (int i = 0; i < evs_.size (); i++)
84 // URG: Text vs TextScript
85 Item *text = make_item ("TextScript", r->self_scm ());
89 Side_position_interface::set_axis (text, ax);
93 SCM s = text->get_property ("script-priority");
94 if (scm_is_number (s))
95 priority = scm_to_int (s);
97 /* see script-engraver.cc */
100 text->set_property ("script-priority", scm_int2num (priority));
102 Direction dir = to_dir (r->get_property ("direction"));
104 set_grob_direction (text, dir);
107 SCM mark = r->get_property ("text");
109 text->set_property ("text", mark);
115 Text_engraver::stop_translation_timestep ()
122 Text_engraver::Text_engraver ()
126 ENTER_DESCRIPTION (Text_engraver,
127 /* descr */ "Create text-scripts",
128 /* creats*/ "TextScript",
129 /* accepts */ "text-script-event",
130 /* acks */ "rhythmic-head-interface stem-interface",