2 bar-number-grav.cc -- implement Bar_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "lily-guile.hh"
11 #include "paper-column.hh"
12 #include "paper-def.hh"
13 #include "side-position-interface.hh"
16 #include "engraver.hh"
17 #include "translator-group.hh"
20 class Bar_number_engraver : public Engraver
25 virtual void stop_translation_timestep ();
26 virtual void acknowledge_grob (Grob_info);
27 virtual void process_music ();
29 TRANSLATOR_DECLARATIONS( Bar_number_engraver );
34 TODO: more advanced formatting via SCM function, perhaps barnumbers
38 Bar_number_engraver::process_music ()
40 // todo include (&&!time->cadenza_b_)
42 SCM wb = get_property ("whichBar");
46 SCM bn = get_property ("currentBarNumber");
47 SCM smp = get_property ("measurePosition");
48 int ibn = gh_number_p (bn) ? gh_scm2int(bn) : 1;
50 Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
51 if (mp.main_part_ == Rational (0)
57 text_p_->set_grob_property ("text",
58 ly_str02scm (to_str (gh_scm2int (bn)).ch_C ()));
66 Bar_number_engraver::Bar_number_engraver ()
73 Bar_number_engraver::acknowledge_grob (Grob_info inf)
75 Grob * s = inf.grob_l_;
77 && dynamic_cast<Item*> (s)
78 && s->get_grob_property ("break-align-symbol") == ly_symbol2scm ("Left_edge_item"))
81 By default this would land on the Paper_column -- so why
82 doesn't it work when you leave this out? */
83 text_p_->set_parent (s, X_AXIS);
88 Bar_number_engraver::stop_translation_timestep ()
92 text_p_->set_grob_property ("side-support-elements", get_property ("stavesFound"));
93 typeset_grob (text_p_);
100 Bar_number_engraver::create_items ()
105 SCM b = get_property ("BarNumber");
106 text_p_ = new Item (b);
107 Side_position_interface::set_axis (text_p_,Y_AXIS);
109 announce_grob(text_p_, SCM_EOL);
112 ENTER_DESCRIPTION(Bar_number_engraver,
113 /* descr */ "A bar number is created whenever measurePosition is zero. It is
114 put on top of all staves, and appears only at left side of the staff.",
115 /* creats*/ "BarNumber",
116 /* acks */ "break-aligned-interface",
117 /* reads */ "currentBarNumber stavesFound" ,