X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fchord-name-engraver.cc;h=aa5c6f27ee4309fb562127b14eb04854562696c6;hb=refs%2Ftags%2Frelease%2F1.3.104;hp=fcc6031cbb2224fe5acfa882fcf38674e8fbbca0;hpb=b2cc0ee8300845fbe604b408adb597247464acc9;p=lilypond.git diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index fcc6031cbb..aa5c6f27ee 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -3,18 +3,44 @@ source file of the GNU LilyPond music typesetter - (c) 1998--1999 Jan Nieuwenhuizen + (c) 1998--2000 Jan Nieuwenhuizen */ -#include "chord-name-engraver.hh" +#include "engraver.hh" #include "chord-name.hh" +#include "chord.hh" #include "musical-request.hh" #include "paper-def.hh" -#include "lookup.hh" +#include "font-interface.hh" #include "paper-def.hh" #include "main.hh" #include "dimensions.hh" -#include "text-item.hh" +#include "item.hh" +#include "musical-pitch.hh" + +class Chord_name_engraver : public Engraver +{ +public: + Chord_name_engraver (); + VIRTUAL_COPY_CONS (Translator); + +protected: + virtual void do_pre_move_processing (); + virtual void acknowledge_element (Score_element_info i); + virtual void do_process_music (); + virtual bool do_try_music (Music* m); + +private: + void create_chord_name (); + + Array pitch_arr_; + Item* chord_name_p_; + Chord* chord_p_; + Chord* last_chord_p_; + Tonic_req* tonic_req_; + Inversion_req* inversion_req_; + Bass_req* bass_req_; +}; ADD_THIS_TRANSLATOR (Chord_name_engraver); @@ -24,6 +50,8 @@ Chord_name_engraver::Chord_name_engraver () tonic_req_ = 0; inversion_req_ = 0; bass_req_ = 0; + chord_p_ = 0; + last_chord_p_ = 0; } void @@ -60,21 +88,49 @@ Chord_name_engraver::do_try_music (Music* m) } void -Chord_name_engraver::do_process_requests () +Chord_name_engraver::do_process_music () { if (chord_name_p_) return; + if (!pitch_arr_.size ()) return; bool find_inversion_b = false; - SCM chord_inversion = get_property ("chordInversion", 0); + SCM chord_inversion = get_property ("chordInversion"); if (gh_boolean_p (chord_inversion)) find_inversion_b = gh_scm2bool (chord_inversion); - chord_name_p_ = new Chord_name (to_chord (pitch_arr_, tonic_req_, inversion_req_, bass_req_, find_inversion_b)); - - announce_element (Score_element_info (chord_name_p_, 0)); + chord_p_ = new Chord (to_chord (pitch_arr_, + tonic_req_, inversion_req_, bass_req_, + find_inversion_b)); + + create_chord_name (); + announce_element (chord_name_p_, 0); + SCM s = get_property ("drarnChords"); //FIXME! + if (to_boolean (s) && last_chord_p_ && !compare (chord_p_, last_chord_p_)) + chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T); +} + +void +Chord_name_engraver::create_chord_name () +{ + assert (chord_p_); + chord_name_p_ = new Item (get_property ("ChordName")); + /* + Hmm, why not represent complete chord as list? + ((tonic third fifth) (inversion bass)) + */ + SCM plist = SCM_EOL; + for (int i= chord_p_->pitch_arr_.size (); i--; ) + plist = gh_cons (chord_p_->pitch_arr_[i].to_scm (), plist); + + chord_name_p_->set_elt_property ("pitches", plist); + if (chord_p_->inversion_b_) + chord_name_p_->set_elt_property ("inversion", + chord_p_->inversion_pitch_.to_scm ()); + if (chord_p_->bass_b_) + chord_name_p_->set_elt_property ("bass", chord_p_->bass_pitch_.to_scm ()); } void @@ -89,5 +145,8 @@ Chord_name_engraver::do_pre_move_processing () tonic_req_ = 0; inversion_req_ = 0; bass_req_ = 0; + delete last_chord_p_; + last_chord_p_ = chord_p_; + chord_p_ = 0; }