[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to return markup conditionally?
From: |
Valentin Petzel |
Subject: |
Re: How to return markup conditionally? |
Date: |
Wed, 19 Jul 2023 20:39:37 +0200 |
Hello Trevor,
instead of trying to use a callback on bound-details.left.text you can use the
before-line-breaking and after-line-breaking hooks to modifiy this property:
%%% BEGIN %%%
\version "2.24"
% no left text set
{
\once \override TextSpanner.before-line-breaking =
#(lambda (grob)
(let* ((bound-details (ly:grob-property grob 'bound-details))
(left (assoc-get 'left bound-details))
(left (assoc-set!
left
'text
(if (equal? red (ly:grob-property grob 'color))
(markup "foo")
(markup "bar"))))
(bound-details (assoc-set! bound-details 'left left)))
(ly:grob-set-property! grob 'bound-details bound-details)))
c'1
- \tweak color #red
\startTextSpan
c'1
\stopTextSpan
}
%%% END %%%
In your case you want to use after-line-breaking, as you want to work with the
broken copies.
Then basically what you want to do is:
- If you want to handle the case of an unbroken spanner differently, use
(unbroken-spanner? grob) to check if the spanner is not broken
- Use (unbroken-or-last-broken-spanner? grob) to determine if the grob is the
last broken sibling.
- Decide whether your endpoint condition applies (e.g. from (ly:grob-property
grob 'right-bound-info))
- If so set bound-info.right.text to bound-info.right.right-broken
Cheers,
Valentin
>
> The problem I'm wanting to solve has to do with swapping a text spanner's
> right text for its right-broken text, conditionally based on the spanner's
> end position. The problem looks complicated, so I'll introduce it as a
> separate thread.
>
> Trevor.
signature.asc
Description: This is a digitally signed message part.
- How to return markup conditionally?, Trevor Bača, 2023/07/18
- Re: How to return markup conditionally?, David Kastrup, 2023/07/19
- Re: How to return markup conditionally?, Trevor Bača, 2023/07/19
- Re: How to return markup conditionally?,
Valentin Petzel <=
- Re: How to return markup conditionally?, Jean Abou Samra, 2023/07/19
- Re: How to return markup conditionally?, Valentin Petzel, 2023/07/19
- Re: How to return markup conditionally?, Jean Abou Samra, 2023/07/19
- Re: How to return markup conditionally?, Valentin Petzel, 2023/07/19
- Re: How to return markup conditionally?, Trevor Bača, 2023/07/20
- Re: How to return markup conditionally?, Valentin Petzel, 2023/07/20
- Re: How to return markup conditionally?, Trevor Bača, 2023/07/21
- Re: How to return markup conditionally?, David Kastrup, 2023/07/20
- Re: How to return markup conditionally?, Trevor Bača, 2023/07/21
- Re: How to return markup conditionally?, Jean Abou Samra, 2023/07/19