lilypond-user
[Top][All Lists]
Advanced

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

Property overrides by ID (discussion)


From: Urs Liska
Subject: Property overrides by ID (discussion)
Date: Fri, 7 Apr 2017 00:28:56 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Hi,

I've done a first implementation of an ID based property override, which
is sort of a complement to the edition-engraver. It's significantly less
complex than the edition-engraver, has some advantages over it, but also
significant limitations.

If you want to have a closer look you may inspect the pull request at
https://github.com/openlilylib/edition-engraver/pull/14.

What it *can* do is apply any property override that could be achieved
with \once \override or \tweak to grobs addressed by an ID. This means
it isn't necessary anymore to bother with finding out when and in which
context the item is. Simply add an ID to it and address it, and there
you go, completely robust against changes in context and timing.

However, at least at the moment, it can only affect individual grobs'
properties, so it's not possible to insert switches like regular
\override's (only \once) or actual elements like breaks, markups or
marks etc. This makes me wonder if it's actually worthwile to have this
- lightweight but limited - implementation around or if it would be
necessary to rather find a way to modify the existing edition-engraver
commands to also address IDs.

I've created an additional property 'eid (edition-engraver ID) because
for use as a lookup key the ID should be a symbol and not a string as
LilyPond's 'id property. But I'm not sure if this is a good idea and if
I should rather redefine the "real" 'id property.

There are a few convenience commands which you can see from the example
file (in the pull request and following below, results attached):

\include "edition-engraver/edition-engraver.ily"

\activateIdMods Tie.NoteHead.Beam

% Apply a single property override to a single grob
\idMod #'b color #red

% Apply multiple property overrides to a single grob
\idMods A
#`((color . ,blue)
   (extra-offset . (-1.5 . -0.5)))

\relative c' {
  <c -\tweak Tie.eid #'a ~
  \tweak eid #'A
  e
  -\tweak Tie.eid #'b ~
  g -\tweak Tie.eid #'c ~
  c -\tweak Tie.eid #'d ~
  >1
  <c e g c>
}

% Apply the same property override to multiple grobs
\idModList positions #'(4 . 4) #'(Ba Bb Bc Bd)
\relative {
  \stemUp
  \once \override Beam.eid = #'Ba
  c'8 d e f
  \once \override Beam.eid = #'Bb
  g e d b'
  \once \override Beam.eid = #'Bc
  c e a, c
  \once \override Beam.eid = #'Bd
  fis, a dis, fis
}

% Apply different values to the same property of multiple grobs
% Not specifying the value for a grob uses the default
\idVarModList color #red
#`((Be . ,blue)
   (Bf . ,magenta)
   Bg
   (Bh . ,green))

\relative {
  \stemUp
  \once \override Beam.eid = #'Be
  c'8 d e f
  \once \override Beam.eid = #'Bf
  g e d b'
  \once \override Beam.eid = #'Bg
  c e a, c
  \once \override Beam.eid = #'Bh
  fis, a dis, fis
}

I'd be happy about any feedback.
Urs

-- 
address@hidden
https://openlilylib.org
http://lilypondblog.org

Attachment: id-mods.pdf
Description: Adobe PDF document


reply via email to

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