2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2010 Juergen Reuter <reuter@ipd.uka.de>,
5 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "engraver.hh"
22 #include "bar-line.hh"
24 #include "note-head.hh"
26 #include "staff-symbol-referencer.hh"
27 #include "stream-event.hh"
30 #include "translator.icc"
33 * This class implements an engraver for custos symbols.
35 * FIXME: note heads inside of ligatures (i.e. ligature heads) are
36 * sometimes not recognized by this engraver. --jr
38 class Custos_engraver
: public Engraver
41 TRANSLATOR_DECLARATIONS (Custos_engraver
);
42 void start_translation_timestep ();
43 DECLARE_ACKNOWLEDGER (bar
);
44 DECLARE_ACKNOWLEDGER (note_head
);
45 void process_acknowledged ();
46 void stop_translation_timestep ();
47 virtual void finalize ();
50 Item
*create_custos ();
51 bool custos_permitted_
;
52 vector
<Grob
*> custodes_
;
53 vector
<Pitch
> pitches_
;
56 Custos_engraver::Custos_engraver ()
58 custos_permitted_
= false;
62 Custos_engraver::stop_translation_timestep ()
65 delay typeset until we're at the next moment, so we can silence custodes at the end of the piece.
69 custos_permitted_
= false;
73 Custos_engraver::start_translation_timestep ()
79 Custos_engraver::acknowledge_bar (Grob_info
/* info */)
81 custos_permitted_
= true;
85 Custos_engraver::acknowledge_note_head (Grob_info info
)
87 Stream_event
*ev
= info
.event_cause ();
88 if (ev
&& ev
->in_event_class ("note-event"))
92 ideally, we'd do custos->set_parent (Y_AXIS, notehead),
93 but since the note head lives on the other system, we can't
95 So we copy the position from the note head pitch. We
96 don't look at the staff-position, since we can't be sure
97 whether Clef_engraver already applied a vertical shift.
99 pitches_
.push_back (*unsmob_pitch (ev
->get_property ("pitch")));
104 Custos_engraver::process_acknowledged ()
106 if (scm_is_string (get_property ("whichBar")))
107 custos_permitted_
= true;
109 if (custos_permitted_
)
111 for (vsize i
= pitches_
.size (); i
--;)
113 Item
*c
= create_custos ();
115 int p
= pitches_
[i
].steps ();
116 SCM c0
= get_property ("middleCPosition");
117 if (scm_is_number (c0
))
118 p
+= scm_to_int (c0
);
120 c
->set_property ("staff-position",
129 Custos_engraver::create_custos ()
131 Item
*custos
= make_item ("Custos", SCM_EOL
);
133 custodes_
.push_back (custos
);
139 Custos_engraver::finalize ()
141 for (vsize i
= custodes_
.size (); i
--;)
142 custodes_
[i
]->suicide ();
146 ADD_ACKNOWLEDGER (Custos_engraver
, bar
);
147 ADD_ACKNOWLEDGER (Custos_engraver
, note_head
);
149 ADD_TRANSLATOR (Custos_engraver
,