Remove unused prototype in score.hh.
[lilypond/mpolesky.git] / lily / mark-engraver.cc
blob657efb9f225c1ad62d7a910dd240b88b9458fe7d
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 "axis-group-interface.hh"
26 #include "bar-line.hh"
27 #include "context.hh"
28 #include "grob-array.hh"
29 #include "international.hh"
30 #include "item.hh"
31 #include "stream-event.hh"
32 #include "text-interface.hh"
33 #include "warn.hh"
35 #include "translator.icc"
37 /**
38 put stuff over or next to bars. Examples: bar numbers, marginal notes,
39 rehearsal marks.
41 class Mark_engraver : public Engraver
44 void create_items (Stream_event *);
45 Item *text_;
46 Item *final_text_;
47 Stream_event *mark_ev_;
49 public:
50 TRANSLATOR_DECLARATIONS (Mark_engraver);
52 protected:
53 void process_music ();
54 void start_translation_timestep ();
55 void stop_translation_timestep ();
56 virtual void finalize ();
58 DECLARE_TRANSLATOR_LISTENER (mark);
59 DECLARE_ACKNOWLEDGER (break_alignment);
62 Mark_engraver::Mark_engraver ()
64 text_ = 0;
65 final_text_ = 0;
66 mark_ev_ = 0;
69 void
70 Mark_engraver::acknowledge_break_alignment (Grob_info inf)
72 Grob *s = inf.grob ();
73 if (text_
74 && dynamic_cast<Item *> (s))
75 text_->set_parent (s, X_AXIS);
78 void
79 Mark_engraver::start_translation_timestep ()
81 final_text_ = 0;
84 void
85 Mark_engraver::stop_translation_timestep ()
87 if (text_)
89 text_->set_object ("side-support-elements",
90 grob_list_to_grob_array (get_property ("stavesFound")));
91 final_text_ = text_;
92 text_ = 0;
94 mark_ev_ = 0;
97 void
98 Mark_engraver::finalize ()
100 if (final_text_)
101 final_text_->set_property ("break-visibility",
102 scm_c_make_vector (3, SCM_BOOL_T));
103 final_text_ = 0;
106 void
107 Mark_engraver::create_items (Stream_event *ev)
109 if (text_)
110 return;
112 text_ = make_item ("RehearsalMark", ev->self_scm ());
115 IMPLEMENT_TRANSLATOR_LISTENER (Mark_engraver, mark);
116 void
117 Mark_engraver::listen_mark (Stream_event *ev)
119 ASSIGN_EVENT_ONCE (mark_ev_, ev);
123 TODO: make the increment function in Scheme.
125 void
126 Mark_engraver::process_music ()
128 if (mark_ev_)
130 create_items (mark_ev_);
133 automatic marks.
136 SCM m = mark_ev_->get_property ("label");
137 SCM proc = get_property ("markFormatter");
138 if (!Text_interface::is_markup (m)
139 && ly_is_procedure (proc))
141 if (!scm_is_number (m))
142 m = get_property ("rehearsalMark");
144 if (scm_integer_p (m) == SCM_BOOL_T
145 && scm_exact_p (m) == SCM_BOOL_T)
147 int mark_count = scm_to_int (m);
148 mark_count++;
149 context ()->set_property ("rehearsalMark",
150 scm_from_int (mark_count));
153 if (scm_is_number (m))
154 m = scm_call_2 (proc, m, context ()->self_scm ());
155 else
156 /* FIXME: constant error message. */
157 warning (_ ("rehearsalMark must have integer value"));
160 if (Text_interface::is_markup (m))
161 text_->set_property ("text", m);
162 else
163 warning (_ ("mark label must be a markup object"));
167 ADD_ACKNOWLEDGER (Mark_engraver, break_alignment);
169 ADD_TRANSLATOR (Mark_engraver,
170 /* doc */
171 "Create @code{RehearsalMark} objects. It puts them on top of"
172 " all staves (which is taken from the property"
173 " @code{stavesFound}). If moving this engraver to a different"
174 " context, @ref{Staff_collecting_engraver} must move along,"
175 " otherwise all marks end up on the same Y@tie{}location.",
177 /* create */
178 "RehearsalMark ",
180 /* read */
181 "markFormatter "
182 "rehearsalMark "
183 "stavesFound ",
185 /* write */