Re: Color tweaks (edition engraver)

2015-05-05 Thread David Nalesnik
Hi Kieren,

On Tue, May 5, 2015 at 8:57 AM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > And it works with that editionEngraver example.
>
> It definitely works with a minimal EE example… Nice work!
>
> However, I added it to my current (definitely non-minimal!) score, and it
> fails with:
>
>   In procedure ly:music-property in expression (ly:music-property
> (ly:event-property cause #) (quote tweaks)):
>   [file-path here] Wrong type argument in position 1 (expecting Music): ()
>
> That line is
>
> #(define (mark-tweak grob)
>  [%%%SNIP%%%]
>  (if (null? diff)
>  (let* ((cause (event-cause grob))
> (tweaks (and cause
>  (ly:music-property%%  THIS ONE
>   (ly:event-property cause 'music-cause)
>   'tweaks
>
> Can’t spend time tracking down the issue further now, but wanted you to
> know.
>
> Thanks!
>

The fix here is no problem.  Quoting just mark-tweak:

 #(define (mark-tweak grob)
   "Color @var{grob} if it has been tweaked.  The color to use is stored
in the global variables @var{override-color} and @var{tweak-color}."
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  ;; We're using after-line-breaking to set color of stencil, but
  ;; let's preserve its last setting
  (after-line-return (assoc-get 'after-line-breaking props))
  ;; Clef.glyph doesn't appear in all-grob-descriptions, but it
  ;; is set at some point automatically.  Don't mark it unless
  ;; it genuinely is a user override.  There may be other
  ;; such grobs.
  (props
   (if (eq? (grob::name grob) 'Clef)
   (reverse (remove-first 'glyph (reverse props)))
   props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob,
but
 ;; we can find them through the music event which led to the grob.
This
 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(music-cause
 (if (ly:stream-event? cause)
 (ly:event-property cause 'music-cause)
 #f))
(tweaks (and (ly:music? music-cause)
 (ly:music-property
  music-cause
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) tweak-color)))
 (set! (ly:grob-property grob 'color) override-color))

 ;; Return any default setting of after-line-breaking.
 after-line-return))

%%%

Thanks for pointing this out!

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-05 Thread Kieren MacMillan
Hi David,

> And it works with that editionEngraver example.

It definitely works with a minimal EE example… Nice work!

However, I added it to my current (definitely non-minimal!) score, and it fails 
with:

  In procedure ly:music-property in expression (ly:music-property 
(ly:event-property cause #) (quote tweaks)):
  [file-path here] Wrong type argument in position 1 (expecting Music): ()

That line is

#(define (mark-tweak grob)
 [%%%SNIP%%%]
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property%%  THIS ONE
  (ly:event-property cause 'music-cause)
  'tweaks

Can’t spend time tracking down the issue further now, but wanted you to know.

Thanks!
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-05 Thread David Nalesnik
On Mon, May 4, 2015 at 10:04 PM, David Nalesnik 
wrote:

> Hi Kieren,
>
> On Sat, May 2, 2015 at 6:29 PM, Kieren MacMillan <
> kieren_macmil...@sympatico.ca> wrote:
>
>> Hi David,
>>
>> > > Out of curiosity, do you get results with color-tweaks2.ly (attached
>> somewhere above)?
>> > Same thing: the EE-added tweak gets executed, but doesn’t appear in the
>> log output.
>> > So it doesn't get colored?
>>
>> Sorry… let me be more clear. I \include-d the edition-engraver, and
>> compiled twice: once with an \editionMod to move the [initial] Clef, and
>> once without. The first time, the Clef moved (as expected) and was coloured
>> (as hoped); the second time, the Clef was neither moved nor coloured (both
>> as expected).
>
>
>> HOWEVER, the console output was identical in both cases: the tweak was
>> not recorded in the output (as I thought it should have been?).
>
>
> OK, then the modifying actual grobs approach is proving to be more useful
> on several counts.
>

And it works with that editionEngraver example.


>
> The attached file contains some improvements over color-tweaks2.ly.  The
> main difference is that it uses a simple Scheme engraver which must be
> \consists-ed.
>
> \voiceTwo and the like will result in colored objects (stems for example),
> but I don't think there's any help for that.  Call it a feature :)
>

oops, forgot the custom color settings.

Anyway, this should do the trick.  Let me know how it works out.

Best,
David

%%

override-color = #darkred

tweak-color = #blue

%tweak-color = #override-color

#(define (remove-first symbol alist)
   "Remove the first key-value pair of association list @var{alist}
whose key matches @var{symbol}."
   (let loop ((alist alist) (result '()))
 (cond
  ((null? alist) result)
  ((eq? (caar alist) symbol)
   (append result (cdr alist)))
  (else (loop (cdr alist)
  (append result (list (car alist

#(define (grob::has-default-prop grob prop)
   "Check all-grob-descriptions to see if symbol @var{grob} has
a default setting for symbol @var{prop}.  Either return the
setting or @code{#f}."
   (let ((description (assoc-get grob all-grob-descriptions)))
 (if description
 (assoc-get 'stencil description

#(define (mark-tweak grob)
   "Color @var{grob} if it has been tweaked.  The color to use is stored
in the global variables @var{override-color} and @var{tweak-color}."
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  ;; We're using after-line-breaking to set color of stencil, but
  ;; let's preserve its last setting
  (after-line-return (assoc-get 'after-line-breaking props))
  ;; Clef.glyph doesn't appear in all-grob-descriptions, but it
  ;; is set at some point automatically.  Don't mark it unless
  ;; it genuinely is a user override.  There may be other
  ;; such grobs.
  (props
   (if (eq? (grob::name grob) 'Clef)
   (reverse (remove-first 'glyph (reverse props)))
   props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob,
but
 ;; we can find them through the music event which led to the grob.
This
 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) tweak-color)))
 (set! (ly:grob-property grob 'color) override-color))

 ;; Return any default setting of after-line-breaking.
 after-line-return))

colorTweaksEngraver =
#(lambda (context)
   (make-engraver
(acknowledgers
 ((grob-interface engraver grob source-engraver)
  (if (grob::has-default-prop grob 'stencil)
  (set! (ly:grob-property grob 'after-line-breaking)
(mark-tweak grob)))


[...your music...]

\layout {
  \context {
\Score
\consists \colorTweaksEngraver
  }
}
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-04 Thread David Nalesnik
Hi Kieren,

On Sat, May 2, 2015 at 6:29 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > > Out of curiosity, do you get results with color-tweaks2.ly (attached
> somewhere above)?
> > Same thing: the EE-added tweak gets executed, but doesn’t appear in the
> log output.
> > So it doesn't get colored?
>
> Sorry… let me be more clear. I \include-d the edition-engraver, and
> compiled twice: once with an \editionMod to move the [initial] Clef, and
> once without. The first time, the Clef moved (as expected) and was coloured
> (as hoped); the second time, the Clef was neither moved nor coloured (both
> as expected).


> HOWEVER, the console output was identical in both cases: the tweak was not
> recorded in the output (as I thought it should have been?).
>

OK, then the modifying actual grobs approach is proving to be more useful
on several counts.

The attached file contains some improvements over color-tweaks2.ly.  The
main difference is that it uses a simple Scheme engraver which must be
\consists-ed.

\voiceTwo and the like will result in colored objects (stems for example),
but I don't think there's any help for that.  Call it a feature :)

Best,
David
\version "2.19.17"

#(define (remove-first symbol alist)
   "Remove the first key-value pair of association list @var{alist}
whose key matches @var{symbol}."
   (let loop ((alist alist) (result '()))
 (cond
  ((null? alist) result)
  ((eq? (caar alist) symbol)
   (append result (cdr alist)))
  (else (loop (cdr alist)
  (append result (list (car alist

#(define (grob::has-default-prop grob prop)
   "Check all-grob-descriptions to see if symbol @var{grob} has
a default setting for symbol @var{prop}.  Either return the
setting or @code{#f}."
   (let ((description (assoc-get grob all-grob-descriptions)))
 (if description
 (assoc-get 'stencil description

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions)) 
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  ;; We're using after-line-breaking to set color of stencil, but
  ;; let's preserve its last setting
  (after-line-return (assoc-get 'after-line-breaking props))
  ;; Clef.glyph doesn't appear in all-grob-descriptions, but it
  ;; is set at some point automatically.  Don't mark it unless
  ;; it genuinely is a user override.  There may be other
  ;; such grobs.
  (props
   (if (eq? (grob::name grob) 'Clef)
   (reverse (remove-first 'glyph (reverse props)))
   props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob, but
 ;; we can find them through the music event which led to the grob.  This
 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) red)))
 (set! (ly:grob-property grob 'color) green))
 
 ;; Return any default setting of after-line-breaking.
 after-line-return))

colorTweaksEngraver =
#(lambda (context)
   (make-engraver 
(acknowledgers
 ((grob-interface engraver grob source-engraver)
  (if (grob::has-default-prop grob 'stencil)
  (set! (ly:grob-property grob 'after-line-breaking)
(mark-tweak grob)))



%%

{ 
  \voiceOne
  \once \override Staff.Clef.extra-offset = #'(0 . 2)
  c^"hi"_1 \clef "bass_8" c,
  \oneVoice
  \key d \major
  c,
}

{
  \override NoteHead.X-extent = #'(-1 . 1)
  \override NoteHead.font-size = 3
  \override NoteHead.stencil = #ly:note-head::print
  c1
  \revert NoteHead.X-extent
  c1
  \revert NoteHead.font-size
  c1
  \revert NoteHead.stencil
  c1
}


{
  %\voiceTwo
  \tweak font-size 3
  c'1
  \tweak NoteHead.font-size 3
  \tweak Stem.thickness 5
  c'2
  
  <\tweak NoteHead.font-size 3 c' e'>1
  \override NoteHead.font-size = 4
  c'1
  \temporary \override NoteHead.font-size = 12
  c'1
  \revert NoteHead.font-size
  \revert Score.BarLine.X-extent
  \revert Staff.Clef.after-line-breaking
  \clef alto
  c'1
}

\layout {
  \context {
\Score {
  \override BarLine.X-extent = #'(-2 . 2)
}
  }
  \context {
\Staff
\override Clef.after-line-breaking =
#(lambda (grob)
   (set! (ly:grob-property grob 

Re: Color tweaks (edition engraver)

2015-05-02 Thread Kieren MacMillan
Hi David,

> > Out of curiosity, do you get results with color-tweaks2.ly (attached 
> > somewhere above)?
> Same thing: the EE-added tweak gets executed, but doesn’t appear in the log 
> output.
> So it doesn't get colored?

Sorry… let me be more clear. I \include-d the edition-engraver, and compiled 
twice: once with an \editionMod to move the [initial] Clef, and once without. 
The first time, the Clef moved (as expected) and was coloured (as hoped); the 
second time, the Clef was neither moved nor coloured (both as expected).

HOWEVER, the console output was identical in both cases: the tweak was not 
recorded in the output (as I thought it should have been?).

Hope that helps.
Kieren.

p.s. Why not just download the edition engraver .zip file 
(https://github.com/openlilylib/openlilylib/archive/master.zip) and test things 
yourself? Here’s all you need to add:

1. At the top
\include "openlilylib-master/editorial-tools/edition-engraver/definitions.ily"
\addEdition test
\editionMod test 1 0/4 test.Score.A \once \override Score.Clef.extra-offset = 
#'(0 . 2)

2. Somewhere else
\layout {
  \context {
\Score
\consists \editionEngraver test
  }
}


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Sat, May 2, 2015 at 6:08 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > Out of curiosity, do you get results with color-tweaks2.ly (attached
> somewhere above)?
>
> Same thing: the EE-added tweak gets executed, but doesn’t appear in the
> log output.
>

 So it doesn't get colored?
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread Kieren MacMillan
Hi David,

> Out of curiosity, do you get results with color-tweaks2.ly (attached 
> somewhere above)?

Same thing: the EE-added tweak gets executed, but doesn’t appear in the log 
output.

Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
Kieren,

On Fri, May 1, 2015 at 3:28 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> This looks pretty amazing so far — thanks for the great work!
>
> When I try to apply it to a score with edition-engraver tweaks, it doesn’t
> seem to colour anything tweaked using the EE.
> It does seem to colour things tweaked otherwise (e.g., in the “content”).
>
> Maybe I’m doing something wrong? I’m simply using
>
> \colorOverride \theScore
>
>
Out of curiosity, do you get results with color-tweaks2.ly (attached
somewhere above)?

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Sat, May 2, 2015 at 3:56 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > Aha.  So in the console do you see something like
>
> No…  =)
>
>  (make-music
>   'SequentialMusic
>   'elements
>   (list (make-music
>   'NoteEvent
>   'pitch
>   (ly:make-pitch 1 0)
>   'duration
>   (ly:make-duration 2
>
> That’s it.
>
>
:(

Another discovery is making me think that there is just no good way to
solve this problem.

Try:

 \colorOverride
{
  \override NoteHead.X-extent = #'(-1 . 1)
  \override NoteHead.font-size = 3
  \override NoteHead.stencil = #ly:note-head::print
  c1
  \revert NoteHead.X-extent
  c1
  \revert NoteHead.font-size
  c1
  \revert NoteHead.stencil
  c1
}

A single revert kills the color, even though two overrides are in effect.

Conversely. using \markAllAlteredGrobs (in color-tweaks2.y above, not to be
confused with colorTweaks2.ly), only the last \revert removes the color,
which is as it should be.

Try:

{
  \override NoteHead.X-extent = #'(-1 . 1)
  \override NoteHead.font-size = 3
  \override NoteHead.stencil = #ly:note-head::print
  c1
  \revert NoteHead.X-extent
  c1
  \revert NoteHead.font-size
  c1
  \revert NoteHead.stencil
  c1
}

\layout {
  \context {
\Score
\markAllAlteredGrobs
  }
}

I just don't think there is any way to do this perfectly.

Maybe I'll try an engraver, since it looks like we need live grobs (the
\markAllAlteredGrobs approach)

DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread Kieren MacMillan
Hi David,

> Aha.  So in the console do you see something like

No…  =)

 (make-music
  'SequentialMusic
  'elements
  (list (make-music
  'NoteEvent
  'pitch
  (ly:make-pitch 1 0)
  'duration
  (ly:make-duration 2

That’s it.

Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread Thomas Morley
2015-05-02 18:53 GMT+02:00 David Nalesnik :
> Hi Harm,
>
> On Sat, May 2, 2015 at 11:45 AM, Thomas Morley 
> wrote:
>>
>> 2015-05-02 17:20 GMT+02:00 David Nalesnik :
>>
>> > [...]
>> > OK!  Though I am disappointed you don't have a magical way to put scores
>> > in
>> > variables :)
>> >  [...]
>> >
>> > David
>>
>>
>>  start snippet
>>
>> \version "2.19.18"
>>
>> m = \new Staff { c''1 }
>>
>> mL =
>>   \layout {
>> \context {
>>   \Score
>>   \override NoteHead #'color = #red
>> }
>>   }
>>
>> %myS = \score { \m \layout { \mL } } %% for 2.18.2
>> myS = \score { \m \mL }
>>
>> myB =
>>   \book {
>> \header { title = "book-title" }
>> \myS
>>   }
>>
>> \myS
>>
>> \myB
>>
>>  end snippet
>>
>>
>> works for me ;)
>>
>
> Useful snippet!
>
> But unfortunately, you can't do
>
> \displayMusic \myS
>
> because \myS produces a # object, not a music expression.

Yep, though you can do:

\displayMusic #(ly:score-music myS)

>
> --David

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
Hi Harm,

On Sat, May 2, 2015 at 11:45 AM, Thomas Morley 
wrote:

> 2015-05-02 17:20 GMT+02:00 David Nalesnik :
>
> > [...]
> > OK!  Though I am disappointed you don't have a magical way to put scores
> in
> > variables :)
> >  [...]
> >
> > David
>
>
>  start snippet
>
> \version "2.19.18"
>
> m = \new Staff { c''1 }
>
> mL =
>   \layout {
> \context {
>   \Score
>   \override NoteHead #'color = #red
> }
>   }
>
> %myS = \score { \m \layout { \mL } } %% for 2.18.2
> myS = \score { \m \mL }
>
> myB =
>   \book {
> \header { title = "book-title" }
> \myS
>   }
>
> \myS
>
> \myB
>
>  end snippet
>
>
> works for me ;)
>
>
Useful snippet!

But unfortunately, you can't do

\displayMusic \myS

because \myS produces a # object, not a music expression.

--David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread Thomas Morley
2015-05-02 17:20 GMT+02:00 David Nalesnik :

> [...]
> OK!  Though I am disappointed you don't have a magical way to put scores in
> variables :)
>  [...]
>
> David


 start snippet

\version "2.19.18"

m = \new Staff { c''1 }

mL =
  \layout {
\context {
  \Score
  \override NoteHead #'color = #red
}
  }

%myS = \score { \m \layout { \mL } } %% for 2.18.2
myS = \score { \m \mL }

myB =
  \book {
\header { title = "book-title" }
\myS
  }

\myS

\myB

 end snippet


works for me ;)


Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Fri, May 1, 2015 at 6:02 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > Would you mind trying an extremely small score with the
> edition-engraver, something like (however you would set it up)
> >
> > \displayMusic
> > {
> >   \override NoteHead.font-size = 2
> >   c’’
> > }
>
> I used
>
> \version "2.19"
> \include
> "openlilylib-master/editorial-tools/edition-engraver/definitions.ily"
> \addEdition test
> \editionMod test 1 0/4 test.Score.A \override NoteHead.font-size = 2
> override-color = #red
> tweak-color = #blue
> colorOverride = […]  %%  full function definition would be here
> \layout { \context { \Score \consists \editionEngraver test }}
> \displayMusic { c’' }
>
> The output remained the same (i.e., the NoteHead font-size did change).
>

Aha.  So in the console do you see something like:


(make-music
  'ContextSpeccedMusic
  'create-new
  #t
  'property-operations
  (list (list 'push
  'NoteHead
  2
  'font-size))
  'context-type
  'Staff
  'element
  (make-music
'SequentialMusic
'elements
(list (make-music
'NoteEvent
'pitch
(ly:make-pitch 0 0)
'duration
(ly:make-duration 2)

%%%

If so, the edition engraver is doing the equivalent of:

\new Staff \with { \override NoteHead.font-size = 2 }
{
  c'
}

and I may be able to get at that through 'property-operations.

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Sat, May 2, 2015 at 10:20 AM, David Nalesnik 
wrote:

>
>
> On Sat, May 2, 2015 at 9:38 AM, Kieren MacMillan <
> kieren_macmil...@sympatico.ca> wrote:
>
>> Hi David,
>>
>> > Could you clarify how you are defining \theScore here?
>>
>> Sorry… that was pseudocode. My actual [minimized] score code was:
>>
>> \score {
>>   \colorOverride <<
>> \new Staff \someMusic
>> ….
>>   >>
>> }
>>
>
> OK!  Though I am disappointed you don't have a magical way to put scores
> in variables :)
>
>
>>
>> I’m not sure about others (Jan-Peter?), but for the edition-engraver, I
>> would like to do something more like:
>>
>> \score {
>>   <<
>> \new Staff \someMusic
>>   >>
>>   \layout {
>> \context {
>>   \Score
>>   \consists \editionEngraver editionName
>>   \colorOverride
>> }
>>   }
>> }
>>
>>
> The above code would work with the first approach, where \
> markAllAlteredGrobs basically created a long series of \overrides of
> every grob which might have a stencil.  This involved setting the
> 'after-line-breaking property of all such grobs to a callback which
> examined the property lists of living, breathing grob instances to see if
> anything had been added to the default property list stored in the global
> variable all-grob-descriptions.  The idea being that the list would change
> with any override.
>
> This approach quickly got hairy.
>
> For one thing, clefs get their 'glyph property added later on.  That was
> why initially all clefs got colored, even the default treble clef that you
> get with { c d e f }, for example.  Who knows if there are other such cases.
>
> For another, tweaks--unlike overrides--do not result in a change to the
> grob's basic property alist.  To get at tweaks, it is necessary to find the
> "music-cause" of the grob--i.e., find the music expression which lead
> ultimately to its creation.  Luckily the stream event carries a reference
> to this earlier stage of processing.  (BTW, there is a note somewhere in
> the source that says this reference ought to be removed at some stage.)
>
> (This method also--like the music function \colorOverride--can't get at
> properties overridden in a \layout \context block.  I really don't know how
> to do that, and I hope that someone can give me a way!)
>
> It occurred to me that it was more natural to simply look at the music
> input.  The method above tries to detect overrides by a sneaky method of
> comparing property alists with default alists, bound to break down or lead
> to complexities (as with the special casing of Clef.glyph).  Why not just
> look at the music expression for OverrideProperty, RevertProperty--there's
> no mistaking those for override or revert.
>
> Plus, it's easy to tell if it's a user override or one that happened
> through \voiceOne, \voiceTwo so  half the stems in the piece don't turn
> green.
>
> This would be the method you hint at below:
>
>
> or
>>
>> \addEdition editionName 1 0/4 editionName.Score.A \colorOverride
>> \score {
>>   <<
>> \new Staff \someMusic
>>   >>
>>   \layout {
>> \context {
>>   \Score
>>   \consists \editionEngraver editionName
>> }
>>   }
>> }
>>
>
> And this *should* work just fine.  Except that I believe that the
> editionEngraver adds the overrides outside of the music expression somehow.
> Therefore, they are invisible to \colorOverrides.
>
> (I wonder if Jan-Peter could clarify what it is that the engraver does;
> I'm not familiar with the code, and fear that I've misrepresented it.)
>
> I *would* like to figure out how to get into the \layout block to color
> those overrides too.  However, I'm guessing that this will have to be done
> by a second function, a two-pass approach to coloring the score.  And,
> again, I need advice on how to write such a function :)
>
>
OK, why don't I just try the obvious?

To wit:

%%%

\colorOverride
{
  \tweak font-size 3
  c'1
  \tweak NoteHead.font-size 3
  \tweak Stem.thickness 2
  c'2
  
  <\tweak NoteHead.font-size 3 c' e'>1
  \override NoteHead.font-size = 4
  c'1
  \temporary \override NoteHead.font-size = 12
  c'1
  \revert NoteHead.font-size
  \revert Score.BarLine.X-extent
  \revert Staff.Clef.stencil
  \clef alto
  c'1
}

\layout {
  \context {
\Score {
  \colorOverride
  {
\override BarLine.X-extent = #'(-2 . 2)
  }
}
  }
  \context {
\Staff
\colorOverride
{
\override Clef.stencil =
#(lambda (grob)
   (ly:stencil-rotate (ly:clef::print grob) -15 0 0))
}
  }
}

%%%

Notice that the \revert-s in the music expression actually work on the
stuff from the context block.

DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Sat, May 2, 2015 at 10:20 AM, David Nalesnik 
wrote:

>
>  the function \colorOverride[1]
>
>
Forgot the footnote.

[1} This really ought to be named \colorTweaks instead.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Sat, May 2, 2015 at 9:38 AM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > Could you clarify how you are defining \theScore here?
>
> Sorry… that was pseudocode. My actual [minimized] score code was:
>
> \score {
>   \colorOverride <<
> \new Staff \someMusic
> ….
>   >>
> }
>

OK!  Though I am disappointed you don't have a magical way to put scores in
variables :)


>
> I’m not sure about others (Jan-Peter?), but for the edition-engraver, I
> would like to do something more like:
>
> \score {
>   <<
> \new Staff \someMusic
>   >>
>   \layout {
> \context {
>   \Score
>   \consists \editionEngraver editionName
>   \colorOverride
> }
>   }
> }
>
>
The above code would work with the first approach, where \
markAllAlteredGrobs basically created a long series of \overrides of every
grob which might have a stencil.  This involved setting the
'after-line-breaking property of all such grobs to a callback which
examined the property lists of living, breathing grob instances to see if
anything had been added to the default property list stored in the global
variable all-grob-descriptions.  The idea being that the list would change
with any override.

This approach quickly got hairy.

For one thing, clefs get their 'glyph property added later on.  That was
why initially all clefs got colored, even the default treble clef that you
get with { c d e f }, for example.  Who knows if there are other such cases.

For another, tweaks--unlike overrides--do not result in a change to the
grob's basic property alist.  To get at tweaks, it is necessary to find the
"music-cause" of the grob--i.e., find the music expression which lead
ultimately to its creation.  Luckily the stream event carries a reference
to this earlier stage of processing.  (BTW, there is a note somewhere in
the source that says this reference ought to be removed at some stage.)

(This method also--like the music function \colorOverride--can't get at
properties overridden in a \layout \context block.  I really don't know how
to do that, and I hope that someone can give me a way!)

It occurred to me that it was more natural to simply look at the music
input.  The method above tries to detect overrides by a sneaky method of
comparing property alists with default alists, bound to break down or lead
to complexities (as with the special casing of Clef.glyph).  Why not just
look at the music expression for OverrideProperty, RevertProperty--there's
no mistaking those for override or revert.

Plus, it's easy to tell if it's a user override or one that happened
through \voiceOne, \voiceTwo so  half the stems in the piece don't turn
green.

This would be the method you hint at below:


or
>
> \addEdition editionName 1 0/4 editionName.Score.A \colorOverride
> \score {
>   <<
> \new Staff \someMusic
>   >>
>   \layout {
> \context {
>   \Score
>   \consists \editionEngraver editionName
> }
>   }
> }
>

And this *should* work just fine.  Except that I believe that the
editionEngraver adds the overrides outside of the music expression somehow.
Therefore, they are invisible to \colorOverrides.

(I wonder if Jan-Peter could clarify what it is that the engraver does; I'm
not familiar with the code, and fear that I've misrepresented it.)

I *would* like to figure out how to get into the \layout block to color
those overrides too.  However, I'm guessing that this will have to be done
by a second function, a two-pass approach to coloring the score.  And,
again, I need advice on how to write such a function :)

For people who mix overrides in the music expression and adopt at most a
moderate separation of "presentation" and "content" the function
\colorOverride[1] should work just fine.  Jan-Peter could probably come up
with something easily integrated with the editionEngraver to accommodate
that more complete separation.

Whew...long email.  Hope that clarifies the issues!

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread Kieren MacMillan
Hi David,

> Could you clarify how you are defining \theScore here?

Sorry… that was pseudocode. My actual [minimized] score code was:

\score {
  \colorOverride <<
\new Staff \someMusic
….
  >>
}

I’m not sure about others (Jan-Peter?), but for the edition-engraver, I would 
like to do something more like:

\score {
  <<
\new Staff \someMusic
  >>
  \layout {
\context {
  \Score
  \consists \editionEngraver editionName
  \colorOverride
}
  }
}

or

\addEdition editionName 1 0/4 editionName.Score.A \colorOverride
\score {
  <<
\new Staff \someMusic
  >>
  \layout {
\context {
  \Score
  \consists \editionEngraver editionName
}
  }
}

Does that make sense?

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-02 Thread David Nalesnik
On Fri, May 1, 2015 at 3:28 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> This looks pretty amazing so far — thanks for the great work!
>
> When I try to apply it to a score with edition-engraver tweaks, it doesn’t
> seem to colour anything tweaked using the EE.
> It does seem to colour things tweaked otherwise (e.g., in the “content”).
>
> Maybe I’m doing something wrong? I’m simply using
>
> \colorOverride \theScore
>

Could you clarify how you are defining \theScore here?  Are you defining
the score with \new Score { [...] } minus a layout block?  I bring this up
because I can't see how errors wouldn't arise if you do it any other way.

More details:

If you do the following--

theScore =
\score {

[...]

}

You can get the score appear with
\theScore

or

\theScore \layout { }

However, you can't apply the music function \colorOverride to \theScore:

\colorOverride \theScore

returns the error

wrong type for argument 1.  Expecting music, found #
\colorOverride
   \myScore

Of course, if you put \colorOverride within the score somewhere like:

theScore =
\score {
  \colorOverride
  \new Staff {
c'
  }
}

all is well.

However, you can do

theScore =
\new Score {

[...]

}

and

\colorOverride \theScore

will work fine, because \theScore is a music expression

%%

Does this logic apply to what you're doing, or is there another way?

Best,
David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
Hi Jim,

On Mon, Apr 27, 2015 at 3:55 PM, Jim Long  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


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
On Fri, May 1, 2015 at 6:21 PM, David Nalesnik 
wrote:

> Hi Kieren,
>
>
> I suppose the way to get at context modifications is through
> \applyContext.
>
>

Nope. Well, there's \applyOutput, which works a single time-step at a time.

Since all modifications are tracked by the edition-engraver, I don't
imagine it will be too difficult to integrate a mechanism for adding a
color tweak/override when another is requested.

Best,
David

P.S. But for whoever doesn't use the edition engraver: give it a try!
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
Hi Kieren,

On Fri, May 1, 2015 at 6:02 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> > Would you mind trying an extremely small score with the
> edition-engraver, something like (however you would set it up)
> >
> > \displayMusic
> > {
> >   \override NoteHead.font-size = 2
> >   c’’
> > }
>
> I used
>
> \version "2.19"
> \include
> "openlilylib-master/editorial-tools/edition-engraver/definitions.ily"
> \addEdition test
> \editionMod test 1 0/4 test.Score.A \override NoteHead.font-size = 2
> override-color = #red
> tweak-color = #blue
> colorOverride = […]  %%  full function definition would be here
> \layout { \context { \Score \consists \editionEngraver test }}
> \displayMusic { c’' }
>
> The output remained the same (i.e., the NoteHead font-size did change).
>
> > (1) Does the font-size override show up in the console output?
>
> No.
>
>
As I suspected

I suppose the way to get at context modifications is through
\applyContext.  Will see what I can figure out.

In any case, we get all overrides and tweaks within the music expression :)

Thanks for trying that out.

David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread Kieren MacMillan
Hi David,

> Would you mind trying an extremely small score with the edition-engraver, 
> something like (however you would set it up)
> 
> \displayMusic
> {
>   \override NoteHead.font-size = 2
>   c’’
> }

I used

\version "2.19"
\include "openlilylib-master/editorial-tools/edition-engraver/definitions.ily"
\addEdition test
\editionMod test 1 0/4 test.Score.A \override NoteHead.font-size = 2
override-color = #red
tweak-color = #blue
colorOverride = […]  %%  full function definition would be here
\layout { \context { \Score \consists \editionEngraver test }}
\displayMusic { c’' }

The output remained the same (i.e., the NoteHead font-size did change).

> (1) Does the font-size override show up in the console output?

No.

Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread Thomas Morley
2015-05-01 23:54 GMT+02:00 David Nalesnik :
> It's Friday...
TGIF

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
On Fri, May 1, 2015 at 3:49 PM, David Nalesnik 
wrote:

> Hi Kieren and all,
>
> On Fri, May 1, 2015 at 3:28 PM, Kieren MacMillan <
> kieren_macmil...@sympatico.ca> wrote:
>
>> Hi David,
>>
>> This looks pretty amazing so far — thanks for the great work!
>>
>> When I try to apply it to a score with edition-engraver tweaks, it
>> doesn’t seem to colour anything tweaked using the EE.
>> It does seem to colour things tweaked otherwise (e.g., in the “content”).
>>
>> Maybe I’m doing something wrong? I’m simply using
>>
>> \colorOverride \theScore
>>
>
> I expected this.  You won't see any coloring for overrides from a \context
> block, and for overrides that come about through \voiceOne/\voiceTwo ...
> (though you can make these appear by commenting out line 28 (put a
> semicolon in front of it).
>
> Would you mind trying an extremely small score with the edition-engraver,
> something like (however you would set it up)
>
> \displayMusic
> {
>   \override NoteHead.font-size = 2
>   c''
> }
>
> (1) Does the font-size override show up in the console output?
> (2) If it does, is there an entry for 'grob-property-path?  (If there is,
> commenting out the line mentioned above will work, though you may get stuff
> you don't care about like the overrides that are predefined for voices)
>

If there _isn't_, commenting out...


It's Friday...
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
On Fri, May 1, 2015 at 3:49 PM, David Nalesnik 
wrote:

>
>
> In other news:
>
> **Attached please find a version that handles tweaks and overrides.  It
> will also deal with \temporary, too.**
>

Drat...wrong file!


>
\version "2.19"

override-color = #red
tweak-color = #blue

%tweak-color = #override-color

colorOverride =
#(define-music-function (parser location music) (ly:music?)
   (music-map
(lambda (mus)
  ;; overrides
  (if (and (music-is-of-type? mus 'context-specification)
   (ly:music? (ly:music-property mus 'element)))
  
  (let ((elt (ly:music-property mus 'element))
(context (ly:music-property mus 'context-type)))

(cond
 ((music-is-of-type? elt 'override-property-event)
  (let* ((grob-name (ly:music-property elt 'symbol))
 (prop-path (ly:music-property elt 'grob-property-path))
 (once? (ly:music-property elt 'once))
 ; is the previous setting remembered?
 (pop-first? (ly:music-property elt 'pop-first)))
(cond
 ; non-user overrides don't set property path
 ((null? prop-path) #{ #})
 ; \once \override
 ((eq? #t once?)
  (set! mus
#{
  \once \override #(list context grob-name 'color)
  = #override-color
  #mus
#}))
 ; \override
 ((eq? pop-first? #t)
  (set! mus
#{
  \override #(list context grob-name 'color)
  = #override-color
  #mus
#}))
 ; \temporary
 ((null? pop-first?)
  (set! mus
#{
  \temporary \override #(list context grob-name 'color)
  = #override-color
  #mus
#})
 
 ;; reverts
 ((and (music-is-of-type? elt 'layout-instruction-event)
   (eq? (ly:music-property elt 'name) 'RevertProperty))
  (let ((grob-name (ly:music-property elt 'symbol)))
(set! mus
  #{
\revert #(list context grob-name 'color)
#mus
  #})
  ;; tweaks
  (let ((tweaks (ly:music-property mus 'tweaks)))
(if (pair? tweaks)
;(begin
(set! (ly:music-property mus 'tweaks)
  (let loop ((tweaks tweaks) (result '()))
(cond
 ((null? tweaks) result)
 ; basic tweak:
 ; ( (font-size . 2) [...] )
 ((symbol? (caar tweaks))
  (loop (cdr tweaks)
(append
 result
 (list (cons 'color tweak-color))
 (list (car tweaks)
 ; 'directed' tweak:
 ; ( ((NoteHead . font-size) . 2) [...] )
 (else
  (loop (cdr tweaks)
(append
 result
 (list
  (cons (cons (caaar tweaks) 'color) tweak-color))
 (list (car tweaks
;(display (ly:music-property mus 'tweaks)) (newline)
;)
))
  )
  
  mus)
music)
   
   music)

%%

%\displayMusic
\colorOverride
\new PianoStaff <<
  \new Staff <<
\new Voice {
  \voiceOne
  c''4
  \once \override NoteHead.after-line-breaking =
  #(lambda (grob)
 (let ((stil (ly:note-head::print grob)))
   (set! (ly:grob-property grob 'stencil)
 (ly:stencil-scale stil 1.5 1.5
  d'' e''->
  \override Voice.Stem.padding = 2
  f''
  g''1  
}
\new Voice {
  \voiceTwo
  c'4 d'
  \override Script.font-size = 3
  e'-> f'->
  \revert Script.font-size
  g'1->
  \override Staff.Clef.extra-offset = #'(0 . 5)
  \oneVoice
  \clef alto
  \shape #'((0 . 0) (0 . 3) (0 . 3) (0 . 0)) Tie % \shape is \once
  c'1~
  \revert Staff.Clef.extra-offset
  \clef treble
  c'1~
  c'1
  \override NoteHead.font-size = 4
  1
  %\unfoldRepeats
  \repeat volta 2 {
c'1
  }
  \override Score.BarLine.X-extent = #'(-3 . 3)
}
  >>
  \new Staff <<
\clef bass
\new Voice { 
  \voiceOne
  c'4 d'

Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
Hi Kieren and all,

On Fri, May 1, 2015 at 3:28 PM, Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi David,
>
> This looks pretty amazing so far — thanks for the great work!
>
> When I try to apply it to a score with edition-engraver tweaks, it doesn’t
> seem to colour anything tweaked using the EE.
> It does seem to colour things tweaked otherwise (e.g., in the “content”).
>
> Maybe I’m doing something wrong? I’m simply using
>
> \colorOverride \theScore
>

I expected this.  You won't see any coloring for overrides from a \context
block, and for overrides that come about through \voiceOne/\voiceTwo ...
(though you can make these appear by commenting out line 28 (put a
semicolon in front of it).

Would you mind trying an extremely small score with the edition-engraver,
something like (however you would set it up)

\displayMusic
{
  \override NoteHead.font-size = 2
  c''
}

(1) Does the font-size override show up in the console output?
(2) If it does, is there an entry for 'grob-property-path?  (If there is,
commenting out the line mentioned above will work, though you may get stuff
you don't care about like the overrides that are predefined for voices)



In other news:

**Attached please find a version that handles tweaks and overrides.  It
will also deal with \temporary, too.**

The colors for tweaks and overrides are controlled by variables at the top
of the file.

It would be helpful to me if people could try it out with larger scores to
see how it fares!

Enjoy,
David
\version "2.19.17"

#(define (remove-first symbol alist)
   (let loop ((alist alist) (result '()))
 (cond
  ((null? alist) result)
  ((eq? (caar alist) symbol) (append result (cdr alist)))
  (else (loop (cdr alist) (append result (car alist)))


#(define (grobs-with-stencils)
   (let loop ((all all-grob-descriptions) (result '()))
 (if (null? all)
 result
 (if (assoc-get 'stencil (cdar all))
 (loop (cdr all) (cons (caar all) result))
 (loop (cdr all) result)

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (after-line-return (assoc-get 'after-line-breaking default)) 
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  ;; Yuck.  We should remove the _last_ entry in the alist.  Good
  ;; enough for now.  Just don't override Clef.glyph.
  (props
   (if (eq? (grob::name grob) 'Clef)
   (remove-first 'glyph props)
   props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob, but
 ;; we can find them through the music event which led to the grob.  This
 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) red)))
 (set! (ly:grob-property grob 'color) green))
 
 ;; Return any default setting of after-line-breaking.
 after-line-return))


markAllAlteredGrobs =
#(define-music-function (parser location) ()
   (let loop ((grobs (grobs-with-stencils)))
 (if (null? grobs)
 #{ #}
 #{
   \override #(list 'Score (car grobs) 'after-line-breaking) = #mark-tweak
   #(loop (cdr grobs))
 #})))

%%


\displayMusic 
{ 
  \voiceOne
  \once \override Staff.Clef.extra-offset = #'(0 . 2)
  c^"hi"_1 \clef "bass_8" c,
  \oneVoice
  \key d \major
  c,
}

\layout {
  \context {
\Score
\markAllAlteredGrobs
  }
}

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread Kieren MacMillan
Hi David,

This looks pretty amazing so far — thanks for the great work!

When I try to apply it to a score with edition-engraver tweaks, it doesn’t seem 
to colour anything tweaked using the EE.
It does seem to colour things tweaked otherwise (e.g., in the “content”).

Maybe I’m doing something wrong? I’m simply using

\colorOverride \theScore

Cheers,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
On Fri, May 1, 2015 at 11:15 AM, David Nalesnik 
wrote:

>
>
> On Fri, May 1, 2015 at 10:56 AM, David Nalesnik 
> wrote:
>>
>>
>> The code below will work much better.
>>
>>
> Drat.  Somehow we need to get the context name into the override.
> Otherwise
>
>
>   \override Staff.Clef.extra-offset = #'(0 . 5)
>   \clef alto
>
> will lose its extra-offset and not be marked in green.
>
>
OK, fixed.  Hoping this wouldn't get too convoluted...

%%%

 \version "2.19"

colorOverride =
#(define-music-function (parser location music) (ly:music?)
   (music-map
(lambda (mus)
  (if (and (music-is-of-type? mus 'context-specification)
   (ly:music? (ly:music-property mus 'element)))

  (let* ((elt (ly:music-property mus 'element))
 (context (ly:music-property mus 'context-type)))

(cond
 ((music-is-of-type? elt 'override-property-event)
  (let* ((grob-name (ly:music-property elt 'symbol))
 (prop-path (ly:music-property elt 'grob-property-path))
 (once? (ly:music-property elt 'once)))
(cond
 ; non-user overrides don't set property path
 ((null? prop-path) #{ #})
 ((eq? #t once?)
  (set! mus
#{
  \once \override #(list context grob-name 'color)
= #green
  #mus
#}))
 (else
  (set! mus
#{
  \override #(list context grob-name 'color) =
#green
  #mus
#})
 ((and (music-is-of-type? elt 'layout-instruction-event)
   (eq? (ly:music-property elt 'name) 'RevertProperty))
  (let ((grob-name (ly:music-property elt 'symbol)))
(set! mus
  #{
\revert #(list context grob-name 'color)
#mus
  #}))

  mus)
music)

   music)

%\displayMusic
\colorOverride
\new PianoStaff <<
  \new Staff <<
\new Voice {
  \voiceOne
  c''4
  \once \override NoteHead.after-line-breaking =
  #(lambda (grob)
 (let ((stil (ly:note-head::print grob)))
   (set! (ly:grob-property grob 'stencil)
 (ly:stencil-scale stil 1.5 1.5
  d'' e''->
  \override Voice.Stem.padding = 2
  f''
  g''1
}
\new Voice {
  \voiceTwo
  c'4 d'
  \override Script.font-size = 3
  e'-> f'->
  \revert Script.font-size
  g'1->
  \override Staff.Clef.extra-offset = #'(0 . 5)
  \oneVoice
  \clef alto
  \shape #'((0 . 0) (0 . 3) (0 . 3) (0 . 0)) Tie % \shape is \once
  c'1~
  \revert Staff.Clef.extra-offset
  \clef treble
  c'1~
  c'1
}
  >>
  \new Staff <<
\clef bass
\new Voice {
  \voiceOne
  c'4 d' e'->
  \override Voice.Stem.padding = 2
  f'
  g'1\fermata
  \oneVoice
  \clef treble
  c'
  \clef alto
}
\new Voice {
  \voiceTwo
  c4 d
  \override Script.font-size = 3
  e-> f->
  g1->
}
  >>
>>
%}
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
On Fri, May 1, 2015 at 10:56 AM, David Nalesnik 
wrote:
>
>
> The code below will work much better.
>
>
Drat.  Somehow we need to get the context name into the override.  Otherwise


  \override Staff.Clef.extra-offset = #'(0 . 5)
  \clef alto

will lose its extra-offset and not be marked in green.

DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-05-01 Thread David Nalesnik
Hi,

On Tue, Apr 28, 2015 at 10:29 AM, David Nalesnik 
wrote:

>
>
> On Mon, Apr 27, 2015 at 6:13 PM, David Nalesnik 
> wrote:
>
>> Hi Joram,
>>
>> On Mon, Apr 27, 2015 at 5:30 PM, Noeck  wrote:
>>
>
>
>>
>>
>
>>> > There is something which has to be fixed, though.  All clefs get
>>> colored,
>>>
>>> Can this be avoided (even at the cost of not coloring them even if
>>> tweaked)?
>>>
>>
>> Sure, but I wouldn't want to settle!
>>
>
> The attached should work for the most part.
>
>
>>
>>
>>>
>>> >  The best way to check, of
>>> > course, is to run it with a large, heavily tweaked score.
>>>
>>> That's my purpose, so I will give you feedback soon. The first
>>> impression is that it colors too much (hairpins, dynamics and ranges of
>>> note heads).
>>>
>>
>> Make sure those aren't instances of \override rather than \once \override
>> ...
>>
>
> Another issue of relevance here is that using \voiceOne, \voiceTwo and the
> like creates lots of overrides "behind the scenes".  These will of course
> be picked up and colored.
>
> Run the attached.  In the log output you can clearly see the wealth of
> overrides which have bee added to the music expression by the \voiceOne
> command.  Comment it out to see the color magically disppear.
>
> There is no realistic way I can see to sort out "hidden overrides" caused
> by \voiceOne, \voiceTwo and actual explicit use of \override.
>
> Now, if that isn't a problem... :)
>
> DN
>
> P.S. The attached won't play well with user overrides of
> 'after-line-breaking.  Optimistically, it's a corner case :) Anyway, I give
> up for the time being.
>

The code below will work much better.  Instead of modifying actual grobs,
I've opted to insert music expressions.  Turns out there is no problem
distinguishing between explicit overrides and ones introduced sneakily by
\oneVoice and the like.

Note that overrides in a context block will not show up.  (They wouldn't in
the other version of the code, either.)

Right now the effect is limited to [\once] \override and \revert.  \tweak
could be accommodated without much difficulty.

The problem with after-line-breaking is gone.

Now, overrides to color aren't going to show up.  (The changed color would
indicate override anyway!)  Making something transparent also won't show up
:)

David

%

\version "2.19"

colorOverride =
#(define-music-function (parser location music) (ly:music?)
   (music-map
(lambda (mus)
  (cond
   ((music-is-of-type? mus 'override-property-event)
(let* ((grob-name (ly:music-property mus 'symbol))
   (prop-path (ly:music-property mus 'grob-property-path))
   (once? (ly:music-property mus 'once)))
  (cond
   ; non-user overrides don't set property path
   ((null? prop-path) #{ #})
   ((eq? #t once?)
(set! mus
  #{
\once \override #(list grob-name 'color) = #green
#mus
  #}))
   (else
(set! mus
  #{
\override #(list grob-name 'color) = #green
#mus
  #})
   ((and (music-is-of-type? mus 'layout-instruction-event)
 (eq? (ly:music-property mus 'name) 'RevertProperty))
(let ((grob-name (ly:music-property mus 'symbol)))
  (set! mus
#{
  \revert #(list grob-name 'color)
  #mus
#}

  mus)
music)
   music)


%\displayMusic
\colorOverride
\new PianoStaff <<
  \new Staff <<
\new Voice {
  \voiceOne
  c''4
  \once \override NoteHead.after-line-breaking =
  #(lambda (grob)
 (let ((stil (ly:note-head::print grob)))
   (set! (ly:grob-property grob 'stencil)
 (ly:stencil-scale stil 1.5 1.5
  d'' e''->
  \override Voice.Stem.padding = 2
  f''
  g''1
}
\new Voice {
  \voiceTwo
  c'4 d'
  \override Script.font-size = 3
  e'-> f'->
  \revert Script.font-size
  g'1->
}
  >>
  \new Staff <<
\clef bass
\new Voice {
  \voiceOne
  c'4 d' e'->
  \override Voice.Stem.padding = 2
  f'
  g'1\fermata
}
\new Voice {
  \voiceTwo
  c4 d
  \override Script.font-size = 3
  e-> f->
  g1->
}
  >>
>>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-28 Thread David Nalesnik
On Mon, Apr 27, 2015 at 6:13 PM, David Nalesnik 
wrote:

> Hi Joram,
>
> On Mon, Apr 27, 2015 at 5:30 PM, Noeck  wrote:
>


>
>

>> > There is something which has to be fixed, though.  All clefs get
>> colored,
>>
>> Can this be avoided (even at the cost of not coloring them even if
>> tweaked)?
>>
>
> Sure, but I wouldn't want to settle!
>

The attached should work for the most part.


>
>
>>
>> >  The best way to check, of
>> > course, is to run it with a large, heavily tweaked score.
>>
>> That's my purpose, so I will give you feedback soon. The first
>> impression is that it colors too much (hairpins, dynamics and ranges of
>> note heads).
>>
>
> Make sure those aren't instances of \override rather than \once \override
> ...
>

Another issue of relevance here is that using \voiceOne, \voiceTwo and the
like creates lots of overrides "behind the scenes".  These will of course
be picked up and colored.

Run the attached.  In the log output you can clearly see the wealth of
overrides which have bee added to the music expression by the \voiceOne
command.  Comment it out to see the color magically disppear.

There is no realistic way I can see to sort out "hidden overrides" caused
by \voiceOne, \voiceTwo and actual explicit use of \override.

Now, if that isn't a problem... :)

DN

P.S. The attached won't play well with user overrides of
'after-line-breaking.  Optimistically, it's a corner case :) Anyway, I give
up for the time being.
\version "2.19.17"

#(define (remove-first symbol alist)
   (let loop ((alist alist) (result '()))
 (cond
  ((null? alist) result)
  ((eq? (caar alist) symbol) (append result (cdr alist)))
  (else (loop (cdr alist) (append result (car alist)))


#(define (grobs-with-stencils)
   (let loop ((all all-grob-descriptions) (result '()))
 (if (null? all)
 result
 (if (assoc-get 'stencil (cdar all))
 (loop (cdr all) (cons (caar all) result))
 (loop (cdr all) result)

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (after-line-return (assoc-get 'after-line-breaking default)) 
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  ;; Yuck.  We should remove the _last_ entry in the alist.  Good
  ;; enough for now.  Just don't override Clef.glyph.
  (props
   (if (eq? (grob::name grob) 'Clef)
   (remove-first 'glyph props)
   props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob, but
 ;; we can find them through the music event which led to the grob.  This
 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) red)))
 (set! (ly:grob-property grob 'color) green))
 
 ;; Return any default setting of after-line-breaking.
 after-line-return))


markAllAlteredGrobs =
#(define-music-function (parser location) ()
   (let loop ((grobs (grobs-with-stencils)))
 (if (null? grobs)
 #{ #}
 #{
   \override #(list 'Score (car grobs) 'after-line-breaking) = #mark-tweak
   #(loop (cdr grobs))
 #})))

%%


\displayMusic 
{ 
  \voiceOne
  c-"hi"-1 \clef "bass_8" c,
}

\layout {
  \context {
\Score
\markAllAlteredGrobs
  }
}

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread David Nalesnik
Hi Joram,

On Mon, Apr 27, 2015 at 5:30 PM, Noeck  wrote:

> Hi David,
>
> thank you very much! This is great. It is by far enough for my purposes.
> For an automatic option like in Frescobaldi it has some issues still –
> as you describe.
>
> > There is something which has to be fixed, though.  All clefs get colored,
>
> Can this be avoided (even at the cost of not coloring them even if
> tweaked)?
>

Sure, but I wouldn't want to settle!


>
> >  The best way to check, of
> > course, is to run it with a large, heavily tweaked score.
>
> That's my purpose, so I will give you feedback soon. The first
> impression is that it colors too much (hairpins, dynamics and ranges of
> note heads).
>

Make sure those aren't instances of \override rather than \once \override
...


>
> > The reason for this is that 'after-line-breaking is often used
> > for advanced tweaks
>
> Out of curiosity, could you explain to me what after-line-breaking is
> doing and why it is used so often for advanced tweaks?
>

It's described as a "dummy" property, so you can set it to various
callbacks without worrying that you will overwrite something important.
 (There are a certain few grobs--Hairpin is an example--which have default
settings for this property, however..  To deal with that, I make sure that
the default value of 'after-line-breaking is returned after I have made my
changes to 'color.)

There are two such dummy properties distinguished by when they are called:
before-line-breaking and after-line-breaking.  The timing can be crucial.
Let's say you want to change pieces of broken spanners.  You need to look
for the pieces within 'after-line-breaking, because the spanner will still
be whole when 'before-line-breaking is evaluated.

The issue with the current file is
(1) calling the music function adds a pair for after-line-breaking at the
head of the properties alist;
(2) a user's advanced functions will add a pair for after-line-breaking as
well
(3) we want to get rid of (1) when deciding whether to color, but we need
(2) to be evaluated

This can be resolved, but I'm too tired to deal with it right now.

Hope this helps!

David

P.S.  I'm wondering if it would be cleaner to modify the music
expression--that is, what is returned by \displayMusic, rather than the
approach taken here.  I'll have a look.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread Noeck
Hi David,

thank you very much! This is great. It is by far enough for my purposes.
For an automatic option like in Frescobaldi it has some issues still –
as you describe.

> There is something which has to be fixed, though.  All clefs get colored,

Can this be avoided (even at the cost of not coloring them even if tweaked)?

>  The best way to check, of
> course, is to run it with a large, heavily tweaked score.

That's my purpose, so I will give you feedback soon. The first
impression is that it colors too much (hairpins, dynamics and ranges of
note heads).

> The reason for this is that 'after-line-breaking is often used
> for advanced tweaks

Out of curiosity, could you explain to me what after-line-breaking is
doing and why it is used so often for advanced tweaks?

Thanks again,
Joram

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread David Nalesnik
Hi Urs,

On Mon, Apr 27, 2015 at 4:57 PM, Urs Liska  wrote:

>  Hey David,
>
> this is terrific. Nice that something I've done comes back to me this way
> ...
>
> When I'll have the time I'll look into integrating this into Frescobaldi's
> Layout Control Options.
>
>
Thanks!

There is something which has to be fixed, though.  All clefs get colored,
apparently because the (glyph . name) pair isn't present in the
basic-properties alist.  This would have to be discounted.  I wonder if
there are any other situations like this.  The best way to check, of
course, is to run it with a large, heavily tweaked score.

Oh, yes, and one more thing.  A more refined way to discount the
after-line-breaking override our function creates is needed (see code
comments).  The reason for this is that 'after-line-breaking is often used
for advanced tweaks, and we don't want to lose these; furthermore. these
should get colored, too.

I'll keep you posted if I come up with solutions.

Best,
David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread Urs Liska

Hey David,

this is terrific. Nice that something I've done comes back to me this 
way ...


When I'll have the time I'll look into integrating this into 
Frescobaldi's Layout Control Options.


Urs

Am 27.04.2015 um 23:14 schrieb David Nalesnik:



On Mon, Apr 27, 2015 at 12:16 PM, David Nalesnik 
mailto:david.nales...@gmail.com>> wrote:




On Mon, Apr 27, 2015 at 12:12 PM, David Nalesnik
mailto:david.nales...@gmail.com>> wrote:

Here's a code snippet to show that it is possible to tell if a
grob has been altered.  Right now you have to add the
procedure for each grob you want to examine.



The following covers all changed grobs.  Thanks, Urs, for your posting 
at http://lilypondblog.org/2014/04/music-functions-4-recursion/ -- I 
adapted one of your functions there to apply the override to all 
objects with a stencil property.  (Rather than using a long string of 
laboriously typed overrides.)


--DN




\version "2.19.17"

#(define (grobs-with-stencils)
   (let loop ((all all-grob-descriptions) (result '()))
 (if (null? all)
 result
 (if (assoc-get 'stencil (cdar all))
 (loop (cdr all) (cons (caar all) result))
 (loop (cdr all) result)

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (default-after-line (assoc-get 'after-line-breaking default))
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our 
grob, but
 ;; we can find them through the music event which led to the 
grob.  This

 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) red)))
 (set! (ly:grob-property grob 'color) green))
 ;; Return any default setting of after-line-breaking.
 (or default-after-line '(


markAllAlteredGrobs =
#(define-music-function (parser location) ()
   (let loop ((grobs (grobs-with-stencils)))
 (if (null? grobs)
 #{ #}
 #{
   \override #(list 'Score (car grobs) 'after-line-breaking) = 
#mark-tweak

   #(loop (cdr grobs))
 #})))

{
  \markAllAlteredGrobs
  c'
  \once \override NoteHead.font-size = 3
  c'
  c'
  \tweak font-size 3 c'
  c'
  %\override Slur.after-line-breaking = #mark-tweak
  c'( e')
  \shape #'((0 . 0) (0 . -0.5) (0 . -0.5) (0 . 0)) Slur
  c'( e')
  c'( e')
  c'-\tweak Slur.positions #'(-5 . -5) ( e')
  \override Hairpin.color = #blue
  c'\< e'\!
  \arpeggio
  \once \override Staff.Arpeggio.positions = #'(-6 . 6)
  \arpeggio
}


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread David Nalesnik
On Mon, Apr 27, 2015 at 12:16 PM, David Nalesnik 
wrote:

>
>
> On Mon, Apr 27, 2015 at 12:12 PM, David Nalesnik  > wrote:
>
> Here's a code snippet to show that it is possible to tell if a grob has
>> been altered.  Right now you have to add the procedure for each grob you
>> want to examine.
>>
>>
>
The following covers all changed grobs.  Thanks, Urs, for your posting at
http://lilypondblog.org/2014/04/music-functions-4-recursion/ -- I adapted
one of your functions there to apply the override to all objects with a
stencil property.  (Rather than using a long string of laboriously typed
overrides.)

--DN




\version "2.19.17"

#(define (grobs-with-stencils)
   (let loop ((all all-grob-descriptions) (result '()))
 (if (null? all)
 result
 (if (assoc-get 'stencil (cdar all))
 (loop (cdr all) (cons (caar all) result))
 (loop (cdr all) result)

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (default-after-line (assoc-get 'after-line-breaking default))
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob,
but
 ;; we can find them through the music event which led to the grob.
This
 ;; is available through the stream-event which caused our grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) red)))
 (set! (ly:grob-property grob 'color) green))

 ;; Return any default setting of after-line-breaking.
 (or default-after-line '(


markAllAlteredGrobs =
#(define-music-function (parser location) ()
   (let loop ((grobs (grobs-with-stencils)))
 (if (null? grobs)
 #{ #}
 #{
   \override #(list 'Score (car grobs) 'after-line-breaking) =
#mark-tweak
   #(loop (cdr grobs))
 #})))

{
  \markAllAlteredGrobs
  c'
  \once \override NoteHead.font-size = 3
  c'
  c'
  \tweak font-size 3 c'
  c'
  %\override Slur.after-line-breaking = #mark-tweak
  c'( e')
  \shape #'((0 . 0) (0 . -0.5) (0 . -0.5) (0 . 0)) Slur
  c'( e')
  c'( e')
  c'-\tweak Slur.positions #'(-5 . -5) ( e')
  \override Hairpin.color = #blue
  c'\< e'\!
  \arpeggio
  \once \override Staff.Arpeggio.positions = #'(-6 . 6)
  \arpeggio

}
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread Jim Long
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")

If the grob doesn't know whether it's been tweaked, then perhaps
\tweak could do it?  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.

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.



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread David Nalesnik
On Mon, Apr 27, 2015 at 12:12 PM, David Nalesnik 
wrote:

Here's a code snippet to show that it is possible to tell if a grob has
> been altered.  Right now you have to add the procedure for each grob you
> want to examine.
>
>
Oh, I should mention that overrides have been colored green and tweaks red,
for no real reason.

DN
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread David Nalesnik
Hi,

On Mon, Apr 27, 2015 at 9:44 AM, Urs Liska  wrote:

>
>
> Am 27.04.2015 um 16:27 schrieb Noeck:
>
>> Dear all, dear Urs,
>>
>> I would like to color tweaks of a particular edition of the edition
>> engraver. I know that there is a checkbox in Frescobaldi to color, so it
>> seems possible to color tweaked grobs in general.
>>
>
> No, I don't think this is possible, although I would really like to have
> that feature (to immediately make visible what is "original" and what is
> "manual").
>
> 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.
>

Here's a code snippet to show that it is possible to tell if a grob has
been altered.  Right now you have to add the procedure for each grob you
want to examine.

\version "2.19.17"

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
  (props (ly:grob-basic-properties grob))
  ;; Our procedure has been added to the head of grob's basic
  ;; properties.  Let's not count it as a tweak!
  (props
   (remove
(lambda (p)
  (and (procedure? (cdr p))
   (eq? (procedure-name (cdr p)) 'mark-tweak)))
props))
  (diff (lset-difference eq? props default)))
 ;; Tweaks will not appear in the "basic properties" alist of our grob,
but
 ;; we can find them through the music event which led to the grob.
This
 ;; is (currently) available through the stream-event which caused our
grob.
 (if (null? diff)
 (let* ((cause (event-cause grob))
(tweaks (and cause
 (ly:music-property
  (ly:event-property cause 'music-cause)
  'tweaks
   (if (pair? tweaks)
   (set! (ly:grob-property grob 'color) red)))
 (set! (ly:grob-property grob 'color) green

{
  \override NoteHead.after-line-breaking = #mark-tweak
  c'
  \once \override NoteHead.font-size = 3
  c'
  c'
  \tweak font-size 3 c'
  c'
  \override Slur.after-line-breaking = #mark-tweak
  c'( e')
  \shape #'((0 . 0) (0 . -0.5) (0 . -0.5) (0 . 0)) Slur
  c'( e')
}

%%%

Hope this is helpful.
David
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread Jan-Peter Voigt
Hi Joram, hi Urs, 

I shall  add this to my todo list. 
Hope to be able to work on it. 

Cheers, 
Jan-Peter 

Am 27. April 2015 17:51:31 MESZ, schrieb Noeck :
>Hi Urs,
>
>thanks. I hoped it was easier. But then I will just color them by hand.
>
>Cheers,
>Joram
>
>___
>lilypond-user mailing list
>lilypond-user@gnu.org
>https://lists.gnu.org/mailman/listinfo/lilypond-user

-- 
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread Noeck
Hi Urs,

thanks. I hoped it was easier. But then I will just color them by hand.

Cheers,
Joram

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Color tweaks (edition engraver)

2015-04-27 Thread Urs Liska



Am 27.04.2015 um 16:27 schrieb Noeck:

Dear all, dear Urs,

I would like to color tweaks of a particular edition of the edition
engraver. I know that there is a checkbox in Frescobaldi to color, so it
seems possible to color tweaked grobs in general.


No, I don't think this is possible, although I would really like to have 
that feature (to immediately make visible what is "original" and what is 
"manual").


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.




What I would like is to specify a color (of my choice) for each of the
editions I define in the edition engraver. Do you see an easy way or
should I rather add a color override for each modification by hand?


I don't think that's possible, but I think it would be a useful 
enhancement to the edition-engraver. So you might add a wish on 
openLIiylIb's tracker.?


Urs



Cheers,
Joram

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user