]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/adding-links-to-objects.ly
Add '-dcrop' option to ps and svg backends
[lilypond.git] / Documentation / snippets / adding-links-to-objects.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.18.0"
8
9 \header {
10   lsrtags = "editorial-annotations, scheme-language, tweaks-and-overrides"
11
12   texidoc = "
13 To add a link to a grob-stencil you could use @code{add-link} as
14 defined here. Works with @code{\\override} and @code{\\tweak}.
15 Drawback: @code{point-and-click} will be disturbed for the linked grobs.
16
17 Limitation: Works for PDF only.
18
19 The linked objects are colored with a separate command.
20
21 "
22   doctitle = "Adding links to objects"
23 } % begin verbatim
24
25 #(define (add-link url-strg)
26   (lambda (grob)
27     (let* ((stil (ly:grob-property grob 'stencil)))
28       (if (ly:stencil? stil)
29         (begin
30           (let* (
31              (x-ext (ly:stencil-extent stil X))
32              (y-ext (ly:stencil-extent stil Y))
33              (url-expr (list 'url-link url-strg `(quote ,x-ext) `(quote ,y-ext)))
34              (new-stil (ly:stencil-add
35                  (ly:make-stencil url-expr x-ext y-ext) stil)))
36           (ly:grob-set-property! grob 'stencil new-stil)))
37         #f))))
38
39 %%%% test
40
41 urlI =
42 "http://lilypond.org/doc/v2.14/Documentation/notation/writing-pitches"
43
44 urlII =
45 "http://lilypond.org/doc/v2.14/Documentation/notation/rhythms"
46
47 urlIII =
48 "http://lilypond.org/doc/v2.14/Documentation/notation/note-heads"
49
50 urlIV =
51 "http://lilypond.org/doc/v2.14/Documentation/notation/beams"
52
53 urlV =
54 "http://lilypond.org/doc/v2.14/Documentation/notation/note-head-styles"
55
56 \relative c' {
57   \key cis \minor
58
59   \once \override Staff.Clef.color = #green
60   \once \override Staff.Clef.after-line-breaking =
61     #(add-link urlI)
62
63   \once \override Staff.TimeSignature.color = #green
64   \once \override Staff.TimeSignature.after-line-breaking =
65     #(add-link urlII)
66
67   \once \override NoteHead.color = #green
68   \once \override NoteHead.after-line-breaking =
69     #(add-link urlIII)
70
71   cis'1
72   \once \override Beam.color = #green
73   \once \override Beam.after-line-breaking =
74     #(add-link urlIV)
75   cis8 dis e fis gis2
76   <gis,
77    % With 2.17.9 you could use the command below to address the Accidental.
78    % \tweak Accidental.before-line-breaking #(add-link url)
79    \tweak color #green
80    \tweak after-line-breaking #(add-link urlV)
81    \tweak style #'harmonic
82    bis
83    dis
84    fis
85   >1
86   <cis, cis' e>
87 }