2 chord-name-engraver.cc -- implement Chord_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "chord-name.hh"
12 #include "musical-request.hh"
13 #include "paper-def.hh"
14 #include "font-interface.hh"
15 #include "paper-def.hh"
17 #include "dimensions.hh"
20 #include "protected-scm.hh"
22 class Chord_name_engraver : public Engraver
25 Chord_name_engraver ();
26 VIRTUAL_COPY_CONS (Translator);
29 virtual void do_pre_move_processing ();
30 virtual void acknowledge_element (Score_element_info i);
31 void deprecated_process_music ();
32 virtual bool do_try_music (Music *);
35 void add_note (Note_req *);
39 Protected_scm last_chord_;
42 ADD_THIS_TRANSLATOR (Chord_name_engraver);
44 Chord_name_engraver::Chord_name_engraver ()
47 chord_ = gh_cons (SCM_EOL, gh_cons (SCM_EOL, SCM_EOL));
48 last_chord_ = gh_cons (SCM_EOL, gh_cons (SCM_EOL, SCM_EOL));
52 Chord_name_engraver::add_note (Note_req* n)
54 SCM pitches = gh_car (chord_);
55 SCM modifiers = gh_cdr (chord_);
56 SCM inversion = modifiers == SCM_EOL ? SCM_EOL : gh_car (modifiers);
57 SCM bass = modifiers == SCM_EOL ? SCM_EOL : gh_cdr (modifiers);
59 if (n->get_mus_property ("inversion") == SCM_BOOL_T)
60 inversion = n->get_mus_property ("pitch");
61 else if (n->get_mus_property ("bass") == SCM_BOOL_T)
62 bass = n->get_mus_property ("pitch");
64 pitches = scm_sort_list (gh_cons (n->get_mus_property ("pitch"), pitches),
66 chord_ = gh_cons (pitches, gh_cons (inversion, bass));
70 Chord_name_engraver::do_try_music (Music* m)
72 if (Note_req* n = dynamic_cast<Note_req*> (m))
80 /* Uh, if we do acknowledge_element, shouldn't we postpone
81 deprecated_process_music until do_process_acknowlegded?
83 Sigh, I can *never* remember how this works, can't we
84 possibly-please just number these functions:
90 deprecated_process_music3 (or is it acknowledge_element3 ?)
97 and what was the deal with this ``do'' prefix again? */
99 Chord_name_engraver::acknowledge_element (Score_element_info i)
101 if (Note_req* n = dynamic_cast<Note_req*> (i.req_l_))
106 Chord_name_engraver::deprecated_process_music ()
108 if (!chord_name_p_ && gh_car (chord_) != SCM_EOL)
111 bool find_inversion_b = false;
112 SCM chord_inversion = get_property ("chordInversion");
113 if (gh_boolean_p (chord_inversion))
114 find_inversion_b = gh_scm2bool (chord_inversion);
116 chord_ = Chord::pitches_and_requests_to_chord (pitches_,
123 chord_name_p_ = new Item (get_property ("ChordName"));
124 chord_name_p_->set_elt_property ("chord", chord_);
125 announce_element (chord_name_p_, 0);
126 SCM s = get_property ("drarnChords"); //FIXME!
127 if (to_boolean (s) && last_chord_ != SCM_EOL &&
128 gh_equal_p (chord_, last_chord_))
129 chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T);
134 Chord_name_engraver::do_pre_move_processing ()
138 typeset_element (chord_name_p_);
142 last_chord_ = chord_;
143 chord_ = gh_cons (SCM_EOL, gh_cons (SCM_EOL, SCM_EOL));