]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tweak-engraver.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / tweak-engraver.cc
index 774664072ccb6b48af41243ebff9cd4cafa9622e..a2a3b6592213dc773afe9ea686c76d85057ce2dc 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2005--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -39,28 +39,60 @@ Tweak_engraver::Tweak_engraver ()
 void
 Tweak_engraver::acknowledge_grob (Grob_info info)
 {
-  if (Stream_event *ev = info.event_cause ())
+  Stream_event *ev = info.event_cause ();
+  bool direct = ev;
+  SCM grobname = SCM_UNDEFINED;
+  if (!direct)
+    ev = info.ultimate_event_cause ();
+  if (ev)
     {
+      // Each tweak conses an address and a value.
+      // The address has one of the following forms:
+      // symbol -> direct tweak
+      // (grob . symbol) -> targeted tweak
+      // (#t . symbol-path) -> direct nested tweak
+      // (grob . symbol-path) -> targeted nested tweak
       for (SCM s = ev->get_property ("tweaks");
-          scm_is_pair (s); s = scm_cdr (s))
-       {
-         info.grob ()->set_property (scm_caar (s), scm_cdar (s));
-       }
+           scm_is_pair (s); s = scm_cdr (s))
+        {
+          if (scm_is_pair (scm_caar (s)))
+            {
+              if (scm_is_symbol (scm_caaar (s)))
+                {
+                  if (SCM_UNBNDP (grobname))
+                    grobname = scm_from_locale_symbol
+                      (info.grob ()->name ().c_str ());
+                  if (scm_is_eq (scm_caaar (s), grobname))
+                    {
+                      if (scm_is_symbol (scm_cdaar (s)))
+                        info.grob ()->set_property (scm_cdaar (s), scm_cdar (s));
+                      else
+                        set_nested_property (info.grob (), scm_cdaar (s),
+                                             scm_cdar (s));
+                    }
+                }
+              else if (direct)
+                set_nested_property (info.grob (), scm_cdaar (s),
+                                     scm_cdar (s));
+            }
+          else if (direct)
+            info.grob ()->set_property (scm_caar (s), scm_cdar (s));
+        }
     }
 }
 
 ADD_ACKNOWLEDGER (Tweak_engraver, grob);
 ADD_TRANSLATOR (Tweak_engraver,
-               /* doc */
-               "Read the @code{tweaks} property from the originating event,"
-               " and set properties.",
-               
-               /* create */
-               "",
+                /* doc */
+                "Read the @code{tweaks} property from the originating event,"
+                " and set properties.",
 
-               /* read */
-               "",
+                /* create */
+                "",
 
-               /* write */
-               ""
-               );
+                /* read */
+                "",
+
+                /* write */
+                ""
+               );