2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "engraver.hh"
12 #include "side-position-interface.hh"
16 #include "rhythmic-head.hh"
20 typeset directions that are plain text.
22 class Text_engraver : public Engraver
24 Link_array<Music> reqs_;
25 Link_array<Item> texts_;
27 TRANSLATOR_DECLARATIONS(Text_engraver);
29 virtual bool try_music (Music* m);
30 virtual void stop_translation_timestep ();
31 virtual void start_translation_timestep ();
32 virtual void process_acknowledged_grobs ();
33 virtual void acknowledge_grob (Grob_info);
37 Text_engraver::try_music (Music *m)
39 if (m->is_mus_type ("text-script-event"))
48 Text_engraver::acknowledge_grob (Grob_info inf)
50 if (Rhythmic_head::has_interface (inf.grob_))
52 for (int i=0; i < texts_.size (); i++)
55 Side_position_interface::add_support (t,inf.grob_);
60 if (Side_position_interface::get_axis (t) == X_AXIS
61 && !t->get_parent (Y_AXIS))
62 t->set_parent (inf.grob_, Y_AXIS);
63 else if (Side_position_interface::get_axis (t) == Y_AXIS
64 && !t->get_parent (X_AXIS))
65 t->set_parent (inf.grob_, X_AXIS);
69 if (Stem::has_interface (inf.grob_))
71 for (int i=0; i < texts_.size (); i++)
73 Side_position_interface::add_support (texts_[i],inf.grob_);
79 Text_engraver::process_acknowledged_grobs ()
83 for (int i=0; i < reqs_.size (); i++)
87 // URG: Text vs TextScript
88 String basic = "TextScript";
90 Item *text = new Item (get_property (basic.to_str0 ()));
93 FIXME -> need to use basic props.
95 SCM axisprop = get_property ("scriptHorizontal");
97 Axis ax = to_boolean (axisprop) ? X_AXIS : Y_AXIS;
98 Side_position_interface::set_axis (text, ax);
102 SCM s = text->get_grob_property ("script-priority");
104 priority = gh_scm2int (s);
106 /* see script-engraver.cc */
109 text->set_grob_property ("script-priority", gh_int2scm (priority));
111 Direction dir = to_dir (r->get_mus_property ("direction"));
113 Side_position_interface::set_direction (text, dir);
115 text->set_grob_property ("text", r->get_mus_property ("text"));
116 announce_grob (text, r->self_scm ());
122 Text_engraver::stop_translation_timestep ()
124 for (int i=0; i < texts_.size (); i++)
126 Item *ti = texts_[i];
127 if (!to_boolean (get_property ("scriptHorizontal")))
128 Side_position_interface::add_staff_support (ti);
135 Text_engraver::start_translation_timestep ()
141 Text_engraver::Text_engraver(){}
143 ENTER_DESCRIPTION(Text_engraver,
144 /* descr */ "Create text-scripts",
145 /* creats*/ "TextScript",
146 /* accepts */ "text-script-event",
147 /* acks */ "rhythmic-head-interface stem-interface",
148 /* reads */ "scriptHorizontal",