%% 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/using-ly-grob-object-to-access-grobs-with--tweak.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: a8a85e19654e46d725563e6deba44083ef137a2c
  texidocja = "
いくつかの Grob は、他の Grob のコールバックから@c
アクセスすることができます。これらは通常、grob-interface の
\"Internal properties\" セクションにある \"layout objects\" にリストアップ@c
されています。@code{ly:grob-object} は、これらの Grob にアクセスするために@c
使用します。

以下に示したのは、NoteHead コールバック内で Grob にアクセスする@c
いくつかの方法ですが、このテクニックは NoteHead に限ったものではありません。@c
しかし、NoteHead は @code{\\tweak} コマンドで暗黙的に指定されるために、@c
このコールバックは特に重要です。

以下で定義された例の関数 (\"display-grobs\") はそこまで有用ではないかも@c
しれませんが、Grob が実際にアクセスできることを示しています。

例のコンソール出力:

@code{ #Grob Accidental () #Grob Stem}
"
  doctitleja = "\\tweak で Grob にアクセスするために ly:grob-object を用いる"

%% Translation of GIT committish: c043783aac6c35926d633aa2daf60ed4f2e7ca7a
  texidocfr = "
Certains objets graphiques ne sont accessibles que par le biais d'un
@emph{callback} à partir d'un autre @code{grob}. Ils sont normalement
listés dans les « @emph{layout objects} » au sein de la section
« Propriétés internes » d'une @emph{grob interface}. La fonction
@w{@code{ly:grob-object}} permet d'accéder à ces objets.

Voici plusieurs moyens d'accéder aux objets par un @emph{callback} sur
@code{NoteHead}. D'autres biais sont naturellement possibles ;
@code{NoteHead} a cependant l'avantage incontestable d'être utilisé
implicitement par la commande @code{\\tweak}.

Voici ce qui sera émis dans la console suite à la fonction
@code{display-grobs} ici construite.

@example
--------------------
#<Grob Accidental >
()
#<Grob Stem >
@end example

Cette fonction n'est probablement pas très utile. Elle indique toutefois
qu'il est tout à fait possible d'accéder aux objets.
"

  doctitlefr = "Utilisation de @code{ly:grob-object} pour accéder aux @emph{grobs} avec @code{\\tweak}"

%% Translation of GIT committish: 70abecb938c2bb752967bd56b7402dd8129838a5
  texidoces = "
Se puede acceder @qq{lateralmente} a algunos grobs desde dentro de
la función de callback de otro grob.  Éstos se encuentran
relacionados normalmente como @qq{layout objects} (objetos de
presentación) en la sección @qq{Internal properties} (propiedades
internas) de un interface de grob.  Se usa la función
@code{ly:grob-object} para acceder a estos grobs.

Se presentan más abajo como ejemplo algunas formas de addecer a
grobs desde dentro de una función de callback de @code{NoteHead},
pero la técnica no se limita a las cabezas de nota.  Sin embargo,
la función de callback de @code{NoteHead} es especialmente
importante, porque es la función de callback implícita que utiliza
la instrucción @code{\\tweak}.

La salida de consola de la función de ejemplo que se muestra abajo
(@code{display-grobs}) es como sigue.

@example
--------------------
#<Grob Accidental >
()
#<Grob Stem >
@end example

Probablemente no es tan útil, pero muestra que efectivamente se
puede acceder a los objetos gráficos.
"
  doctitlees = "Utilizar ly:grob-object para acceder a los grobs con \\tweak"

%% Translation of GIT committish: 8ffecf6be17c6ec2ff87cf31873121a8cce29b09
  texidocca = "
Es pot accedir \"lateralment\" a alguns grobs des de dins de la
funció de callbak d'un altre grob.  Aquests es troben relacionats
normalment com \"layout objects\" (objectes de presentació) en la
secció \"Internal properties\" (propietats internes) d'una
interfície de grob.  S'usa la funció ly:grob-object per a
accedir a aquests grobs.

Es presenten més avall com a exemple algunes formes d'accedir a
grobs des de dins d'una funció de callblack de NoteHead, però la
tècnica no es limita als caps de nota.  No obstant, la funció de
callblack de NoteHead és especialment important, perquè és la
funció de callback implícita que utilitza l'ordre @code{\\tweak}.

La funció d'exemple que es defineix sota (\"display-grobs\") no és
probablement tan útil, però mostra que s'està accedint
efectivament als grobs.

Sortida d'exemple de la consola:


@example
--------------------
#-Grob Accidental -
#-Grob Arpeggio -
#-Grob Stem -
@end example

"
  doctitleca = "Utilitzar ly:grob-object per accedir als grobs amb \\tweak"

  categories = "Scheme, Tweaks and overrides"

  texidoc = "
Some grobs can be accessed @qq{laterally} from within another grob's
callback. These are usually listed as @qq{layout objects} in the @qq{Internal
properties} section of a grob interface. The function
@code{ly:grob-object} is used to access these grobs.

Demonstrated below are some ways of accessing grobs from within a
@code{NoteHead} callback, but the technique is not limited to
@code{NoteHead}s. However, the @code{NoteHead} callback is particularly
important, since it is the implicit callback used by the @code{\\tweak}
command.

The console output of the example function below (@code{display-grobs})
is as follows.

@example
--------------------
#<Grob Accidental >
()
#<Grob Stem >
@end example

It is probably not that useful, but it demonstrates that the grobs are
indeed being accessed.
"

  doctitle = "Using ly:grob-object to access grobs with \\tweak"
} % begin verbatim


#(define (notehead-get-accidental notehead)
   ;; notehead is grob
   (ly:grob-object notehead 'accidental-grob))

#(define (notehead-get-arpeggio notehead)
   ;; notehead is grob
   (let ((notecolumn (notehead-get-notecolumn notehead)))
     (ly:grob-object notecolumn 'arpeggio)))

#(define (notehead-get-notecolumn notehead)
   ;; notehead is grob
   (ly:grob-parent notehead X))

#(define (notehead-get-stem notehead)
   ;; notehead is grob
   (let ((notecolumn (notehead-get-notecolumn notehead)))
     (ly:grob-object notecolumn 'stem)))

#(define (display-grobs notehead)
   ;; notehead is grob
   (let ((accidental (notehead-get-accidental notehead))
         (arpeggio (notehead-get-arpeggio notehead))
         (stem (notehead-get-stem notehead)))
     (format (current-error-port) "~2&~a\n" (make-string 20 #\-))
     (for-each
      (lambda (x) (format (current-error-port) "~a\n" x))
      (list accidental arpeggio stem))))

\relative c' {
  %% display grobs for each note head:
  %\override NoteHead.before-line-breaking = #display-grobs
  <c
  %% or just for one:
  \tweak before-line-breaking #display-grobs
  es
  g>1\arpeggio
}



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