2 text-engraver.cc -- implement Text_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
11 #include "g-staff-side.hh"
12 #include "g-text-item.hh"
13 #include "text-def.hh"
14 #include "note-head.hh"
16 #include "staff-sym.hh"
18 class Text_engraver : public Engraver
20 Link_array<Script_req> reqs_;
21 Link_array<G_staff_side_item> positionings_;
22 Link_array<G_text_item> texts_;
25 VIRTUAL_COPY_CONS(Translator);
27 virtual bool do_try_music (Music* m);
28 virtual void do_pre_move_processing ();
29 virtual void do_post_move_processing ();
30 virtual void do_process_requests ();
31 virtual void acknowledge_element (Score_element_info);
34 Text_engraver::Text_engraver ()
40 Text_engraver::do_try_music (Music *m)
42 if (Script_req *r = dynamic_cast<Script_req*> (m))
44 Text_def * t = dynamic_cast<Text_def*> (r->scriptdef_p_);
55 Text_engraver::acknowledge_element (Score_element_info i)
57 if (Note_head *n = dynamic_cast<Note_head*> (i.elem_l_))
59 for (int i=0; i < positionings_.size (); i++)
61 positionings_[i]->add_support (n);
64 if (Stem *n = dynamic_cast<Stem*> (i.elem_l_))
66 for (int i=0; i < positionings_.size (); i++)
68 positionings_[i]->add_support (n);
74 Text_engraver::do_process_requests ()
76 for (int i=0; i < reqs_.size (); i++)
78 Script_req * r = reqs_[i];
79 Text_def * t= dynamic_cast<Text_def*> (r->scriptdef_p_);
81 G_text_item *text = new G_text_item;
82 G_staff_side_item *ss = new G_staff_side_item;
83 ss->set_victim (text);
85 Scalar p (get_property ("textstyle", 0)); // textStyle?
88 text->text_str_ = t->text_str_;
90 Scalar padding = get_property ("textScriptPadding", 0);
91 if (padding.length_i() && padding.isnum_b ())
93 ss->padding_f_ = Real(padding);
96 announce_element (Score_element_info (text, r));
97 announce_element (Score_element_info (ss, r));
100 positionings_.push (ss);
105 Text_engraver::do_pre_move_processing ()
107 Staff_symbol* s_l = get_staff_info().staff_sym_l_;
108 for (int i=0; i < texts_.size (); i++)
112 positionings_[i]->add_support (s_l);
115 typeset_element (texts_[i]);
116 typeset_element (positionings_[i]);
119 positionings_.clear ();
123 Text_engraver::do_post_move_processing ()
128 ADD_THIS_TRANSLATOR(Text_engraver);