\version "2.19.24" off = #(define-music-function (spec event) (pair? ly:music?) " Shift grobs using X- and Y-offset, with outside-staff-priority unset by default. Provides dedicated input modes for Dynamics in order to handle the tricky interaction with DynamicLineSpanner and both settings of outside-staff-priority. " ;; default values (define item-x-off 0) (define item-y-off #f) (define span-y-off 0) (define inside-staff? #t) (define dynamic? #f) (define (spec-type? spec symbol-list) (and (list? spec) (member (car spec) symbol-list))) ;; Apply tweak only if cond? is true (define (cond-tweak cond? prop val arg) (if cond? (tweak prop val arg) arg)) (define (cond-offset cond? prop offs item) (if cond? (offset prop offs item) item)) ;; differentiate between spec-types (cond ;; no further complications: proper pair for input ((not (list? spec)) (set! item-x-off (car spec)) (set! item-y-off (cdr spec))) ;; Offset DynamicText or Hairpin ;; input: three-element list '(spec-type x y) ;;;; 1. at the beginning of a DynamicLineSpanner ((spec-type? spec '(dynamic-line-spanner dls)) (set! dynamic? #t) (set! item-x-off (second spec)) (set! span-y-off (third spec))) ;;;; 2. when a DynamicLineSpanner is already active ((spec-type? spec '(dynamic d)) (set! dynamic? #t) (set! item-x-off (second spec)) (set! item-y-off (third spec)) ;(format #t "item-y-off is ~a" item-y-off) ) (else (ly:warning "Cannot read specification for offset - using default values."))) (cond-tweak inside-staff? 'outside-staff-priority #f (cond-tweak item-x-off 'X-offset item-x-off (cond-offset item-y-off 'Y-offset item-y-off (cond-tweak (and dynamic? inside-staff?) '(DynamicLineSpanner outside-staff-priority) #f (cond-tweak dynamic? '(DynamicLineSpanner Y-offset) span-y-off event))))))