X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fchord-name-engraver.cc;h=44c1333d7a383a333261c813594a87ed03e12b8c;hb=a33165e3b6af2d807d069e6eacd0e220ba2ef68a;hp=a13f527601aa0548c33c1ef70dbe7cce6640dd10;hpb=947454c5cc430a9627262de4f25274a64789d3c2;p=lilypond.git diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index a13f527601..44c1333d7a 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -8,13 +8,11 @@ #include "engraver.hh" #include "chord-name.hh" -#include "event.hh" -#include "paper-def.hh" +#include "output-def.hh" #include "font-interface.hh" -#include "paper-def.hh" +#include "output-def.hh" #include "dimensions.hh" #include "item.hh" -#include "pitch.hh" #include "protected-scm.hh" #include "context.hh" #include "warn.hh" @@ -27,19 +25,27 @@ protected: virtual void process_music (); virtual bool try_music (Music *); virtual void finalize (); + virtual void derived_mark () const; private: void add_note (Music *); Item* chord_name_; Link_array notes_; - Protected_scm last_chord_; + SCM last_chord_; }; + + void Chord_name_engraver::finalize () { - last_chord_ = SCM_EOL; +} + +void +Chord_name_engraver::derived_mark() const +{ + scm_gc_mark (last_chord_); } Chord_name_engraver::Chord_name_engraver () @@ -65,7 +71,7 @@ Chord_name_engraver::process_music () SCM pitches = SCM_EOL; Music* inversion_event = 0; - for (int i =0 ; i < notes_.size (); i++) + for (int i = 0 ; i < notes_.size (); i++) { Music *n = notes_[i]; SCM p = n->get_property ("pitch"); @@ -80,19 +86,19 @@ Chord_name_engraver::process_music () else if (n->get_property ("bass") == SCM_BOOL_T) bass = p; else - pitches = gh_cons (p, pitches); + pitches = scm_cons (p, pitches); } if (inversion_event) { SCM oct = inversion_event->get_property ("octavation"); - if (gh_number_p (oct)) + if (scm_is_number (oct)) { Pitch *p = unsmob_pitch (inversion_event->get_property ("pitch")); - int octavation = gh_scm2int (oct); + int octavation = scm_to_int (oct); Pitch orig = p->transposed (Pitch (-octavation, 0,0)); - pitches= gh_cons (orig.smobbed_copy (), pitches); + pitches = scm_cons (orig.smobbed_copy (), pitches); } else programming_error ("Inversion does not have original pitch."); @@ -102,19 +108,19 @@ Chord_name_engraver::process_music () SCM name_proc = get_property ("chordNameFunction"); SCM markup = scm_call_4 (name_proc, pitches, bass, inversion, - daddy_context_->self_scm ()); + context ()->self_scm ()); /* Ugh. */ - SCM chord_as_scm = gh_cons (pitches, gh_cons (bass, inversion)); + SCM chord_as_scm = scm_cons (pitches, scm_cons (bass, inversion)); - chord_name_ = make_item ("ChordName"); + chord_name_ = make_item ("ChordName",notes_[0]->self_scm ()); chord_name_->set_property ("text", markup); - announce_grob (chord_name_, notes_[0]->self_scm ()); + SCM s = get_property ("chordChanges"); - if (to_boolean (s) && gh_pair_p (last_chord_) - && gh_equal_p (chord_as_scm, last_chord_)) + if (to_boolean (s) && scm_is_pair (last_chord_) + && ly_c_equal_p (chord_as_scm, last_chord_)) chord_name_->set_property ("begin-of-line-visible", SCM_BOOL_T); last_chord_ = chord_as_scm; @@ -137,10 +143,6 @@ Chord_name_engraver::try_music (Music* m) void Chord_name_engraver::stop_translation_timestep () { - if (chord_name_) - { - typeset_grob (chord_name_); - } chord_name_ = 0; notes_.clear (); } @@ -149,7 +151,7 @@ Chord_name_engraver::stop_translation_timestep () The READs description is not strictly accurate: which properties are read depend on the chord naming function active. */ -ENTER_DESCRIPTION (Chord_name_engraver, +ADD_TRANSLATOR (Chord_name_engraver, /* descr */ "Catch note-events " "and generate the appropriate chordname.", /* creats*/ "ChordName",