%% 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)),quote]
\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))
  line-width = 160\mm - 2.0 * 10.16\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:
% ****************************************************************
\sourcefileline 4458
#(define visualize-alignments
   ;; Add visual clues to show alignment between `TextScript` and
   ;; `NoteColumn` grobs.
   ;;
   ;;   reference point of `TextScript` grob:              dot
   ;;   self-alignment-X ('self' grob is `TextScript`):    cross
   ;;   parent-alignment-X (parent grob is `NoteColumn`):  vertical line
   (grob-transformer
    'stencil
    (lambda (grob orig)
      (let* ((dot (make-circle-stencil 0.2 0.1 #t))
             (zero-ext-dot
              (ly:make-stencil (ly:stencil-expr dot) '(0 . 0) '(0 . 0)))
             (cross (make-path-stencil '(moveto -1 -1
                                         lineto 1 1
                                         moveto -1 1
                                         lineto 1 -1)
                                       0.1 0.3 0.3 #f))
             (zero-ext-cross
              (ly:make-stencil (ly:stencil-expr cross) '(0 . 0) '(0 . 0)))
             (line (make-line-stencil 0 0 -7.5 0 1.5)))
        (if (ly:stencil? orig)
            (let* ((stil-x-ext (ly:stencil-extent orig X))
                   (stil-y-ext (ly:stencil-extent orig Y))
                   (self-x (ly:grob-property grob 'self-alignment-X #f))
                   (self-y (ly:grob-property grob 'self-alignment-Y #f))
                   (nc (ly:grob-parent grob X))
                   (nc-x-ext (ly:grob-property nc 'main-extent))
                   (nc-y-ext (ly:grob-extent nc nc Y))
                   (par-x (ly:grob-property grob 'parent-alignment-X #f)))
              (when (grob::has-interface nc 'note-column-interface)
                (ly:grob-set-property!
                 nc 'stencil
                 (ly:stencil-translate-axis
                  line
                  (+ (car nc-x-ext) (/ (interval-length nc-x-ext) 2)
                     (* (/ (interval-length nc-x-ext) 2) (or par-x -1)))
                  X))
                ;; Ensure that the line is not hidden by the gray box
                ;; representing the `TextScript` grob.
                (ly:grob-set-property! nc 'layer 2))
              (ly:stencil-add
               orig
               zero-ext-dot
               (ly:stencil-translate
                zero-ext-cross
                (cons
                 (if self-x
                     (+ (car stil-x-ext) (/ (interval-length stil-x-ext) 2)
                        (* (/ (interval-length stil-x-ext) 2) self-x))
                     0)
                 (if self-y
                     (+ (car stil-y-ext) (/ (interval-length stil-y-ext) 2)
                        (* (/ (interval-length stil-y-ext) 2) self-y))
                     0)))))
            ;; If there is no stencil already, return a dot.
            zero-ext-dot)))))

boxStil = \markup \stencil
    #(box-stencil
      (stencil-with-color
       (make-filled-box-stencil '(-1 . 3)  '(-1 . 2))
       "#CCC")
      0 0)

alignment = #(define-scheme-function (arg) (boolean-or-number?)
  #{
    \markup
      \fontsize #-3
      \typewriter #(format #f "self-alignment-X = #~a" arg)
  #})

mus =
#(define-music-function (arg pad mus)
   (boolean-or-number? number? ly:music?)
   #{
     <>-\tweak self-alignment-X #-0.8
       -\tweak padding #pad
       ^\alignment #arg
     #mus -\tweak stencil \visualize-alignments
          -\boxStil
 #})

musline = {
  \mus ##f #0 b'
  \once \override TextScript.self-alignment-X = #-1
    \mus #-1 #2 <b' c''>
  \once \override TextScript.self-alignment-X = #0
    \mus #0 #0 b'
  \once \override TextScript.self-alignment-X = #1
    \mus #1 #2 <b' c''>
  \break
}

{
  \omit Staff.TimeSignature

  \textMark \markup \smaller \typewriter "parent-alignment-X = ##f"
  \override TextScript.parent-alignment-X = ##f
  \musline

  \textMark \markup \smaller \typewriter "parent-alignment-X = #-1"
  \override TextScript.parent-alignment-X = #-1
  \musline

  \textMark \markup \smaller \typewriter "parent-alignment-X = #0"
  \override TextScript.parent-alignment-X = #0
  \musline

  \textMark \markup \smaller \typewriter "parent-alignment-X = #1"
  \override TextScript.parent-alignment-X = #1
  \musline
}

\layout {
  indent = 0
  \context {
    \Score
    \override TextMark.self-alignment-X = #-1
  }
}


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