2 bar-number-engraver.cc -- implement Bar_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.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"
17 TODO: detect the top staff (stavesFound), and acknowledge staff-group
18 system-start-delims. If we find these, and the top staff is in the
19 staff-group, add padding to the bar number.
22 class Bar_number_engraver : public Engraver
27 virtual void stop_translation_timestep ();
28 virtual void acknowledge_grob (Grob_info);
29 virtual void process_music ();
31 TRANSLATOR_DECLARATIONS (Bar_number_engraver);
35 Bar_number_engraver::process_music ()
37 // todo include (&&!time->cadenza_b_)
39 SCM wb = get_property ("whichBar");
41 if (scm_is_string (wb))
43 Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
44 if (mp.main_part_ == Rational (0))
46 SCM bn = get_property ("currentBarNumber");
47 SCM proc = get_property ("barNumberVisibility");
48 if (scm_is_number (bn) && ly_is_procedure (proc)
49 && to_boolean (scm_call_1 (proc, bn)))
54 ("text", scm_makfrom0str (to_string (scm_to_int (bn)).to_str0 ()));
60 Bar_number_engraver::Bar_number_engraver ()
66 Bar_number_engraver::acknowledge_grob (Grob_info inf)
68 Grob *s = inf.grob ();
70 && dynamic_cast<Item *> (s)
71 && s->get_property ("break-align-symbol") == ly_symbol2scm ("left-edge"))
74 By default this would land on the Paper_column -- so why
75 doesn't it work when you leave this out? */
76 text_->set_parent (s, X_AXIS);
81 Bar_number_engraver::stop_translation_timestep ()
85 text_->set_object ("side-support-elements",
86 grob_list_to_grob_array (get_property ("stavesFound")));
92 Bar_number_engraver::create_items ()
97 text_ = make_item ("BarNumber", SCM_EOL);
98 Side_position_interface::set_axis (text_, Y_AXIS);
101 ADD_TRANSLATOR (Bar_number_engraver,
102 /* descr */ "A bar number is created whenever measurePosition is zero. It is\n"
103 "put on top of all staves, and appears only at left side of the staff. "
104 "The staves are taken from @code{stavesFound}, which is maintained by "
105 "@code{@ref{Staff_collecting_engraver}}. ",
107 /* creats*/ "BarNumber",
109 /* acks */ "break-aligned-interface",
110 /* reads */ "currentBarNumber stavesFound barNumberVisibility",