2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 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"
19 typeset directions that are plain text.
21 class Text_engraver : public Engraver
23 Link_array<Text_script_req> reqs_;
24 Link_array<Item> texts_;
26 VIRTUAL_COPY_CONS(Translator);
28 virtual bool do_try_music (Music* m);
29 virtual void do_pre_move_processing ();
30 virtual void do_post_move_processing ();
31 virtual void do_process_music ();
32 virtual void acknowledge_element (Score_element_info);
37 Text_engraver::do_try_music (Music *m)
39 if (Text_script_req *r = dynamic_cast<Text_script_req*> (m))
41 if (r->style_str_ == "dynamic")
52 Text_engraver::acknowledge_element (Score_element_info inf)
54 if (Rhythmic_head::has_interface (inf.elem_l_))
56 for (int i=0; i < texts_.size (); i++)
58 Score_element*t = texts_[i];
59 Side_position::add_support (t,inf.elem_l_);
60 if (Side_position::get_axis( t) == X_AXIS
61 && !t->parent_l (Y_AXIS))
62 t->set_parent (inf.elem_l_, Y_AXIS);
65 if (Stem::has_interface (inf.elem_l_))
67 for (int i=0; i < texts_.size (); i++)
69 Side_position::add_support(texts_[i],inf.elem_l_);
75 Text_engraver::do_process_music ()
77 for (int i=0; i < reqs_.size (); i++)
79 Text_script_req * r = reqs_[i];
82 Urg: Text_engraver loads TextScriptProperties
84 Item *text = new Item (get_property ("basicTextScriptProperties"));
87 SCM axisprop = get_property ("scriptHorizontal");
89 Side_position::set_axis (text, to_boolean (axisprop) ? X_AXIS : Y_AXIS);
92 make sure they're in order by adding i to the priority field.
94 text->set_elt_property ("script-priority",
95 gh_int2scm (200 + i));
97 if (r->get_direction ())
98 Side_position::set_direction (text, r->get_direction ());
100 text->set_elt_property ("text",
101 ly_str02scm ( r->text_str_.ch_C ()));
103 if (r->style_str_.length_i ())
104 text->set_elt_property ("style", ly_str02scm (r->style_str_.ch_C()));
107 Text is empty by default, which means that the only condition
108 for not setting 'no-spacing-rods' should be: boolean && true.
110 Anyway, non-empty text has been broken for some time now.
114 /// URG this is broken by basicTextScriptProperties which defines
117 SCM nonempty = get_property ("textNonEmpty");
118 if (!to_boolean (nonempty))
120 empty text: signal that no rods should be applied.
122 text->set_elt_property ("no-spacing-rods" , SCM_BOOL_T);
125 announce_element (text, r);
131 Text_engraver::do_pre_move_processing ()
133 for (int i=0; i < texts_.size (); i++)
135 Item *ti = texts_[i];
136 Side_position::add_staff_support (ti);
137 typeset_element (ti);
143 Text_engraver::do_post_move_processing ()
148 ADD_THIS_TRANSLATOR(Text_engraver);