2 bar-number-engraver.cc -- implement Bar_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "paper-column.hh"
10 #include "output-def.hh"
11 #include "side-position-interface.hh"
12 #include "engraver.hh"
14 #include "grob-array.hh"
16 #include "translator.icc"
19 TODO: detect the top staff (stavesFound), and acknowledge staff-group
20 system-start-delims. If we find these, and the top staff is in the
21 staff-group, add padding to the bar number.
24 class Bar_number_engraver : public Engraver
29 void stop_translation_timestep ();
30 DECLARE_ACKNOWLEDGER (break_aligned);
31 DECLARE_ACKNOWLEDGER (break_alignment);
32 void process_music ();
34 TRANSLATOR_DECLARATIONS (Bar_number_engraver);
38 Bar_number_engraver::process_music ()
40 // todo include (&&!time->cadenza_b_)
42 SCM wb = get_property ("whichBar");
44 if (scm_is_string (wb))
46 Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
47 if (mp.main_part_ == Rational (0))
49 SCM bn = get_property ("currentBarNumber");
50 SCM proc = get_property ("barNumberVisibility");
51 if (scm_is_number (bn) && ly_is_procedure (proc)
52 && to_boolean (scm_call_1 (proc, bn)))
57 ("text", scm_number_to_string (bn, scm_from_int (10)));
63 Bar_number_engraver::Bar_number_engraver ()
70 see rehearsal mark comments.
73 Bar_number_engraver::acknowledge_break_aligned (Grob_info inf)
75 Grob *s = inf.grob ();
77 && !text_->get_parent (X_AXIS)
78 && dynamic_cast<Item *> (s)
79 && (s->get_property_data (ly_symbol2scm ("break-align-symbol"))
80 == text_->get_property_data (ly_symbol2scm ("break-align-symbol"))))
83 By default this would land on the Paper_column -- so why
84 doesn't it work when you leave this out? */
85 text_->set_parent (s, X_AXIS);
91 Bar_number_engraver::acknowledge_break_alignment (Grob_info inf)
93 Grob *s = inf.grob ();
95 && dynamic_cast<Item *> (s))
97 text_->set_parent (s, X_AXIS);
102 Bar_number_engraver::stop_translation_timestep ()
106 text_->set_object ("side-support-elements",
107 grob_list_to_grob_array (get_property ("stavesFound")));
113 Bar_number_engraver::create_items ()
118 text_ = make_item ("BarNumber", SCM_EOL);
122 ADD_ACKNOWLEDGER(Bar_number_engraver,break_aligned);
123 ADD_ACKNOWLEDGER(Bar_number_engraver,break_alignment);
125 ADD_TRANSLATOR (Bar_number_engraver,
126 /* doc */ "A bar number is created whenever measurePosition "
127 "is zero and when there is a bar line (ie. when @code{whichBar} is set. "
129 "put on top of all staves, and appears only at left side of the staff. "
130 "The staves are taken from @code{stavesFound}, which is maintained by "
131 "@code{@ref{Staff_collecting_engraver}}. ",
133 /* create */ "BarNumber",
139 "barNumberVisibility ",