2 lyric-engraver.cc -- implement Lyric_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "musical-request.hh"
12 #include "dimensions.hh"
13 #include "g-text-item.hh"
14 #include "engraver.hh"
16 #include "lily-proto.hh"
18 class Lyric_engraver : public Engraver
21 virtual void do_pre_move_processing();
22 virtual bool do_try_music (Music*);
23 virtual void do_process_requests();
27 VIRTUAL_COPY_CONS(Translator);
30 Link_array<Lyric_req> lyric_req_l_arr_;
31 Link_array<Item> text_p_arr_;
35 ADD_THIS_TRANSLATOR(Lyric_engraver);
38 Lyric_engraver::Lyric_engraver()
43 Lyric_engraver::do_try_music (Music*r)
45 if (Lyric_req* l = dynamic_cast <Lyric_req *> (r))
47 lyric_req_l_arr_.push (l);
54 Lyric_engraver::do_process_requests()
56 if (text_p_arr_.size ())
59 for (int i=0; i < lyric_req_l_arr_.size (); i++)
61 Lyric_req* request_l = lyric_req_l_arr_[i];
62 G_text_item* item_p = new G_text_item;
63 item_p->text_str_ = request_l->text_str_;
65 Scalar style = get_property ("textstyle", 0);
66 if (style.length_i ())
67 item_p->style_str_ = style;
68 // urg, when/how can one get the height of this thing?
69 item_p->translate (Offset (0, - i * 12 PT));
71 text_p_arr_.push (item_p);
72 announce_element (Score_element_info (item_p, request_l));
77 Lyric_engraver::do_pre_move_processing()
79 for (int i=0; i < text_p_arr_.size (); i++)
81 typeset_element (text_p_arr_[i]);
84 lyric_req_l_arr_.clear ();