]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3322: Add callback factory grob::inherit-parent-property
authorDavid Kastrup <dak@gnu.org>
Wed, 17 Apr 2013 14:17:14 +0000 (16:17 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 23 Apr 2013 06:21:47 +0000 (08:21 +0200)
"@var{grob} callback generator for inheriting a @var{property} from
an @var{axis} parent, defaulting to @var{default} if there is no
parent or the parent has no setting."

scm/output-lib.scm

index 4533cf2a965a8c95eb22b3dcf84d21dc2e5ad8f7..f424931c2d410f74c4282a5bcf19b87a1d56e422 100644 (file)
@@ -1099,6 +1099,19 @@ and draws the stencil based on its coordinates.
 (define-public ((grob::calc-property-by-non-event-cause prop) grob)
   (ly:grob-property (non-event-cause grob) prop))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; general inheritance
+
+(define-public ((grob::inherit-parent-property axis property . default) grob)
+  "@var{grob} callback generator for inheriting a @var{property} from
+an @var{axis} parent, defaulting to @var{default} if there is no
+parent or the parent has no setting."
+  (let ((parent (ly:grob-parent grob axis)))
+    (cond
+     ((ly:grob? parent)
+      (apply ly:grob-property parent property default))
+     ((pair? default) (car default))
+     (else '()))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; fret boards