%% 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/center-text-below-hairpin-dynamics.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: 0cc270b871321ae5aa8622cea8d8262aafd16641
  texidocja = "
この例はヘアピンの (デ) クレッシェンドの下に @qq{molto} や @qq{poco}
のようなテキストを追加する機能を提供しています。@c
テキストの向きは、ヘアピンの向きに応じて変更されます。ヘアピンは DynamicText
に揃えられます。

この例は Scheme コードを用いて、オブジェクトが通常どのように表示されるかを@c
変更する方法も示しています。
"
  doctitleja = "ヘアピンの下にテキストを中央揃えする"

%% Translation of GIT committish: c043783aac6c35926d633aa2daf60ed4f2e7ca7a
  texidocfr = "
La fonction comprise dans l'extrait suivant permet d'ajouter du texte --
comme « molto » ou « poco » -- à un soufflet de (de)crescendo. Le texte
ajouté viendra se positionner selon le positionnement du soufflet. Le
soufflet s'aligne avec un objet @code{DynamicText}.

Cet exemple présente aussi comment, à l'aide de code
Scheme, influencer la manière dont un objet est normalement imprimé.
"

  doctitlefr = "Texte centré sous un soufflet"

%% Translation of GIT committish: beda50f64452870aee2823454a6cbd75b93f4825
  texidoces = "
Este ejemplo proporciona una función para tipografiar un regulador
con texto por debajo, como @qq{molto} o @qq{poco}.  El texto
añadido cambia la dirección de acuerdo con la del regulador.  El
objeto Hairpin está alineado con un objeto gráfico DynamicText.

El ejemplo ilustra también cómo modificar la manera en que se
imprime normalmente un objeto, utilizando código de Scheme.
"
  doctitlees = "Centrar texto debajo de un regulador"

%% Translation of GIT committish: 46821fda434ae17eccc778bd1a0276e785fffdf6
  texidocca = "
Aquest exemple proporciona una funció per escriure un regulador
amb text a sota, com @qq{molto} o @qq{poco}.  El text afegit
canvia la direcció d'acord amb la del regulador.  L'objecte
hairpin està alineat amb DynamicText.

L'exemple il·lustra també com modificar la manera en la qual 
s'imprimeix normalment un object, utilitzat codi de l'Scheme.

"
  doctitleca = "Centrar text a sota d'un regulador"

  categories = "Expressive marks, Really cool, Scheme, Text"

  texidoc = "
This example provides a function to typeset a hairpin (de)crescendo
with some additional text below it, such as @qq{molto} or @qq{poco}. The
added text will change the direction according to the direction of the
hairpin. The Hairpin is aligned to a @code{DynamicText} grob.

The example also illustrates how to modify the way an object is
normally printed, using some Scheme code.
"

  doctitle = "Center text below hairpin dynamics"
} % begin verbatim


hairpinWithCenteredText =
#(define-music-function (text) (markup?)
  #{
    \once \override Voice.Hairpin.after-line-breaking =
      #(lambda (grob)
         (let* ((stencil (ly:hairpin::print grob))
                (par-y (ly:grob-parent grob Y))
                (dir (ly:grob-property par-y 'direction))
                (staff-line-thickness
                 (ly:output-def-lookup (ly:grob-layout grob)
                                       'line-thickness))
                (new-stencil
                 (ly:stencil-aligned-to
                  (ly:stencil-combine-at-edge
                   (ly:stencil-aligned-to stencil X CENTER)
                   Y dir
                   (ly:stencil-aligned-to
                    (grob-interpret-markup
                     grob
                     (make-fontsize-markup
                      (magnification->font-size
                       (+ (ly:staff-symbol-staff-space grob)
                          (/ staff-line-thickness 2)))
                      text))
                    X CENTER))
                  X LEFT))
                (staff-space (ly:output-def-lookup
                 (ly:grob-layout grob) 'staff-space))
                (par-x (ly:grob-parent grob X))
                (dyn-text (grob::has-interface par-x
                                               'dynamic-text-interface))
                (dyn-text-stencil-x-length
                 (if dyn-text
                     (interval-length
                      (ly:stencil-extent
                       (ly:grob-property par-x 'stencil) X))
                     0))
                (x-shift
                 (if dyn-text (- (+ staff-space dyn-text-stencil-x-length)
                                 (* 0.5 staff-line-thickness))
                     0)))
           (ly:grob-set-property! grob 'Y-offset 0)
           (ly:grob-set-property! grob
                                  'stencil (ly:stencil-translate-axis
                                            new-stencil
                                            x-shift X))))
  #})

hairpinMolto = \hairpinWithCenteredText \markup { \italic molto }
hairpinMore = \hairpinWithCenteredText \markup { \larger moltissimo }

\relative c' {
  \hairpinMolto c2\< c\f
  \hairpinMore c2\ppppp\< c\f
  \break
  \hairpinMolto c2^\< c\f
  \hairpinMore c2\ppppp\< c\f
}



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