Hi Jim, On Mon, Apr 27, 2015 at 3:55 PM, Jim Long <lilyp...@umpquanet.com> wrote:
> On Mon, Apr 27, 2015 at 04:44:52PM +0200, Urs Liska wrote: > > > > What we have in Frescobaldi depends on what we can "catch" by either > > listening through engravers or by redefining command. So far I haven't > > found a notion of a grob knowing if it has been tweaked or not. > > As a Scheme/Lilypond novice sitting on the sidelines, I have a > difficult time judging whether my comments are obvious, stupid, > trival, useless, impractical, or some exquisite combination of all > five, but .... (oh, and there's "poorly thought-out") > Not at all ! > > If the grob doesn't know whether it's been tweaked, then perhaps > \tweak could do it? Of course, if a grob could know that it's been tweaked--info stored in a new property 'tweaked--then it would be a simple matter harvesting them. > Or, perhaps one could create a wrapper directive > \ctweak which invokes \tweak to perform the specific tweak that was > requested, and then \ctweak could also color the grob that got > tweaked? Having to change one's code from tweak to ctweak and back > may be less than ideal. Perhaps a global variable (ugh) could be > used by \ctweak, defaulting to black, so that by default \tweak > and \ctweak are equivalent, except that a user of \ctweak could > alter the global color variable to something other than black, > resulting in all the \ctweaks appearing in that color. > Sure you could do something like this sketch which handles [\once] \override and \revert: : \version "2.19" override-color = #red show-colors = ##t coverride = #(define-music-function (parser location arg value) (symbol-list-or-symbol? scheme?) (if show-colors (let* ((path-len (length arg)) (context (if (= path-len 3) (car arg) '())) (grob (if (null? context) (car arg) (cadr arg))) (color-path (if (null? context) (list grob 'color) (list context grob 'color)))) #{ \override #color-path = #override-color \override #arg = #value #}) #{ #})) crevert = #(define-music-function (parser location arg) (symbol-list-or-symbol?) (if show-colors (let* ((path-len (length arg)) (context (if (= path-len 3) (car arg) '())) (grob (if (null? context) (car arg) (cadr arg))) (color-path (if (null? context) (list grob 'color) (list context grob 'color)))) #{ \revert #color-path \revert #arg #}) #{ #})) { \coverride Stem.thickness 3 c'' \crevert Stem.thickness c'' \once \coverride Stem.thickness 5 c' c' } ( There's a more sophisticated way to go about getting a grob's "property path" and checking its validity.) > > I can't think offhand how to extend this to support users who use > a color other than black as the base color for engraved grobs, or > for how to show tweaked grobs which already use \ctweak's global > tweak color. But if \tweak is defined in terms of Scheme/Guile > code (I'm ignorant on that point), perhaps a Scheme guru can > write a first-order approximation of \ctweak that could be > included in any project's source code where it is desired. > > A deeper change might be to add a property to all grobs that > contains a tweak-count, initialized to 0. \tweak would increment > the count of each grob it touches, and then the grobs would know > whether they've been tweaked or not. Pretty sure this is the > "obvious" option in paragraph 1. Sure, or store the property path of the tweak instead of a simple count. David
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user