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"
14 #include "musical-request.hh"
16 #include "rhythmic-head.hh"
20 typeset directions that are plain text.
22 class Text_engraver : public Engraver
24 Link_array<Text_script_req> 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 create_grobs ();
33 virtual void acknowledge_grob (Grob_info);
37 Text_engraver::try_music (Music *m)
39 if (dynamic_cast<Text_script_req*> (m)
40 && m->get_mus_property ("text-type") != ly_symbol2scm ("finger")
41 && m->get_mus_property ("text-type") != ly_symbol2scm ("dynamic"))
43 reqs_.push (dynamic_cast<Text_script_req*> (m));
50 Text_engraver::acknowledge_grob (Grob_info inf)
52 if (Rhythmic_head::has_interface (inf.grob_l_))
54 for (int i=0; i < texts_.size (); i++)
57 Side_position_interface::add_support (t,inf.grob_l_);
62 if (Side_position_interface::get_axis (t) == X_AXIS
63 && !t->get_parent (Y_AXIS))
64 t->set_parent (inf.grob_l_, Y_AXIS);
65 else if (Side_position_interface::get_axis (t) == Y_AXIS
66 && !t->get_parent (X_AXIS))
67 t->set_parent (inf.grob_l_, X_AXIS);
71 if (Stem::has_interface (inf.grob_l_))
73 for (int i=0; i < texts_.size (); i++)
75 Side_position_interface::add_support (texts_[i],inf.grob_l_);
81 Text_engraver::create_grobs ()
85 for (int i=0; i < reqs_.size (); i++)
87 Text_script_req * r = reqs_[i];
89 // URG: Text vs TextScript
90 String basic = "TextScript";
92 Item *text = new Item (get_property (basic.ch_C ()));
95 FIXME -> need to use basic props.
97 SCM axisprop = get_property ("scriptHorizontal");
99 Axis ax = to_boolean (axisprop) ? X_AXIS : Y_AXIS;
100 Side_position_interface::set_axis (text, ax);
103 make sure they're in order by adding i to the priority field.
105 text->set_grob_property ("script-priority",
106 gh_int2scm (200 + i));
108 if (r->get_direction ())
109 Side_position_interface::set_direction (text, r->get_direction ());
111 text->set_grob_property ("text", r->get_mus_property ("text"));
112 announce_grob (text, r->self_scm ());
118 Text_engraver::stop_translation_timestep ()
120 for (int i=0; i < texts_.size (); i++)
122 Item *ti = texts_[i];
123 if (!to_boolean (get_property ("scriptHorizontal")))
124 Side_position_interface::add_staff_support (ti);
131 Text_engraver::start_translation_timestep ()
137 Text_engraver::Text_engraver(){}
139 ENTER_DESCRIPTION(Text_engraver,
140 /* descr */ "Create text-scripts",
141 /* creats*/ "TextScript",
142 /* acks */ "rhythmic-head-interface stem-interface",
143 /* reads */ "scriptHorizontal",