]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-engraver.cc
release: 1.1.9
[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--1998 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 "text-item.hh"
13 #include "paper-def.hh"
14 #include "lookup.hh"
15 #include "paper-def.hh"
16 #include "main.hh"
17 #include "dimensions.hh"
18
19 ADD_THIS_TRANSLATOR(Lyric_engraver);
20
21 Lyric_engraver::Lyric_engraver()
22 {
23 }
24
25 bool
26 Lyric_engraver::do_try_music (Music*r)
27 {
28   if (Lyric_req* l = dynamic_cast <Lyric_req *> (r))
29     {
30       lyric_req_l_arr_.push (l);
31       return true;
32     }
33   return false;
34 }
35
36 void
37 Lyric_engraver::do_process_requests()
38 {
39   if (text_p_arr_.size ())
40     return;
41
42   Scalar style = get_property ("textstyle");
43   Scalar alignment = get_property ("textalignment");
44   for (int i=0; i < lyric_req_l_arr_.size (); i++)
45     {
46       Lyric_req* request_l = lyric_req_l_arr_[i];
47       Text_def* text_p = new Text_def;
48       text_p->text_str_ = request_l->text_str_;
49       text_p->align_dir_ = LEFT;
50       if (style.length_i ())
51         text_p->style_str_ = style;
52       if (alignment.isnum_b())
53         text_p->align_dir_= (Direction)(int)alignment;
54       
55       Text_item* item_p =  new Text_item (text_p);
56       item_p->dir_ = DOWN;
57       item_p->fat_b_ = true;
58       // urg
59       // item_p->translate (Offset (0, (i - 1) * item_p->height ().length_i ()));
60 //      if (i && ((Text_def*)text_p_arr_[i - 1]->tdef_p_)->text_str_.length_i ())
61       // urg, when/how can one get the heigt of this thing?
62       item_p->translate (Offset (0, - i * 12 PT));
63       text_p_arr_.push (item_p);
64       announce_element (Score_element_info (item_p, request_l));
65     }
66 }
67
68 void
69 Lyric_engraver::do_post_move_processing()
70 {
71 }
72
73 void
74 Lyric_engraver::do_pre_move_processing()
75 {
76   for (int i=0; i < text_p_arr_.size (); i++)
77     {
78       typeset_element (text_p_arr_[i]);
79     }
80   text_p_arr_.clear ();
81   lyric_req_l_arr_.clear ();
82 }
83