2 bar-number-grav.cc -- implement Bar_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "bar-number-engraver.hh"
12 #include "text-def.hh"
13 #include "paper-def.hh"
14 #include "command-request.hh"
16 #include "span-bar.hh"
18 #include "time-description.hh"
20 Bar_number_engraver::Bar_number_engraver()
26 Bar_number_engraver::acknowledge_element (Score_element_info i)
29 Item *it=dynamic_cast <Item *> (i.elem_l_);
31 || !it || !it->is_type_b (Bar::static_name()))
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
37 if (i.origin_grav_l_arr_.size() != 1)
40 Time_description const * time = get_staff_info().time_C_;
41 if (!time || time->cadenza_b_)
44 script_p_ = new Script;
45 Text_def *td_p = new Text_def;
46 td_p->text_str_ = to_str (time->bars_i_);
48 td_p->align_dir_ = LEFT;
51 script_p_->axis_ = Y_AXIS;
52 script_p_->specs_p_ = td_p->clone ();
53 script_p_->breakable_b_ = true;
55 Scalar pri = get_property ("barNumberBreakPriority");
56 if (pri.length_i () && pri.isnum_b ())
58 script_p_->break_priority_i_ = int (pri);
61 script_p_->break_priority_i_ = it->break_priority_i_;
63 Scalar padding = get_property ("barScriptPadding");
64 if (padding.length_i() && padding.isnum_b ())
66 script_p_->padding_f_ = Real(padding);
69 announce_element (Score_element_info (script_p_,0));
73 Bar_number_engraver::do_pre_move_processing()
77 typeset_element (script_p_);
82 IMPLEMENT_IS_TYPE_B1(Bar_number_engraver,Engraver);
83 ADD_THIS_TRANSLATOR(Bar_number_engraver);