2 mark-engraver.cc -- implement Metronome_mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2007 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "engraver.hh"
15 #include "duration.hh"
16 #include "grob-array.hh"
18 #include "stream-event.hh"
19 #include "text-interface.hh"
21 #include "translator.icc"
24 put stuff over or next to bars. Examples: bar numbers, marginal notes,
27 class Metronome_mark_engraver : public Engraver
30 TRANSLATOR_DECLARATIONS (Metronome_mark_engraver);
40 virtual void derived_mark () const;
41 void stop_translation_timestep ();
42 void process_music ();
45 Metronome_mark_engraver::Metronome_mark_engraver ()
48 last_duration_ = SCM_EOL;
49 last_count_ = SCM_EOL;
53 Metronome_mark_engraver::derived_mark () const
55 scm_gc_mark (last_count_);
56 scm_gc_mark (last_duration_);
57 scm_gc_mark (last_text_);
61 Metronome_mark_engraver::stop_translation_timestep ()
65 Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"));
66 text_->set_parent (mc, X_AXIS);
67 text_->set_object ("side-support-elements",
68 grob_list_to_grob_array (get_property ("stavesFound")));
74 Metronome_mark_engraver::process_music ()
76 SCM count = get_property ("tempoUnitCount");
77 SCM duration = get_property ("tempoUnitDuration");
78 SCM text = get_property ("tempoText");
80 if ( ( (unsmob_duration (duration) && scm_is_number (count))
81 || Text_interface::is_markup (text) )
82 && !(ly_is_equal (count, last_count_)
83 && ly_is_equal (duration, last_duration_)
84 && ly_is_equal (text, last_text_)))
86 text_ = make_item ("MetronomeMark", SCM_EOL);
88 SCM proc = get_property ("metronomeMarkFormatter");
89 SCM result = scm_call_4 (proc,
93 context ()->self_scm ());
95 text_->set_property ("text", result);
98 last_duration_ = duration;
103 ADD_TRANSLATOR (Metronome_mark_engraver,
105 "Engrave metronome marking. This delegates the formatting"
106 " work to the function in the @code{metronomeMarkFormatter}"
107 " property. The mark is put over all staves. The staves are"
108 " taken from the @code{stavesFound} property, which is"
109 " maintained by @ref{Staff_collecting_engraver}.",
116 "metronomeMarkFormatter "