]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/adding-links-to-objects.ly
Doc-fr: updates texidocs
[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.dsi.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.17.6"
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 % Code by Thomas Morley
26 % Contributed by harm6
27 % Tested with 2.14.2 up to 2.17.9
28
29 #(define (add-link url-strg)
30   (lambda (grob)
31     (let* ((stil (ly:grob-property grob 'stencil)))
32       (if (ly:stencil? stil)
33         (begin
34           (let* (
35              (x-ext (ly:stencil-extent stil X))
36              (y-ext (ly:stencil-extent stil Y))
37              (url-expr (list 'url-link url-strg `(quote ,x-ext) `(quote ,y-ext)))
38              (new-stil (ly:stencil-add (ly:make-stencil url-expr x-ext y-ext) stil)))
39           (ly:grob-set-property! grob 'stencil new-stil)))
40         #f))))
41
42 %%%% test
43
44 urlI =
45 "http://lilypond.org/doc/v2.14/Documentation/notation/writing-pitches"
46
47 urlII =
48 "http://lilypond.org/doc/v2.14/Documentation/notation/rhythms"
49
50 urlIII =
51 "http://lilypond.org/doc/v2.14/Documentation/notation/note-heads"
52
53 urlIV =
54 "http://lilypond.org/doc/v2.14/Documentation/notation/beams"
55
56 urlV =
57 "http://lilypond.org/doc/v2.14/Documentation/notation/note-head-styles"
58
59 \relative c' {
60   \key cis \minor
61
62   \once \override Staff.Clef.color = #green
63   \once \override Staff.Clef.after-line-breaking =
64     #(add-link urlI)
65
66   \once \override Staff.TimeSignature.color = #green
67   \once \override Staff.TimeSignature.after-line-breaking =
68     #(add-link urlII)
69
70   \once \override NoteHead.color = #green
71   \once \override NoteHead.after-line-breaking =
72     #(add-link urlIII)
73
74   cis'1
75   \once \override Beam.color = #green
76   \once \override Beam.after-line-breaking =
77     #(add-link urlIV)
78   cis8 dis e fis gis2
79   <gis,
80    % With 2.17.9 you could use the command below to address the Accidental.
81    % \tweak Accidental.before-line-breaking #(add-link url)
82    \tweak color #green
83    \tweak after-line-breaking #(add-link urlV)
84    \tweak style #'harmonic
85    bis
86    dis
87    fis
88   >1
89   <cis, cis' e>
90 }