2 custos-engraver.cc -- implement Custos_engraver
4 source file of the GNU LilyPond music typesetter
6 (C) 2000 Juergen Reuter <reuterj@ira.uka.de>,
8 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "engraver.hh"
15 #include "note-head.hh"
16 #include "staff-symbol-referencer.hh"
18 #include "musical-request.hh"
21 This class implements an engraver for custos symbols.
23 class Custos_engraver : public Engraver
27 virtual void start_translation_timestep();
28 virtual void acknowledge_grob(Grob_info);
29 void deprecated_process_music ();
30 virtual void create_grobs ();
31 virtual void stop_translation_timestep ();
32 virtual void do_removal_processing ();
33 VIRTUAL_COPY_CONS(Translator);
36 Item * create_custos();
37 bool custos_permitted;
38 Link_array<Grob> custos_arr_;
39 Array<Pitch> pitches_;
42 Custos_engraver::Custos_engraver ()
44 custos_permitted = false;
49 Custos_engraver::stop_translation_timestep()
52 delay typeset until we're at the next moment, so we can silence custodes at the end of the piece.
57 Custos_engraver::start_translation_timestep ()
59 for (int i = custos_arr_.size (); i--;)
61 typeset_grob (custos_arr_[i]);
66 custos_permitted = false;
71 TODO check if this works with forced bar lines?
74 Custos_engraver::deprecated_process_music ()
76 if (gh_string_p (get_property( "whichBar")))
77 custos_permitted = true;
81 Custos_engraver::acknowledge_grob (Grob_info info)
83 Item *item = dynamic_cast <Item *>(info.elem_l_);
86 if (Bar::has_interface (info.elem_l_))
87 custos_permitted = true;
88 else if (Note_head::has_interface (info.elem_l_))
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 Note_req * nr = dynamic_cast<Note_req*> (info.req_l_);
101 pitches_.push (*unsmob_pitch (nr->get_mus_property ("pitch")));
107 Custos_engraver::create_grobs ()
109 deprecated_process_music ();
111 if (custos_permitted)
113 for (int i = pitches_.size (); i--;)
115 Item *c = create_custos ();
117 c->set_grob_property ("staff-position",
118 gh_int2scm (pitches_[i].steps ()));
127 Custos_engraver::create_custos()
129 SCM basicProperties = get_property ("Custos");
130 Item* custos = new Item (basicProperties);
132 announce_grob (custos, 0);
133 custos_arr_.push (custos);
139 Custos_engraver::do_removal_processing ()
141 for (int i = custos_arr_.size (); i--;)
143 custos_arr_[i]->suicide ();
144 typeset_grob (custos_arr_[i]);
146 custos_arr_.clear ();
149 ADD_THIS_TRANSLATOR (Custos_engraver);