[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Naming callback generators for grobs
From: |
David Kastrup |
Subject: |
Naming callback generators for grobs |
Date: |
Thu, 14 Aug 2014 17:28:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
Sorry for being a few days late with this call for comments.
Please take a look at
<URL:https://code.google.com/p/lilypond/issues/detail?id=4045>. The
issue is that we have a number of grob callback generators that create a
callback for some grob property.
Issue 4045 is about renaming one of them. You may want to take a look
at the proposal in the code review. Basically I am waffling back and
forth over several proposals.
Here are, as far as I can see, the current relevant callback generators:
(define ((grob::calc-property-by-copy prop) grob)
(ly:event-property (event-cause grob) prop))
So calling grob::calc-property-by-copy with the name of a property
returns a function which, when called with a grob as argument, will look
up the event-cause of the grob and take the named property from that
event.
Then there is
(define ((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."
Some uses are in scm/define-grobs.scm, stuff like
scm/define-grobs.scm: (text . ,(grob::calc-property-by-copy 'text))
scm/define-grobs.scm: (X-offset . ,(grob::calc-property-by-copy
'X-offset))
scm/define-grobs.scm: (Y-offset . ,(grob::calc-property-by-copy
'Y-offset))
scm/define-grobs.scm: (transparent . ,(grob::inherit-parent-property
scm/define-grobs.scm- X 'transparent))
scm/define-grobs.scm: (break-visibility . ,(grob::inherit-parent-property
scm/define-grobs.scm- X 'break-visibility))
scm/define-grobs.scm: (color . ,(grob::inherit-parent-property
scm/define-grobs.scm- X 'color))
There is no particular reason that the referenced property and the grob
property calculated via a callback needs to be the same, though it will
in practice be more often than not the case.
For grob::calc-property-by-copy a few names were bounced around in the
Rietveld discussion. My last proposal regarding
grob::calc-property-by-copy were grob::from-event-property and
grob::event-property-getter. An intermediate proposal was just
grob::event-property but that is less likely to be expected returning a
callback procedure rather than a property.
What do you think?
Obviously, the same naming would want to get applied to
grob::inherit-parent-property which currently is named completely
differently.
--
David Kastrup
- Naming callback generators for grobs,
David Kastrup <=