lilypond-user
[Top][All Lists]
Advanced

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

Re: Making markup functions parametric


From: Urs Liska
Subject: Re: Making markup functions parametric
Date: Sat, 04 Jul 2020 12:50:17 +0200
User-agent: Evolution 3.36.3-1

Hi Lukas,

Am Samstag, den 04.07.2020, 10:22 +0200 schrieb Lukas-Fabian Moser:
> Hi Urs,
> 
> > I have tried various things, but I don't seem to understand how
> > that
> > primitive-eval actually works here. Your solution does only work
> > when
> > the input is a simple markup (string), not when it is wrapped in
> > other
> > markup commands.
> 
> It seems to work quite robustly if you draw the given content markup 
> into a stencil and insert this stencil in the markup expression that 
> will be fly-evaluated:
> 
> \version "2.20"
> 
> #(define (get-scheme-markup-function func)
>     (symbol-append 'make- func '-markup))
> 
> #(define-markup-command (enclose layout props func content)(symbol?
> markup?)
>     (interpret-markup layout props
>                       (primitive-eval
>                        (list 'markup
>                              (list
>                               (get-scheme-markup-function func)
>                               `(make-stencil-markup ,(interpret-
> markup 
> layout props content)))))))
> 
> \markup \enclose #'box "C"
> \markup \enclose #'circle \italic \concat { "Camel" "Case" }
> \markup \enclose #'circle \enclose #'box \italic "E"
> 
> Does this help?
> 

Yes, indeed, thank you very much! With it I could for now complete my
function for a highly configurable object to denote the reference key
in harmonic analysis.

The following code produces the (non-sensical) attached result. It is
also a first demonstration of the new "properties/property
sets/presets" feature I'm right now finalizing for openLilyLib.
If you want to check it our yourself, the code is in oll-core (branch
'properties') and anaLYsis (branch 'harmony-initial'). The full
implementation of the function (also with property sets in action) can
be seen in 
https://github.com/openlilylib/analysis/blob/harmony-initial/harmony/ref-key.ily
When a function is created with the with-property-set macro arguments
are type-checked against the property set, defaults are given,
properties can be changed globally, in presets or locally in a call.
Within a function there's a function 'property' available to retrieve
the current property value. There's also a function 'use-preset' (not
used in this example, which works together with a set of preset filters
to determine whether a function should be "used" based on the given
presets. This can be used to selectively activate functions, for
example to hide them until needed or to highlight them on demand. The
Frames, Arrows, and Highlighters modules of anaLYsis are the first
real-world examples for this new functionality, which I'm pretty
excited about.

Best
Urs

\version "2.20.0"

\include "oll-core/package.ily"
\loadModule analysis.harmony

\definePreset \with {
  color = #red
  box-padding = 1
} analysis.harmony.ref-key default

\definePreset \with {
  parent = default
  box-type = ellipse
  box-padding = 0.3
  space-before-separator = 0.7
} analysis.harmony.ref-key one

\definePreset \with {
  parent = default
  accidental-size = 4
  space-before-accidental = -0.5
} analysis.harmony.ref-key two


{
  <<
    \new Staff { c' d' e' f' g' a' b' c' }
    \new Lyrics \lyricmode {
      \refKey  \with  { preset = one } C> T1
      \refKey  \with  { preset = two } F< S
    }
  >>
}

(The complete list of (so far) configurable properties for \refKey can
be seen here: 
https://github.com/openlilylib/analysis/blob/harmony-initial/harmony/ref-key.ily#L20-L38
)

> Best
> Lukas
> 
> 

Attachment: ref-keys.png
Description: PNG image


reply via email to

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