2 bar-number-grav.cc -- implement Bar_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 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 do_pre_move_processing ();
28 virtual void acknowledge_element (Score_element_info);
29 virtual void do_creation_processing ();
31 void do_process_music ();
33 VIRTUAL_COPY_CONS(Translator);
34 Bar_number_engraver();
38 Bar_number_engraver::do_process_music ()
40 // todo include (&&!time->cadenza_b_ )
41 SCM bn = get_property("currentBarNumber");
42 SCM smp = get_property ("measurePosition");
43 Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
45 if (gh_number_p (bn) &&
46 !mp && now_mom () > Moment (0))
51 text_p_->set_elt_property ("text",
52 ly_str02scm (to_str (gh_scm2int (bn)).ch_C()));
56 ADD_THIS_TRANSLATOR(Bar_number_engraver);
58 Bar_number_engraver::Bar_number_engraver ()
64 Bar_number_engraver::do_creation_processing ()
67 ugh: need to share code with mark_engraver
69 daddy_trans_l_->set_property ("staffsFound", SCM_EOL);
75 Bar_number_engraver::acknowledge_element (Score_element_info inf)
77 Score_element * s = inf.elem_l_;
78 if (Staff_symbol::has_interface (s))
80 SCM sts = get_property ("staffsFound");
81 SCM thisstaff = inf.elem_l_->self_scm ();
82 if (scm_memq (thisstaff, sts) == SCM_BOOL_F)
83 daddy_trans_l_->set_property ("staffsFound", gh_cons (thisstaff, sts));
86 && dynamic_cast<Item*> (s)
87 && s->get_elt_property ("break-align-symbol") == ly_symbol2scm ("Left_edge_item"))
90 By default this would land on the Paper_column -- so why
91 doesn't it work when you leave this out? */
92 text_p_->set_parent (s, X_AXIS);
97 Bar_number_engraver::do_pre_move_processing ()
101 text_p_->set_elt_property ("side-support-elements", get_property ("staffsFound"));
102 typeset_element (text_p_);
109 Bar_number_engraver::create_items ()
114 SCM b = get_property ("BarNumber");
115 text_p_ = new Item (b);
116 Side_position::set_axis(text_p_,Y_AXIS);
118 announce_element (text_p_, 0);