]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-number-grav.cc
partial: 1.0.1.jcn
[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--1998 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 "stem.hh"
16 #include "time-description.hh"
17
18 Bar_number_engraver::Bar_number_engraver()
19 {
20   script_p_ =0;
21 }
22
23 static Command_script_req dummy;
24 static Stem support;
25
26 void
27 Bar_number_engraver::acknowledge_element (Score_elem_info i)
28 {
29   if (i.origin_grav_l_arr_.size() == 1 &&
30       i.elem_l_->is_type_b (Bar::static_name()) && !script_p_) 
31     {
32       Time_description const * time = get_staff_info().time_C_;
33       if (!time || time->cadenza_b_)
34         return ;
35       
36       script_p_ = new Script;
37       Text_def *td_p =new Text_def;
38       td_p->text_str_ = time->bars_i_;
39       td_p->align_i_ = LEFT;
40
41       script_p_->specs_l_ = td_p;
42       script_p_->breakable_b_ = true;
43
44       // ugh, howto move this up?
45       script_p_->dir_ = UP;
46 ////      script_p_->y_ += 2;
47       script_p_->y_ = 10;
48
49       support.dir_ = UP;
50       support.set_stemend (10);
51       script_p_->set_stem (&support);
52
53       announce_element (Score_elem_info (script_p_, &dummy));
54     }
55 }
56
57 void
58 Bar_number_engraver::do_pre_move_processing()
59 {
60   if (script_p_) 
61     {
62       typeset_element (script_p_);
63       script_p_ =0;
64     }
65 }
66
67 IMPLEMENT_IS_TYPE_B1(Bar_number_engraver,Engraver);
68 ADD_THIS_TRANSLATOR(Bar_number_engraver);