]> git.donarmstrong.com Git - lilypond.git/commitdiff
Let Chord_name_engraver record lastChord in internal context property
authorDavid Kastrup <dak@gnu.org>
Mon, 3 Feb 2014 22:16:13 +0000 (23:16 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 8 Feb 2014 10:42:45 +0000 (11:42 +0100)
Using a context property instead of an engraver-internal variable
allows for more flexible behavior of identical chord suppression.

lily/chord-name-engraver.cc
scm/define-context-properties.scm

index 59efe683541c8b42ef41dc16d5cbb2c1bbae89cc..0057176a9f761c5f6bce9bc17ff419d2a3459c46 100644 (file)
@@ -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<Stream_event *> 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 "
                );
index 7960246d98ac3026668e6dc2e2d7540da7dbb9cf..06f307b8438d4a8500dbb0fe44152de1df88edfd 100644 (file)
@@ -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