2 mark-engraver.cc -- implement Metronome_mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "engraver.hh"
15 #include "duration.hh"
16 #include "grob-array.hh"
18 #include "stream-event.hh"
20 #include "translator.icc"
23 put stuff over or next to bars. Examples: bar numbers, marginal notes,
26 class Metronome_mark_engraver : public Engraver
29 TRANSLATOR_DECLARATIONS (Metronome_mark_engraver);
38 virtual void derived_mark () const;
39 void stop_translation_timestep ();
40 void process_music ();
43 Metronome_mark_engraver::Metronome_mark_engraver ()
46 last_duration_ = SCM_EOL;
47 last_count_ = SCM_EOL;
51 Metronome_mark_engraver::derived_mark () const
53 scm_gc_mark (last_count_);
54 scm_gc_mark (last_duration_);
58 Metronome_mark_engraver::stop_translation_timestep ()
62 Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"));
63 text_->set_parent (mc, X_AXIS);
64 text_->set_object ("side-support-elements",
65 grob_list_to_grob_array (get_property ("stavesFound")));
72 Metronome_mark_engraver::process_music ()
74 SCM count = get_property ("tempoUnitCount");
75 SCM duration = get_property ("tempoUnitDuration");
77 if (unsmob_duration (duration)
78 && scm_is_number (count)
79 && !(ly_is_equal (count, last_count_)
80 && ly_is_equal (duration, last_duration_)))
82 text_ = make_item ("MetronomeMark", SCM_EOL);
84 SCM proc = get_property ("metronomeMarkFormatter");
85 SCM result = scm_call_3 (proc,
88 context ()->self_scm ());
90 text_->set_property ("text", result);
93 last_duration_ = duration;
97 ADD_TRANSLATOR (Metronome_mark_engraver,
98 /* doc */ "Engrave metro nome marking. This delegates the formatting work "
99 "to the function in the metronomeMarkFormatter property. "
100 "The mark is put over all staves. "
101 "The staves are taken from the @code{stavesFound} property, "
102 "which is maintained by @code{@ref{Staff_collecting_engraver}}. ",
103 /* create */ "MetronomeMark",
108 "metronomeMarkFormatter "