lilypond-1.3.4
[lilypond.git] / lily / chord-name-engraver.cc
blob21f0a99f1ad7f4fa239b76293bc60574e0ba0233
1 /*
2 chord-name-engraver.cc -- implement Chord_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "chord-name-engraver.hh"
10 #include "chord.hh"
11 #include "musical-request.hh"
12 #include "paper-def.hh"
13 #include "lookup.hh"
14 #include "paper-def.hh"
15 #include "main.hh"
16 #include "dimensions.hh"
17 #include "text-item.hh"
19 ADD_THIS_TRANSLATOR (Chord_name_engraver);
21 Chord_name_engraver::Chord_name_engraver ()
23 chord_p_ = 0;
24 tonic_req_ = 0;
25 inversion_req_ = 0;
26 bass_req_ = 0;
29 void
30 Chord_name_engraver::acknowledge_element (Score_element_info i)
32 if (Note_req* n = dynamic_cast<Note_req*> (i.req_l_))
33 pitch_arr_.push (n->pitch_);
36 bool
37 Chord_name_engraver::do_try_music (Music* m)
39 if (Note_req* n = dynamic_cast<Note_req*> (m))
41 pitch_arr_.push (n->pitch_);
42 return true;
44 if (Tonic_req* t = dynamic_cast<Tonic_req*> (m))
46 tonic_req_ = t;
47 return true;
49 if (Inversion_req* i = dynamic_cast<Inversion_req*> (m))
51 inversion_req_ = i;
52 return true;
54 if (Bass_req* b = dynamic_cast<Bass_req*> (m))
56 bass_req_ = b;
57 return true;
59 return false;
62 void
63 Chord_name_engraver::do_process_requests ()
65 if (chord_p_)
66 return;
67 if (!pitch_arr_.size ())
68 return;
70 bool find_inversion_b = false;
71 SCM chord_inversion = get_property ("chordInversion", 0);
72 if (gh_boolean_p (chord_inversion))
73 find_inversion_b = gh_scm2bool (chord_inversion);
75 chord_p_ = new Chord (to_chord (pitch_arr_, tonic_req_, inversion_req_, bass_req_, find_inversion_b));
77 announce_element (Score_element_info (chord_p_, 0));
80 void
81 Chord_name_engraver::do_pre_move_processing ()
83 if (chord_p_)
85 typeset_element (chord_p_);
87 pitch_arr_.clear ();
88 chord_p_ = 0;
89 tonic_req_ = 0;
90 inversion_req_ = 0;
91 bass_req_ = 0;