lilypond-devel
[Top][All Lists]
Advanced

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

Re: Add callback factory grob::inherit-parent-property (issue 8726045)


From: dak
Subject: Re: Add callback factory grob::inherit-parent-property (issue 8726045)
Date: Wed, 17 Apr 2013 18:45:01 +0000

Reviewers: MikeSol,

Message:
On 2013/04/17 18:27:05, MikeSol wrote:
Hey, I hadn't seen this. I just finished writing an equivalent patch.
Yours is
better, so keep it.  You can use this for the
inherit-X-parent-visibility and
eliminate the inherit-Y-parent-visibility callback, which is cruft and
can be
replaced with the X one.

I did not actually replace anything because I was not sure of the intent
of the code matching the actual code.

inherit-x-parent-visibility is used only once, so is
inherent-y-parent-visibility.

Apart from the axis discrepancy, the only visible difference is that
inherit-x-parent-visibility has a default of all-invisible, while
inherit-y-parent-visibility has a default of '() and thus can
distinguish the default use, possibly substituting something else.

I was planning to remove _both_ functions here.  The question is what
call to replace inherit-y-parent-visibility with: use rather the X or Y
axis parent, and which default to use.  I am not familiar with the
footnote code enough to make that decision, so I was planning on leaving
the actual replacement with you.

I think there are several other rarely used callbacks which would
warrant replacing by a call to grob::inherit-parent-property since that
puts the programmer-interesting information right in define-grobs.scm
and does not scatter it to other files.

Description:
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."

Please review this at https://codereview.appspot.com/8726045/

Affected files:
  M scm/output-lib.scm


Index: scm/output-lib.scm
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 4533cf2a965a8c95eb22b3dcf84d21dc2e5ad8f7..f424931c2d410f74c4282a5bcf19b87a1d56e422 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





reply via email to

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