]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-number-engraver.cc
release: 1.1.1
[lilypond.git] / lily / bar-number-engraver.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@cs.uu.nl>
7 */
8
9
10 #include "bar-number-engraver.hh"
11 #include "script.hh"
12 #include "text-def.hh"
13 #include "paper-def.hh"
14 #include "command-request.hh"
15 #include "bar.hh"
16 #include "span-bar.hh"
17 #include "stem.hh"
18 #include "time-description.hh"
19
20 Bar_number_engraver::Bar_number_engraver()
21 {
22   script_p_ =0;
23 }
24
25 void
26 Bar_number_engraver::acknowledge_element (Score_element_info i)
27 {
28   Bar *b =dynamic_cast <Bar *> (i.elem_l_);
29   if (script_p_ || !b)
30       return;
31
32   /* Only put numbers on bars that are at our own level (don't put
33     numbers over the staffs of a GrandStaff, only over the GrandStaff
34     itself */
35   if (i.origin_grav_l_arr_.size() != 1)
36     return;
37
38   Time_description const * time = get_staff_info().time_C_;
39   if (!time || time->cadenza_b_)
40     return;
41   
42   script_p_ = new Script;
43   Text_def *td_p = new Text_def;
44   td_p->text_str_ = to_str (time->bars_i_);
45
46   td_p->align_dir_ = LEFT;
47
48   script_p_->dir_ = UP;
49   script_p_->axis_ = Y_AXIS;
50   script_p_->specs_p_ = td_p->clone ();
51   script_p_->breakable_b_ = true;
52
53   Scalar pri = get_property ("barNumberBreakPriority");
54   if (pri.length_i () && pri.isnum_b ())
55     {
56       script_p_->break_priority_i_ = int (pri);
57     }
58   else
59     script_p_->break_priority_i_ = b->break_priority_i_;
60
61   Scalar padding = get_property ("barScriptPadding");
62   if (padding.length_i() && padding.isnum_b ())
63     {
64       script_p_->padding_f_ = Real(padding);
65     }
66
67   announce_element (Score_element_info (script_p_,0));
68 }
69
70 void
71 Bar_number_engraver::do_pre_move_processing()
72 {
73   if (script_p_) 
74     {
75       typeset_element (script_p_);
76       script_p_ =0;
77     }
78 }
79
80 IMPLEMENT_IS_TYPE_B1(Bar_number_engraver,Engraver);
81 ADD_THIS_TRANSLATOR(Bar_number_engraver);