2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "rhythmic-head.hh"
9 #include "paper-def.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
15 #include "engraver.hh"
23 * TODO: junk bool in_ligature (and all the messy code around it).
24 * This can be done by also junking LigatureHead in
25 * scm/grob-description.scm. Instead, NoteHead should be used
26 * throughout typesetting of ligatures; ligature-(start/stop)-events
27 * should simply modify NoteHead properties values of
28 * molecule-callback ligature-primitive-callback. --jr
30 class Note_heads_engraver : public Engraver
32 Link_array<Item> notes_;
34 Link_array<Item> dots_;
35 Link_array<Music> note_reqs_;
38 TRANSLATOR_DECLARATIONS(Note_heads_engraver);
41 virtual void start_translation_timestep ();
42 virtual bool try_music (Music *req) ;
43 virtual void process_music ();
45 virtual void stop_translation_timestep ();
51 Note_heads_engraver::Note_heads_engraver()
57 Note_heads_engraver::try_music (Music *m)
59 if (m->is_mus_type ("note-event"))
64 else if (m->is_mus_type ("busy-playing-event"))
65 return note_reqs_.size ();
66 else if (m->is_mus_type ("abort-event"))
70 else if (m->is_mus_type ("ligature-event"))
73 Urg ; this is not protocol. We should accept and return
76 in_ligature = (to_dir (m->get_mus_property("span-direction")) == START);
85 Note_heads_engraver::process_music ()
87 for (int i=0; i < note_reqs_.size (); i++)
90 new Item (get_property ((in_ligature) ? "LigatureHead" : "NoteHead"));
92 Music * req = note_reqs_[i];
94 Duration dur = *unsmob_duration (req->get_mus_property ("duration"));
96 note->set_grob_property ("duration-log", gh_int2scm (dur.duration_log ()));
100 Item * d = new Item (get_property ("Dots"));
101 Rhythmic_head::set_dots (note, d);
104 != gh_scm2int (d->get_grob_property ("dot-count")))
105 d->set_grob_property ("dot-count", gh_int2scm (dur.dot_count ()));
107 d->set_parent (note, Y_AXIS);
108 announce_grob (d, SCM_EOL);
112 Pitch *pit =unsmob_pitch (req->get_mus_property ("pitch"));
114 int pos = pit->steps ();
115 SCM c0 = get_property ("centralCPosition");
116 if (gh_number_p (c0))
117 pos += gh_scm2int (c0);
119 note->set_grob_property ("staff-position", gh_int2scm (pos));
120 announce_grob (note,req->self_scm());
126 Note_heads_engraver::stop_translation_timestep ()
128 for (int i=0; i < notes_.size (); i++)
130 typeset_grob (notes_[i]);
134 for (int i=0; i < dots_.size (); i++)
136 typeset_grob (dots_[i]);
143 Note_heads_engraver::start_translation_timestep ()
148 ENTER_DESCRIPTION(Note_heads_engraver,
149 /* descr */ "Generate noteheads (also serves a double functions: makes ligatures.",
150 /* creats*/ "NoteHead LigatureHead Dots",
151 /* accepts */ "note-event busy-playing-event ligature-event abort-event",
153 /* reads */ "centralCPosition",