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