]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-number-engraver.cc
76163d5b3fd8f2da5535a35d35d03373742dba6a
[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
29   Item *it=i.elem_l_->access_Item ();
30   if (script_p_
31       || !it || !it->is_type_b (Bar::static_name()))
32       return;
33
34   /* Only put numbers on bars that are at our own level (don't put
35     numbers over the staffs of a GrandStaff, only over the GrandStaff
36     itself */
37   if (i.origin_grav_l_arr_.size() != 1)
38     return;
39
40   Time_description const * time = get_staff_info().time_C_;
41   if (!time || time->cadenza_b_)
42     return;
43   
44   script_p_ = new Script;
45   Text_def *td_p = new Text_def;
46   td_p->text_str_ = to_str (time->bars_i_);
47
48   td_p->align_dir_ = LEFT;
49
50   script_p_->dir_ = UP;
51   script_p_->axis_ = Y_AXIS;
52   script_p_->specs_p_ = td_p->clone ();
53   script_p_->breakable_b_ = true;
54
55   Scalar pri = get_property ("barNumberBreakPriority");
56   if (pri.length_i () && pri.isnum_b ())
57     {
58       script_p_->break_priority_i_ = int (pri);
59     }
60   else
61     script_p_->break_priority_i_ = it->break_priority_i_;
62
63   Scalar padding = get_property ("barScriptPadding");
64   if (padding.length_i() && padding.isnum_b ())
65     {
66       script_p_->padding_f_ = Real(padding);
67     }
68
69   announce_element (Score_element_info (script_p_,0));
70 }
71
72 void
73 Bar_number_engraver::do_pre_move_processing()
74 {
75   if (script_p_) 
76     {
77       typeset_element (script_p_);
78       script_p_ =0;
79     }
80 }
81
82 IMPLEMENT_IS_TYPE_B1(Bar_number_engraver,Engraver);
83 ADD_THIS_TRANSLATOR(Bar_number_engraver);