2 bar-number-grav.cc -- implement Bar_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 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"
14 #include "staff-symbol.hh"
17 #include "engraver.hh"
18 #include "translator-group.hh"
21 class Bar_number_engraver : public Engraver
27 virtual void stop_translation_timestep ();
28 virtual void acknowledge_grob (Grob_info);
29 virtual void initialize ();
30 virtual void create_grobs ();
34 VIRTUAL_COPY_CONS (Translator);
35 Bar_number_engraver ();
40 TODO: more advanced formatting via SCM function, perhaps barnumbers
44 Bar_number_engraver::create_grobs ()
46 // todo include (&&!time->cadenza_b_)
47 SCM bn = get_property ("currentBarNumber");
48 SCM smp = get_property ("measurePosition");
49 Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
51 if (gh_number_p (bn) &&
52 !mp.to_bool () && now_mom () > Moment (0))
57 text_p_->set_grob_property ("text",
58 ly_str02scm (to_str (gh_scm2int (bn)).ch_C ()));
62 ADD_THIS_TRANSLATOR (Bar_number_engraver);
64 Bar_number_engraver::Bar_number_engraver ()
70 Bar_number_engraver::initialize ()
73 ugh: need to share code with mark_engraver
75 daddy_trans_l_->set_property ("stavesFound", SCM_EOL);
81 Bar_number_engraver::acknowledge_grob (Grob_info inf)
83 Grob * s = inf.elem_l_;
84 if (Staff_symbol::has_interface (s))
86 SCM sts = get_property ("stavesFound");
87 SCM thisstaff = inf.elem_l_->self_scm ();
88 if (scm_memq (thisstaff, sts) == SCM_BOOL_F)
89 daddy_trans_l_->set_property ("stavesFound", gh_cons (thisstaff, sts));
92 && dynamic_cast<Item*> (s)
93 && s->get_grob_property ("break-align-symbol") == ly_symbol2scm ("Left_edge_item"))
96 By default this would land on the Paper_column -- so why
97 doesn't it work when you leave this out? */
98 text_p_->set_parent (s, X_AXIS);
103 Bar_number_engraver::stop_translation_timestep ()
107 text_p_->set_grob_property ("side-support-elements", get_property ("stavesFound"));
108 typeset_grob (text_p_);
115 Bar_number_engraver::create_items ()
120 SCM b = get_property ("BarNumber");
121 text_p_ = new Item (b);
122 Side_position_interface::set_axis (text_p_,Y_AXIS);
124 announce_grob (text_p_, 0);