From: David Kastrup Date: Wed, 17 Apr 2013 14:17:14 +0000 (+0200) Subject: Issue 3322: Add callback factory grob::inherit-parent-property X-Git-Tag: release/2.17.17-1~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6c7a171483afdec10d0f6cfeff121c1e1bc9ebd1;p=lilypond.git Issue 3322: Add callback factory grob::inherit-parent-property "@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." --- diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 4533cf2a96..f424931c2d 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -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