Add sol head to shape note heads
[lilypond/mpolesky.git] / lily / metronome-engraver.cc
blob9d585af827c16465d058cd163493993cf1c2d473
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1998--2010 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include <cctype>
21 using namespace std;
23 #include "engraver.hh"
25 #include "context.hh"
26 #include "duration.hh"
27 #include "grob-array.hh"
28 #include "item.hh"
29 #include "stream-event.hh"
30 #include "text-interface.hh"
32 #include "translator.icc"
34 class Metronome_mark_engraver : public Engraver
36 public:
37 TRANSLATOR_DECLARATIONS (Metronome_mark_engraver);
38 protected:
39 Item *text_;
40 Grob *bar_line_;
42 SCM last_duration_;
43 SCM last_count_;
44 SCM last_text_;
46 protected:
47 virtual void derived_mark () const;
48 void stop_translation_timestep ();
49 void process_music ();
52 Metronome_mark_engraver::Metronome_mark_engraver ()
54 text_ = 0;
55 last_duration_ = SCM_EOL;
56 last_count_ = SCM_EOL;
57 last_text_ = SCM_EOL;
60 void
61 Metronome_mark_engraver::derived_mark () const
63 scm_gc_mark (last_count_);
64 scm_gc_mark (last_duration_);
65 scm_gc_mark (last_text_);
68 void
69 Metronome_mark_engraver::stop_translation_timestep ()
71 if (text_)
73 Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"));
74 text_->set_parent (mc, X_AXIS);
75 text_->set_object ("side-support-elements",
76 grob_list_to_grob_array (get_property ("stavesFound")));
77 text_ = 0;
81 void
82 Metronome_mark_engraver::process_music ()
84 SCM count = get_property ("tempoUnitCount");
85 SCM duration = get_property ("tempoUnitDuration");
86 SCM text = get_property ("tempoText");
88 if ( ( (unsmob_duration (duration) && scm_is_number (count))
89 || Text_interface::is_markup (text) )
90 && !(ly_is_equal (count, last_count_)
91 && ly_is_equal (duration, last_duration_)
92 && ly_is_equal (text, last_text_)))
94 text_ = make_item ("MetronomeMark", SCM_EOL);
96 SCM proc = get_property ("metronomeMarkFormatter");
97 SCM result = scm_call_4 (proc,
98 text,
99 duration,
100 count,
101 context ()->self_scm ());
103 text_->set_property ("text", result);
106 last_duration_ = duration;
107 last_count_ = count;
108 last_text_ = text;
111 ADD_TRANSLATOR (Metronome_mark_engraver,
112 /* doc */
113 "Engrave metronome marking. This delegates the formatting"
114 " work to the function in the @code{metronomeMarkFormatter}"
115 " property. The mark is put over all staves. The staves are"
116 " taken from the @code{stavesFound} property, which is"
117 " maintained by @ref{Staff_collecting_engraver}.",
119 /* create */
120 "MetronomeMark ",
122 /* read */
123 "stavesFound "
124 "metronomeMarkFormatter "
125 "tempoUnitDuration "
126 "tempoUnitCount "
127 "tempoText "
128 "tempoHideNote ",
130 /* write */