]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-engraver.cc
release: 1.1.6
[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 */
8
9 #include "lyric-engraver.hh"
10 #include "musical-request.hh"
11 #include "text-item.hh"
12 #include "paper-def.hh"
13 #include "lookup.hh"
14 #include "paper-def.hh"
15 #include "main.hh"
16
17 Lyric_engraver::Lyric_engraver()
18 {
19   lreq_l_ =0;
20   lyric_item_p_ =0;
21 }
22
23 bool
24 Lyric_engraver::do_try_music (Music*r)
25 {
26   if (Lyric_req * lr = dynamic_cast <Lyric_req *> (r))
27     {
28       lreq_l_ = lr;
29       return true;
30     }
31   return false;
32 }
33
34 void
35 Lyric_engraver::do_process_requests()
36 {
37   if (lreq_l_) 
38     {
39       Text_def *td_p = new Text_def;
40       td_p->text_str_ = lreq_l_->text_str_;
41       td_p->align_dir_ = LEFT;
42       Scalar style = get_property ("textstyle");
43       if (style.length_i ())
44         {
45           td_p->style_str_ = style;
46         }
47       Scalar alignment = get_property ("textalignment");
48       if (alignment.isnum_b())
49         {
50           td_p->align_dir_= (Direction)(int)alignment;
51         }
52       
53       lyric_item_p_ =  new Text_item (td_p);
54
55       lyric_item_p_->dir_ = DOWN;
56       lyric_item_p_->fat_b_ = true;
57       announce_element (Score_element_info (lyric_item_p_, lreq_l_));
58     }
59 }
60
61 void
62 Lyric_engraver::do_post_move_processing()
63 {
64   lreq_l_ =0;
65 }
66
67 void
68 Lyric_engraver::do_pre_move_processing()
69 {
70   if (lyric_item_p_)
71     {
72       typeset_element (lyric_item_p_);
73       lyric_item_p_ =0;
74     }
75 }
76
77
78
79 ADD_THIS_TRANSLATOR(Lyric_engraver);