%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "snippets/adding-links-to-objects.ly"
\sourcefileline 0
%% DO NOT EDIT this file manually; it was automatically
%% generated from the LilyPond Wiki
%% (https://wiki.lilypond.community).
%%
%% Make any changes in the Wiki itself, or in
%% `Documentation/snippets/new/`, then run
%% `scripts/auxiliar/makelsr.pl`.
%%
%% This file is in the public domain.

\version "2.24.0"

\header {
%% Translation of GIT committish: f11513f36c131dab18338d6a3a729e24a927150d
  texidocja = "
grob-stencil にリンクを追加する場合、ここに定義されている @code{add-link} を@c
使用することができます。@code{\\override} や @code{\\tweak} と動作します。@c
ただし、リンクが設定された Grob は @code{point-and-click} が無効になります。

制限: PDF でのみ動作します。

リンクされたオブジェクトに色が付いているのは、別のコマンドによるものです。
"
  doctitleja = "オブジェクトにリンクを追加する"

%% Translation of GIT committish: c043783aac6c35926d633aa2daf60ed4f2e7ca7a
  texidocfr = "
La fonction @code{add-link}, telle que définie ci-dessous, permet
d'ajouter un lien au stencil d'un objet graphique.  Elle s'emploie
au sein d'un @code{\\override} ou d'un @code{\\tweak}.

À noter que le fonctionnemment du @code{point-and-click} est perturbé
sur les objets ainsi liés.

Cette fonction n'est opérationnelle que pour une sortie PDF.

La coloration des objets liés s'obtient par une commande séparée.
"

  doctitlefr = "Ajout de liens à des objets"

%% Translation of GIT committish: 70abecb938c2bb752967bd56b7402dd8129838a5
  texidoces = "
Para añadir un enlace al sello de un objeto gráfico, podemos usar
@code{add-link} tal y como se define aquí.  Funciona con
@code{\\override} y con @code{\\tweak}.

Inconveniente: @code{point-and-click} (apuntar y pulsar) quedará
obstacuilzado por los objetos gráficos enlazados.

Limitación: funciona solamente para PDF.

Los objetos enlazados se colorean con una instrucción aparte.
"
  doctitlees = "Añadir enlaces a los objetos"

%% Translation of GIT committish: ff9ca62acddb818b7788d7818a5c7eb0ddb6cdcb
  texidocca = "
Per afegir un enllaç al segell d'un objecte gràfic, podem usar
@code{add-link} tal i com es defineix aquí.  Funciona amb
@code{\\override} i amb @code{\\tweak}.  Inconvenient:
@code{point-and-click} (apuntar i clicar) quedarà obstaculitzat
pels objectes gràfics enllaçats.

Limitació: funciona sols per a PDF.

Els objectes enllaçats s'acoloreixen amb una ordre a part.

"
  doctitleca = "Afegir enllaços als objectes"

  categories = "Editorial annotations, Scheme, Tweaks and overrides"

  texidoc = "
To add a link to a grob stencil you can use @code{add-link} as defined
here. It works both with @code{\\override} and @code{\\tweak}.

Drawback: @code{point-and-click} is disturbed for the linked grobs.

Limitation: Works for PDF only.

The linked objects are colored with a separate command.
"

  doctitle = "Adding links to objects"
} % begin verbatim


#(define (add-link url-strg)
  (lambda (grob)
    (let* ((stil (ly:grob-property grob 'stencil)))
      (if (ly:stencil? stil)
          (let* ((x-ext (ly:stencil-extent stil X))
                 (y-ext (ly:stencil-extent stil Y))
                 (url-expr `(url-link ,url-strg ,x-ext ,y-ext))
                 (new-stil
                   (ly:stencil-add
                     (ly:make-stencil url-expr x-ext y-ext)
                     stil)))
          (ly:grob-set-property! grob 'stencil new-stil))))))

%%%% test

%% For easier maintenance of this snippet the URL is formatted to use the
%% actually used LilyPond version.
%% Of course a literal URL would work as well.

#(define major.minor-version
  (string-join (take (string-split (lilypond-version) #\.) 2) "."))

urlI =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/writing-pitches"
  major.minor-version)

urlII =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/rhythms"
  major.minor-version)

urlIII =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/note-heads"
  major.minor-version)

urlIV =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/beams"
  major.minor-version)

urlV =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/note-head-styles"
  major.minor-version)

urlVI =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/writing-pitches"
  major.minor-version)

\relative c' {
   \key cis \minor

   \once \override Staff.Clef.color = #green
   \once \override Staff.Clef.after-line-breaking =
     #(add-link urlI)

   \once \override Staff.TimeSignature.color = #green
   \once \override Staff.TimeSignature.after-line-breaking =
     #(add-link urlII)

   \once \override NoteHead.color = #green
   \once \override NoteHead.after-line-breaking =
     #(add-link urlIII)

   cis'1
   \once \override Beam.color = #green
   \once \override Beam.after-line-breaking =
     #(add-link urlIV)
   cis8 dis e fis gis2
   <gis,
    \tweak Accidental.color #green
    \tweak Accidental.after-line-breaking #(add-link urlVI)
    \tweak color #green
    \tweak after-line-breaking #(add-link urlV)
    \tweak style #'harmonic
    bis
    dis
    fis
   >1
   <cis, cis' e>
}



% ****************************************************************
% end ly snippet
% ****************************************************************
