]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-engraver.cc
release: 1.1.29
[lilypond.git] / lily / lyric-engraver.cc
1 /*
2   lyric-engraver.cc -- implement Lyric_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "lyric-engraver.hh"
11 #include "musical-request.hh"
12 #include "g-text-item.hh"
13 #include "paper-def.hh"
14 #include "lookup.hh"
15
16 ADD_THIS_TRANSLATOR (Lyric_engraver);
17
18
19 Lyric_engraver::Lyric_engraver()
20 {
21 }
22
23 bool
24 Lyric_engraver::do_try_music (Music*r)
25 {
26   if (Lyric_req* l = dynamic_cast <Lyric_req *> (r))
27     {
28       lyric_req_l_arr_.push (l);
29       return true;
30     }
31   return false;
32 }
33
34 void
35 Lyric_engraver::do_process_requests()
36 {
37   if (text_p_arr_.size ())
38     return;
39
40   for (int i=0; i < lyric_req_l_arr_.size (); i++)
41     {
42       Lyric_req* request_l = lyric_req_l_arr_[i];
43       G_text_item* item_p =  new G_text_item;
44       item_p->text_str_ = request_l->text_str_;
45
46       Scalar style = get_property ("textstyle", 0);
47       if (style.length_i ())
48         item_p->style_str_ = style;
49       if (i)
50         {
51           Real dy = paper ()->lookup_l (0)-> text
52             (item_p->style_str_, String ("Cg")).dim_. y ().length ();
53           dy *= 1.1;
54           item_p->translate_axis (-i * dy, Y_AXIS);
55         }
56       
57       text_p_arr_.push (item_p);
58       announce_element (Score_element_info (item_p, request_l));
59     }
60 }
61
62 void
63 Lyric_engraver::do_pre_move_processing()
64 {
65   for (int i=0; i < text_p_arr_.size (); i++)
66     {
67       typeset_element (text_p_arr_[i]);
68     }
69   text_p_arr_.clear ();
70   lyric_req_l_arr_.clear ();
71 }
72