]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-number-grav.cc
release: 0.1.60
[lilypond.git] / lily / bar-number-grav.cc
1 /*
2   bar-number-grav.cc -- implement Bar_number_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #include "bar-number-grav.hh"
11 #include "script.hh"
12 #include "text-def.hh"
13 #include "command-request.hh"
14 #include "bar.hh"
15 #include "time-description.hh"
16
17 Bar_number_engraver::Bar_number_engraver()
18 {
19   script_p_ =0;
20 }
21
22 static Command_script_req dummy;
23
24 void
25 Bar_number_engraver::acknowledge_element (Score_elem_info i)
26 {
27   if (i.origin_grav_l_arr_.size() == 1 &&
28       i.elem_l_->is_type_b (Bar::static_name()) && !script_p_) 
29     {
30       Time_description const * time = get_staff_info().time_C_;
31       if (!time || time->cadenza_b_)
32         return ;
33       
34       script_p_ = new Script;
35       Text_def *td_p =new Text_def;
36       td_p->text_str_ = time->bars_i_;
37       td_p->align_i_ = LEFT;
38
39       script_p_->specs_l_ = td_p;
40       script_p_->breakable_b_ = true;
41       script_p_->dir_ = UP;
42 //      script_p_->y_ += 2;
43       script_p_->y_ = 8;
44
45       announce_element (Score_elem_info (script_p_, &dummy));
46     }
47 }
48
49 void
50 Bar_number_engraver::do_pre_move_processing()
51 {
52   if (script_p_) 
53     {
54       typeset_element (script_p_);
55       script_p_ =0;
56     }
57 }
58
59 IMPLEMENT_IS_TYPE_B1(Bar_number_engraver,Engraver);
60 ADD_THIS_TRANSLATOR(Bar_number_engraver);