Re: Stencil questions (adding text and defining line style)

2016-09-21 Thread Urs Liska
Hi Nathan (and Harm and David),


Am 21.09.2016 um 23:43 schrieb Nathan Ho:
> Hi Urs,
>
> grob-interpret-markup is the way to create text. You can position it
> with ly:stencil-translate, and add it to another stencil using
> ly:stencil-add:
>
> (ly:stencil-add
>   your-current-stencil
>   (ly:stencil-translate
> (grob-interpret-markup
>   grob
>   (markup "Hey"))
> '(2 . 3)))

and here's to that: I noticed that with more than a few inflections it
becomes hard to match the definition in the file with the result in the
score. Adding index labels makes this easier, although there's no real
reference to the index number in the file.

Maybe one could allow to specify an optional label, and only if that's
present print it. That will allow the user to print *some* labels for
easier navigation, without requiring him to add labels to all inflections.

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


Re: Stencil questions (adding text and defining line style)

2016-09-21 Thread Urs Liska
Hi David,


Am 21.09.2016 um 23:47 schrieb David Nalesnik:
> Hi Urs,
>
> On Wed, Sep 21, 2016 at 1:49 PM, Urs Liska  wrote:
>> Hi all,
>>
>> it may seem unprobable but I don't find the information how I can add
>> some text to my constum-made stencils.
>>
>> Concretely I want to add a text element at a certain position to a
>>   (ly:stencil-add
>> construction
> You would probably create the text stencil using grob-interpret-markup.
> .
>> The other thing I didn't find is: how can I create a dashed (or
>> otherwise styled) line stencil with make-line-stencil?
> You should use ly:line-interface::line (which is available from
> 2.19.27, off the top of my head).
>
> Here's an example with both text and different line styles.
>
> (Even though TextScript doesn't support line-interface, you can still
> tweak line-related properties!)
>
> \version "2.19.46"
>
> #(define (my-stencil grob)
>(let* ((line (ly:line-interface::line grob 1.5 0 6 0))
>   (text (grob-interpret-markup grob "A"))
>   (stil (apply ly:stencil-add (list line text
>  stil))
>
> {
>   \override TextScript.stencil = #my-stencil
>   c''1 -\tweak style #'dashed-line ^""
>   c''1 -\tweak style #'zigzag ^""
> }

Thank you, I could integrate this into my slur editing (helper)
interface. Attached you can see how the handles to the second and third
control points are prolonged by a dashed line. This actually makes
editing easier because the length of this handle (i.e. the distance from
the end points to the neighboring control points) is defined as the
ratio to the baseline. Seeing the "1" unit as a dashed line makes it
much easier to judge what value to try next.

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


Re: Stencil questions (adding text and defining line style)

2016-09-21 Thread Thomas Morley
Hi Urs,

2016-09-21 23:47 GMT+02:00 David Nalesnik :

>> The other thing I didn't find is: how can I create a dashed (or
>> otherwise styled) line stencil with make-line-stencil?

I was going to write:
If you regard the basics you'll see something like the following example:

\markup
  \box {
  \stencil
#(ly:make-stencil
   (list
 'dashed-line
 0.2 ; width
 0.5 ;; on
 0.5 ; off
 10 ;; x-end
 10 ;; y-end
 0 ;; phase
 )
   ;; x-ext
   (cons 0 10)
   ;; y-ext
   (cons 0 10))
  \stencil
#(ly:make-stencil
   (list
 'draw-line
 0.2 ; width
 0  ; startx
 0 ; starty
 10 ; endx
 10 ;endy
 )
   '(0 . 10)
  '(0 . 10))
}

So there's no direct method to switch between both, because of the
kind and amount of arguments differ.
But you can use some "meta"-functions like:

(and now follow David' reply)


>
> You should use ly:line-interface::line (which is available from
> 2.19.27, off the top of my head).
>
> Here's an example with both text and different line styles.
>
> (Even though TextScript doesn't support line-interface, you can still
> tweak line-related properties!)
>
> \version "2.19.46"
>
> #(define (my-stencil grob)
>(let* ((line (ly:line-interface::line grob 1.5 0 6 0))
>   (text (grob-interpret-markup grob "A"))
>   (stil (apply ly:stencil-add (list line text
>  stil))
>
> {
>   \override TextScript.stencil = #my-stencil
>   c''1 -\tweak style #'dashed-line ^""
>   c''1 -\tweak style #'zigzag ^""
> }
>
>>
>> More generally: how can I learn more about these things? Searching
>> lilypond.org seems to only point to snippets and no real explanations.
>
> There's not much to go on.
>
> grob-interpret-markup is mentioned here:
> http://lilypond.org/doc/v2.19/Documentation/extending/callback-functions
>
> The function doesn't have a docstring:
>
> #(display (procedure-documentation grob-interpret-markup))
>
> returns #f ...
>
> ly:line-interface::line is listed in the IR (Scheme functions)
>
> Sorry I can't be more helpful.
>
> David

Cheers,
  Harm

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


Re: Stencil questions (adding text and defining line style)

2016-09-21 Thread David Nalesnik
Hi Urs,

On Wed, Sep 21, 2016 at 1:49 PM, Urs Liska  wrote:
> Hi all,
>
> it may seem unprobable but I don't find the information how I can add
> some text to my constum-made stencils.
>
> Concretely I want to add a text element at a certain position to a
>   (ly:stencil-add
> construction

You would probably create the text stencil using grob-interpret-markup.
.
>
> The other thing I didn't find is: how can I create a dashed (or
> otherwise styled) line stencil with make-line-stencil?

You should use ly:line-interface::line (which is available from
2.19.27, off the top of my head).

Here's an example with both text and different line styles.

(Even though TextScript doesn't support line-interface, you can still
tweak line-related properties!)

\version "2.19.46"

#(define (my-stencil grob)
   (let* ((line (ly:line-interface::line grob 1.5 0 6 0))
  (text (grob-interpret-markup grob "A"))
  (stil (apply ly:stencil-add (list line text
 stil))

{
  \override TextScript.stencil = #my-stencil
  c''1 -\tweak style #'dashed-line ^""
  c''1 -\tweak style #'zigzag ^""
}

>
> More generally: how can I learn more about these things? Searching
> lilypond.org seems to only point to snippets and no real explanations.

There's not much to go on.

grob-interpret-markup is mentioned here:
http://lilypond.org/doc/v2.19/Documentation/extending/callback-functions

The function doesn't have a docstring:

#(display (procedure-documentation grob-interpret-markup))

returns #f ...

ly:line-interface::line is listed in the IR (Scheme functions)

Sorry I can't be more helpful.

David

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


Re: Stencil questions (adding text and defining line style)

2016-09-21 Thread Nathan Ho

On 2016-09-21 11:49, Urs Liska wrote:


Concretely I want to add a text element at a certain position to a
  (ly:stencil-add
construction.


Hi Urs,

grob-interpret-markup is the way to create text. You can position it 
with ly:stencil-translate, and add it to another stencil using 
ly:stencil-add:


(ly:stencil-add
  your-current-stencil
  (ly:stencil-translate
(grob-interpret-markup
  grob
  (markup "Hey"))
'(2 . 3)))

ly:stencil-combine-at-edge is also really handy if you want to position 
a stencil relative to bounding box of another one, like "place this 
thing vertically centered so its left edge is 0.1 staff spaces away from 
the right edge of this other thing."



The other thing I didn't find is: how can I create a dashed (or
otherwise styled) line stencil with make-line-stencil?


I don't think it's possible, but you can use draw-dashed-line / 
draw-dotted-line in a grob-interpret-markup.



More generally: how can I learn more about these things? Searching
lilypond.org seems to only point to snippets and no real explanations.


I've generally relied on examining examples in the LSR to learn about 
this sort of thing. The "Scheme functions" section of the Notation and 
Internals manuals is helpful, but a lot of the functions are not clearly 
documented, and they're definitely not presented in a manner that's 
conducive to step-by-step learning.


Since it's pretty tough to use stencils, as you can see I resort a lot 
to markups. They're not the perfect solution, but they're better 
documented and easier to use.



Nathan

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


Stencil questions (adding text and defining line style)

2016-09-21 Thread Urs Liska
Hi all,

it may seem unprobable but I don't find the information how I can add
some text to my constum-made stencils.

Concretely I want to add a text element at a certain position to a
  (ly:stencil-add
construction.

The other thing I didn't find is: how can I create a dashed (or
otherwise styled) line stencil with make-line-stencil?

More generally: how can I learn more about these things? Searching
lilypond.org seems to only point to snippets and no real explanations.

TIA
Urs

-- 
Urs Liska
www.openlilylib.org

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