2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "rhythmic-head.hh"
9 #include "paper-def.hh"
10 #include "musical-request.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
15 #include "engraver.hh"
21 class Note_heads_engraver : public Engraver
23 Link_array<Item> notes_;
25 Link_array<Item> dots_;
26 Link_array<Music> note_reqs_;
29 TRANSLATOR_DECLARATIONS(Note_heads_engraver);
32 virtual void start_translation_timestep ();
33 virtual bool try_music (Music *req) ;
34 virtual void process_music ();
36 virtual void stop_translation_timestep ();
42 Note_heads_engraver::Note_heads_engraver()
48 Note_heads_engraver::try_music (Music *m)
50 if (m->is_mus_type ("note-event"))
55 else if (m->is_mus_type ("busy-playing-event"))
56 return note_reqs_.size ();
57 else if (m->is_mus_type ("abort-event"))
61 else if (m->is_mus_type ("ligature-event"))
64 Urg ; this is not protocol. We should accept and return
67 in_ligature = (m->get_mus_property("span-direction")
68 == gh_int2scm (START));
76 Note_heads_engraver::process_music ()
78 for (int i=0; i < note_reqs_.size (); i++)
81 new Item (get_property ((in_ligature) ? "LigatureHead" : "NoteHead"));
83 Music * req = note_reqs_[i];
85 Duration dur = *unsmob_duration (req->get_mus_property ("duration"));
87 note->set_grob_property ("duration-log", gh_int2scm (dur.duration_log ()));
91 Item * d = new Item (get_property ("Dots"));
92 Rhythmic_head::set_dots (note, d);
95 != gh_scm2int (d->get_grob_property ("dot-count")))
96 d->set_grob_property ("dot-count", gh_int2scm (dur.dot_count ()));
98 d->set_parent (note, Y_AXIS);
99 announce_grob (d, SCM_EOL);
103 Pitch *pit =unsmob_pitch (req->get_mus_property ("pitch"));
105 int pos = pit->steps ();
106 SCM c0 = get_property ("centralCPosition");
107 if (gh_number_p (c0))
108 pos += gh_scm2int (c0);
110 note->set_grob_property ("staff-position", gh_int2scm (pos));
111 announce_grob (note,req->self_scm());
117 Note_heads_engraver::stop_translation_timestep ()
119 for (int i=0; i < notes_.size (); i++)
121 typeset_grob (notes_[i]);
125 for (int i=0; i < dots_.size (); i++)
127 typeset_grob (dots_[i]);
134 Note_heads_engraver::start_translation_timestep ()
139 ENTER_DESCRIPTION(Note_heads_engraver,
140 /* descr */ "Generate noteheads (also serves a double functions: makes ligatures.",
141 /* creats*/ "NoteHead LigatureHead Dots",
142 /* accepts */ "note-event busy-playing-event ligature-event abort-event",
144 /* reads */ "centralCPosition",