staff-symbol-referencer.cc: Junk redundant functions.
[lilypond.git] / lily / custos-engraver.cc
blobd0546bf65e3ee2749f4a6e0c240afd8088f9ab2d
1 /*
2 custos-engraver.cc -- implement Custos_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Juergen Reuter <reuter@ipd.uka.de>,
7 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "engraver.hh"
11 #include "bar-line.hh"
12 #include "item.hh"
13 #include "note-head.hh"
14 #include "pitch.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "stream-event.hh"
17 #include "warn.hh"
19 #include "translator.icc"
22 * This class implements an engraver for custos symbols.
24 * FIXME: note heads inside of ligatures (i.e. ligature heads) are
25 * sometimes not recognized by this engraver. --jr
27 class Custos_engraver : public Engraver
29 public:
30 TRANSLATOR_DECLARATIONS (Custos_engraver);
31 void start_translation_timestep ();
32 DECLARE_ACKNOWLEDGER (bar);
33 DECLARE_ACKNOWLEDGER (note_head);
34 void process_acknowledged ();
35 void stop_translation_timestep ();
36 virtual void finalize ();
38 private:
39 Item *create_custos ();
40 bool custos_permitted_;
41 vector<Grob*> custodes_;
42 vector<Pitch> pitches_;
45 Custos_engraver::Custos_engraver ()
47 custos_permitted_ = false;
50 void
51 Custos_engraver::stop_translation_timestep ()
54 delay typeset until we're at the next moment, so we can silence custodes at the end of the piece.
56 pitches_.clear ();
58 custos_permitted_ = false;
61 void
62 Custos_engraver::start_translation_timestep ()
64 custodes_.clear ();
67 void
68 Custos_engraver::acknowledge_bar (Grob_info info)
70 (void) info;
71 custos_permitted_ = true;
74 void
75 Custos_engraver::acknowledge_note_head (Grob_info info)
77 Stream_event *ev = info.event_cause ();
78 if (ev && ev->in_event_class ("note-event"))
82 ideally, we'd do custos->set_parent (Y_AXIS, notehead),
83 but since the note head lives on the other system, we can't
85 So we copy the position from the note head pitch. We
86 don't look at the staff-position, since we can't be sure
87 whether Clef_engraver already applied a vertical shift.
89 pitches_.push_back (*unsmob_pitch (ev->get_property ("pitch")));
93 void
94 Custos_engraver::process_acknowledged ()
96 if (scm_is_string (get_property ("whichBar")))
97 custos_permitted_ = true;
99 if (custos_permitted_)
101 for (vsize i = pitches_.size (); i--;)
103 Item *c = create_custos ();
105 int p = pitches_[i].steps ();
106 SCM c0 = get_property ("middleCPosition");
107 if (scm_is_number (c0))
108 p += scm_to_int (c0);
110 c->set_property ("staff-position",
111 scm_from_int (p));
114 pitches_.clear ();
118 Item *
119 Custos_engraver::create_custos ()
121 Item *custos = make_item ("Custos", SCM_EOL);
123 custodes_.push_back (custos);
125 return custos;
128 void
129 Custos_engraver::finalize ()
131 for (vsize i = custodes_.size (); i--;)
132 custodes_[i]->suicide ();
133 custodes_.clear ();
136 ADD_ACKNOWLEDGER (Custos_engraver, bar);
137 ADD_ACKNOWLEDGER (Custos_engraver, note_head);
139 ADD_TRANSLATOR (Custos_engraver,
140 /* doc */
141 "Engrave custodes.",
143 /* create */
144 "Custos ",
146 /* read */
149 /* write */