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<Note_req> 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 (Note_req * n =dynamic_cast <Note_req *> (m))
55 else if (dynamic_cast<Busy_playing_req*> (m))
57 return note_reqs_.size ();
59 else if (Span_req *req_ = dynamic_cast<Span_req*> (m))
61 if (scm_equal_p (req_->get_mus_property ("span-type"),
62 scm_makfrom0str ("abort")) == SCM_BOOL_T)
66 else if (scm_equal_p (req_->get_mus_property ("span-type"),
67 scm_makfrom0str ("ligature")) == SCM_BOOL_T)
69 in_ligature = (req_->get_span_dir () == START);
78 Note_heads_engraver::process_music ()
80 for (int i=0; i < note_reqs_.size (); i++)
83 new Item (get_property ((in_ligature) ? "LigatureHead" : "NoteHead"));
85 Music * req = note_reqs_[i];
87 Duration dur = *unsmob_duration (req->get_mus_property ("duration"));
89 note->set_grob_property ("duration-log", gh_int2scm (dur.duration_log ()));
93 Item * d = new Item (get_property ("Dots"));
94 Rhythmic_head::set_dots (note, d);
97 != gh_scm2int (d->get_grob_property ("dot-count")))
98 d->set_grob_property ("dot-count", gh_int2scm (dur.dot_count ()));
100 d->set_parent (note, Y_AXIS);
101 announce_grob (d, SCM_EOL);
105 Pitch *pit =unsmob_pitch (req->get_mus_property ("pitch"));
107 int pos = pit->steps ();
108 SCM c0 = get_property ("centralCPosition");
109 if (gh_number_p (c0))
110 pos += gh_scm2int (c0);
112 note->set_grob_property ("staff-position", gh_int2scm (pos));
113 announce_grob (note,req->self_scm());
119 Note_heads_engraver::stop_translation_timestep ()
121 for (int i=0; i < notes_.size (); i++)
123 typeset_grob (notes_[i]);
127 for (int i=0; i < dots_.size (); i++)
129 typeset_grob (dots_[i]);
137 Note_heads_engraver::start_translation_timestep ()
142 ENTER_DESCRIPTION(Note_heads_engraver,
143 /* descr */ "Generate one or more noteheads from Music of type Note_req.",
144 /* creats*/ "NoteHead Dots",
145 /* accepts */ "general-music",
147 /* reads */ "centralCPosition",