From: David Kastrup Date: Mon, 3 Feb 2014 22:16:13 +0000 (+0100) Subject: Let Chord_name_engraver record lastChord in internal context property X-Git-Tag: release/2.19.3-1~37 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bb93be473bf1dd481a2e2a3ea53ee3b4cf0a5983;p=lilypond.git Let Chord_name_engraver record lastChord in internal context property Using a context property instead of an engraver-internal variable allows for more flexible behavior of identical chord suppression. --- diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index 59efe68354..0057176a9f 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -39,14 +39,12 @@ protected: void stop_translation_timestep (); void process_music (); virtual void finalize (); - virtual void derived_mark () const; DECLARE_TRANSLATOR_LISTENER (note); DECLARE_TRANSLATOR_LISTENER (rest); private: Item *chord_name_; vector notes_; - SCM last_chord_; Stream_event *rest_event_; }; @@ -55,16 +53,9 @@ Chord_name_engraver::finalize () { } -void -Chord_name_engraver::derived_mark () const -{ - scm_gc_mark (last_chord_); -} - Chord_name_engraver::Chord_name_engraver () { chord_name_ = 0; - last_chord_ = SCM_EOL; rest_event_ = 0; } @@ -148,11 +139,12 @@ Chord_name_engraver::process_music () markup = maybe_markup; SCM chord_changes = get_property ("chordChanges"); - if (to_boolean (chord_changes) && scm_is_pair (last_chord_) - && ly_is_equal (markup, last_chord_)) + SCM last_chord = get_property ("lastChord"); + if (to_boolean (chord_changes) && scm_is_pair (last_chord) + && ly_is_equal (markup, last_chord)) chord_name_->set_property ("begin-of-line-visible", SCM_BOOL_T); - last_chord_ = markup; + context ()->set_property ("lastChord", markup); } IMPLEMENT_TRANSLATOR_LISTENER (Chord_name_engraver, note); @@ -195,9 +187,10 @@ ADD_TRANSLATOR (Chord_name_engraver, "chordNoteNamer " "chordRootNamer " "chordNameExceptions " + "lastChord " "majorSevenSymbol " "noChordSymbol ", /* write */ - "" + "lastChord " ); diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 7960246d98..06f307b843 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -709,6 +709,7 @@ in an axis group.") @code{CommandColumn} contains items that will affect spacing.") + (lastChord ,markup? "Last chord, used for detecting chord changes.") (lastKeySignature ,list? "Last key signature before a key signature change.") (localKeySignature ,list? "The key signature at this point in the