einheitliche Funktionalität zur Autorenanzeige #3

This commit is contained in:
tux 2023-08-11 16:25:06 +02:00
parent 05ea776add
commit c20d0327e7
3 changed files with 81 additions and 29 deletions

View File

@ -1,5 +1,6 @@
\language "deutsch" \language "deutsch"
\include "default_author_style.ly"
\include "styles.ly" \include "styles.ly"
\include #(ly:format "styles/~a.ly" songStyle) \include #(ly:format "styles/~a.ly" songStyle)

26
default_author_style.ly Normal file
View File

@ -0,0 +1,26 @@
\paper {
authorMarkup =
#(make-on-the-fly-markup
(lambda (layout props m)
(let ((name (chain-assoc-get 'author:name props #f))
(trail_name (chain-assoc-get 'author:trail_name props #f))
(birth_year (chain-assoc-get 'author:birth_year props #f))
(death_year (chain-assoc-get 'author:death_year props #f))
(organization (chain-assoc-get 'author:organization props #f)))
(interpret-markup layout props
(string-append
name
(if trail_name (ly:format " (~a)" trail_name) "")
(if (and birth_year death_year)
(ly:format ", (~a~a)" birth_year death_year)
(if birth_year
(ly:format ", (*~a)" birth_year)
(if death_year (ly:format ", (†~a)" death_year) "")))
(if organization (ly:format ", ~a" organization) "")
))))
(make-null-markup)
)
poetMarkup = \markup { "Worte:" \fromproperty #'author }
composerMarkup = \markup { "Weise:" \fromproperty #'author }
poetAndComposerEqualMarkup = \markup { "Worte und Weise:" \fromproperty #'author }
}

View File

@ -1,14 +1,38 @@
#(define-markup-command (print-songinfo layout props) () #(define-markup-command (print-songinfo layout props) ()
(define (format-author authorId)
(let ((author (if (defined? 'AUTHORS) (assq-ref AUTHORS authorId) #f)))
(if author
(markup
#:override (cons 'author:name (assq-ref author 'name))
#:override (cons 'author:trail_name (assq-ref author 'trail_name))
#:override (cons 'author:birth_year (assq-ref author 'birth_year))
#:override (cons 'author:death_year (assq-ref author 'death_year))
#:override (cons 'author:organization (assq-ref author 'organization))
(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 (interpret-markup layout props
(if (chain-assoc-get 'page:is-bookpart-last-page props #f)
(let* ((poetId (chain-assoc-get 'header:poetId props #f))
(composerId (chain-assoc-get 'header:composerId props #f))
(poet-and-composer-same (eq? poetId composerId)))
(let ( (let (
(blockwidth (* (chain-assoc-get 'header:songinfo-size-factor props 0.9) (ly:output-def-lookup layout 'line-width))) (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)) (infotext (chain-assoc-get 'header:songinfo props #f))
(poet (chain-assoc-get 'header:poet 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 #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)) (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))) (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))) (copyright (chain-assoc-get 'header:copyright props #f)))
(if (chain-assoc-get 'page:is-bookpart-last-page props #f)
(markup #:override '(baseline-skip . 3.0) ( (markup #:override '(baseline-skip . 3.0) (
make-fontsize-markup songInfoFontSize make-fontsize-markup songInfoFontSize
(make-sans-markup (make-sans-markup
@ -27,7 +51,8 @@
))) )))
) )
) )
(make-null-markup)))) ))
(make-null-markup)))
) )
#(define-markup-command (print-pagenumber layout props)() #(define-markup-command (print-pagenumber layout props)()