lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allows user to set ChordName text (issue 6496085)


From: mtsolo
Subject: Re: Allows user to set ChordName text (issue 6496085)
Date: Thu, 06 Sep 2012 09:59:09 +0000

Reviewers: dak,


http://codereview.appspot.com/6496085/diff/1/lily/chord-name-engraver.cc
File lily/chord-name-engraver.cc (right):

http://codereview.appspot.com/6496085/diff/1/lily/chord-name-engraver.cc#newcode83
lily/chord-name-engraver.cc:83: || ly_is_procedure
(chord_name_->get_property ("text")));
On 2012/09/06 08:50:40, dak wrote:
If it is a procedure, shouldn't it be called with the calculated
value?

Right you are - I should have used get_property_data.  Will fix.

http://codereview.appspot.com/6496085/diff/1/lily/chord-name-engraver.cc#newcode149
lily/chord-name-engraver.cc:149: && ly_is_equal (chord_as_scm,
last_chord_))
On 2012/09/06 08:50:40, dak wrote:
If one is doing the chord calculation manually, you can't make the
decision of
whether a chord changed based on the automatic calculation.  For
better or
worse, you need to compare the computed chord versions/text.

To respond to your points above, I don't throw away the values above
because they're used here.  As for the present point, that is an
interesting conundrum...I'll  drum up some logic for that.  That may
eliminate the need for guarding the values above having to do with chord
changes, in which point the if else statement will be able to be
simplified.

Description:
Allows user to set ChordName text

Please review this at http://codereview.appspot.com/6496085/

Affected files:
  A input/regression/chord-name-override-text.ly
  M lily/chord-name-engraver.cc


Index: input/regression/chord-name-override-text.ly
diff --git a/input/regression/chord-name-override-text.ly b/input/regression/chord-name-override-text.ly
new file mode 100644
index 0000000000000000000000000000000000000000..4acd549394eff095065c0b9605473424ef13c649
--- /dev/null
+++ b/input/regression/chord-name-override-text.ly
@@ -0,0 +1,13 @@
+\version "2.17.2"
+
+\header {
+  texidoc = "Users can override the @code{text} property of
address@hidden
+"
+}
+
+\new ChordNames \chordmode {
+  a b c:7
+  \once \override ChordName #'text = #"foo"
+  d
+}
\ No newline at end of file
Index: lily/chord-name-engraver.cc
diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc
index eab4d94d075c52ef95f0ae09449d6d9d184585c5..6aad475ebb5a0f61292a1d58c8fe68aafe64c1c6 100644
--- a/lily/chord-name-engraver.cc
+++ b/lily/chord-name-engraver.cc
@@ -76,7 +76,14 @@ Chord_name_engraver::process_music ()
   SCM inversion = SCM_EOL;
   SCM pitches = SCM_EOL;

-  if (rest_event_)
+  chord_name_ = make_item ("ChordName",
+ rest_event_ ? rest_event_->self_scm () : notes_[0]->self_scm ());
+
+ bool make_markup = !(Text_interface::is_markup (chord_name_->get_property ("text")) + || ly_is_procedure (chord_name_->get_property ("text")));
+
+  if (rest_event_ && !make_markup) { }
+  else if (rest_event_)
     {
       SCM no_chord_markup = get_property ("noChordSymbol");
       if (!Text_interface::is_markup (no_chord_markup))
@@ -125,17 +132,17 @@ Chord_name_engraver::process_music ()
       pitches = scm_sort_list (pitches, Pitch::less_p_proc);

       SCM name_proc = get_property ("chordNameFunction");
-      markup = scm_call_4 (name_proc, pitches, bass, inversion,
-                           context ()->self_scm ());
+      if (make_markup)
+        markup = scm_call_4 (name_proc, pitches, bass, inversion,
+                             context ()->self_scm ());
     }
   /*
     Ugh.
   */
   SCM chord_as_scm = scm_cons (pitches, scm_cons (bass, inversion));

-  chord_name_ = make_item ("ChordName",
- rest_event_ ? rest_event_->self_scm () : notes_[0]->self_scm ());
-  chord_name_->set_property ("text", markup);
+  if (make_markup)
+    chord_name_->set_property ("text", markup);

   SCM chord_changes = get_property ("chordChanges");
   if (to_boolean (chord_changes) && scm_is_pair (last_chord_)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]