2023-07-22 22:07:57 +02:00
|
|
|
#(define-markup-command (print-songinfo layout props) ()
|
2023-08-20 12:14:30 +02:00
|
|
|
(define (songinfo-from songId key)
|
|
|
|
(let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f)))
|
|
|
|
(if song
|
|
|
|
(assoc-ref song key)
|
|
|
|
(ly:warning (ly:format "song with id ~a not found" songId)))))
|
|
|
|
|
2023-08-11 16:25:06 +02:00
|
|
|
(define (format-author authorId)
|
2023-08-20 12:14:30 +02:00
|
|
|
(let ((author (if (defined? 'AUTHOR_DATA) (assoc-ref AUTHOR_DATA authorId) #f)))
|
2023-08-11 16:25:06 +02:00
|
|
|
(if author
|
|
|
|
(markup
|
2023-08-20 12:14:30 +02:00
|
|
|
#:override (cons 'author:name (assoc-ref author "name"))
|
|
|
|
#:override (cons 'author:trail_name (assoc-ref author "trail_name"))
|
|
|
|
#:override (cons 'author:birth_year (assoc-ref author "birth_year"))
|
|
|
|
#:override (cons 'author:death_year (assoc-ref author "death_year"))
|
|
|
|
#:override (cons 'author:organization (assoc-ref author "organization"))
|
2023-08-11 16:25:06 +02:00
|
|
|
(ly:output-def-lookup layout 'authorMarkup))
|
|
|
|
(ly:warning (ly:format "author with id ~a not found" authorId)))))
|
|
|
|
|
|
|
|
(define (format-poet poetId)
|
|
|
|
(markup #:override (cons 'author (format-author poetId)) (ly:output-def-lookup layout 'poetMarkup)))
|
|
|
|
|
|
|
|
(define (format-composer composerId)
|
|
|
|
(markup #:override (cons 'author (format-author composerId)) (ly:output-def-lookup layout 'composerMarkup)))
|
|
|
|
|
|
|
|
(define (format-poet-and-composer authorId)
|
|
|
|
(markup #:override (cons 'author (format-author authorId)) (ly:output-def-lookup layout 'poetAndComposerEqualMarkup)))
|
|
|
|
|
|
|
|
(interpret-markup layout props
|
|
|
|
(if (chain-assoc-get 'page:is-bookpart-last-page props #f)
|
2023-08-20 12:14:30 +02:00
|
|
|
(let* ((songId (chain-assoc-get 'header:songId props #f))
|
|
|
|
(poetId (chain-assoc-get 'header:poetId props (if songId (songinfo-from songId "poet") #f)))
|
|
|
|
(composerId (chain-assoc-get 'header:composerId props (if songId (songinfo-from songId "composer") #f)))
|
|
|
|
(poet-and-composer-same (equal? poetId composerId)))
|
2023-08-11 16:25:06 +02:00
|
|
|
(let (
|
|
|
|
(blockwidth (* (chain-assoc-get 'header:songinfo-size-factor props 0.9) (ly:output-def-lookup layout 'line-width)))
|
|
|
|
(infotext (chain-assoc-get 'header:songinfo props #f))
|
|
|
|
(poet (chain-assoc-get 'header:poet props (if poetId (if poet-and-composer-same (format-poet-and-composer poetId) (format-poet poetId)) #f)))
|
|
|
|
(composer (chain-assoc-get 'header:composer props (if (and composerId (not poet-and-composer-same)) (format-composer composerId) #f)))
|
|
|
|
(poet-and-composer-stacked (chain-assoc-get 'header:poet-and-composer-stacked props songInfoPoetAndComposerStacked))
|
|
|
|
(between-poet-and-composer-markup (chain-assoc-get 'header:between-poet-and-composer-markup props (make-hspace-markup 3)))
|
|
|
|
(copyright (chain-assoc-get 'header:copyright props #f)))
|
|
|
|
(markup #:override '(baseline-skip . 3.0) (
|
|
|
|
make-fontsize-markup songInfoFontSize
|
|
|
|
(make-sans-markup
|
|
|
|
;%\override #'(line-width . 92) \wordwrap-field #symbol
|
|
|
|
(make-column-markup (list
|
|
|
|
(make-line-markup
|
|
|
|
(list
|
|
|
|
(if (and poet (not (and (string? poet) (string-null? poet)))) (markup poet between-poet-and-composer-markup) "")
|
|
|
|
(if (and composer (not poet-and-composer-stacked)) composer ""))
|
|
|
|
)
|
|
|
|
(if (and composer poet-and-composer-stacked) (make-line-markup (list composer)) "")
|
|
|
|
(make-override-markup `(line-width . ,blockwidth) (make-justify-string-markup (string-append
|
|
|
|
(if (and copyright (not (and (string? copyright) (string-null? copyright)))) (ly:format "© ~a\n\n" copyright) "")
|
|
|
|
(if infotext infotext "")
|
|
|
|
)))
|
|
|
|
)))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
))
|
|
|
|
(make-null-markup)))
|
2023-07-22 22:07:57 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
#(define-markup-command (print-pagenumber layout props)()
|
|
|
|
(let ((label (chain-assoc-get 'header:myindexlabel props #f)))
|
|
|
|
(interpret-markup layout props
|
|
|
|
(markup #:large #:bold
|
|
|
|
(if label
|
|
|
|
(make-custom-page-number-markup label (chain-assoc-get 'page:page-number props 0))
|
|
|
|
(make-fromproperty-markup 'page:page-number-string)
|
|
|
|
)
|
|
|
|
))))
|
|
|
|
|
|
|
|
\paper {
|
|
|
|
print-first-page-number = ##t
|
|
|
|
first-page-number = #0
|
|
|
|
|
|
|
|
oddFooterMarkup = \markup {
|
|
|
|
\fill-line {
|
|
|
|
\line { \null }
|
|
|
|
\line { \general-align #Y #DOWN \print-songinfo }
|
|
|
|
\line { \if \should-print-page-number \print-pagenumber }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evenFooterMarkup = \markup {
|
|
|
|
\fill-line {
|
|
|
|
\line { \if \should-print-page-number \print-pagenumber }
|
|
|
|
\line { \general-align #Y #DOWN \print-songinfo }
|
|
|
|
\line { \null }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|