[Top][All Lists]

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

Re: New markup command `parenthesize'

From: Neil Puttock
Subject: Re: New markup command `parenthesize'
Date: Tue, 28 Jul 2009 00:32:48 +0100

2009/7/26 Thomas Morgan <address@hidden>:
> Here is a patch which defines `parenthesize', a new markup command
> which works like `bracket'.  It's mainly useful for parenthesizing
> columns containing several lines of text.

Very shapely parentheses. :)

Here are a few comments on your patch:

>    In `scm/define-grob-properties.scm', define property `angularity'
>    that controls the shape of parentheses.  Add this property
>    to TextScript grob definition in `scm/define-grobs.scm' and
>    to text script interface in `lily/'.

This doesn't belong in text-script-interface; it would make more sense
being part of text-interface, though I'm unsure why you've singled out
this particular property to be a grob property (see below).

There is an argument to be made for making many of the markup
properties part of text-interface (since it would allow the user to
override TextScript without being annoyed by warning messages for
missing type-checks), but the majority of specific properties for
other markup commands are defined solely within the code (e.g.,
box-padding for \box).

> +(define-builtin-markup-command (parenthesize layout props arg)
> +  (markup?)
> +  graphic
> +  ()

This is where you should place the defaults for the markup command's
used properties (including angularity):

((angularity 0)
 (size 1)
 (thickness 1)
 (width 0.25))

Since padding defaults to half-thickness if it's not set by the user,
it has no default value here.

> +  (let* ((markup (interpret-markup layout props arg))
> +        (size (chain-assoc-get 'size props 1))
> +        (width (* size (chain-assoc-get 'width props 0.25)))
> +        (thickness (* (chain-assoc-get 'line-thickness props 0.1)
> +                      (chain-assoc-get 'thickness props 1)))
> +        (half-thickness (min (* size 0.5 thickness)
> +                             (* (/ 4 3.0) width)))
> +        (angularity (chain-assoc-get 'angularity props 0))
> +        (padding (chain-assoc-get 'padding props half-thickness)))

If you set the properties as detailed above, you can get rid of most
of the chain-assoc-get calls:

  (let* ((markup (interpret-markup layout props arg))
         (scaled-width (* size width))
         (thick (* (chain-assoc-get 'line-thickness props 0.1)
         (half-thickness (min (* size 0.5 thick)
                              (* (/ 4 3.0) scaled-width)))
         (padding (chain-assoc-get 'padding props half-thickness)))

> +(define (parenthesize-stencil

define-public like bracketify-stencil so it's available for use outside markup.

> +    (set! stencil (ly:stencil-combine-at-edge lp X 1 stencil padding))
> +    (set! stencil (ly:stencil-combine-at-edge stencil X 1 rp padding))

You can use RIGHT instead of 1 for both of these.


reply via email to

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