- ;; the grob we want to parenthesize
- (let ((victim (ly:grob-array-ref (ly:grob-object grob 'elements) 0)))
- ;; check whether it's a notehead
- (if (grob::has-interface victim 'note-head-interface)
- (begin
- ;; tweak appearance before retrieving
- ;; list of stencils '(left-paren right-paren)
- ;; get the font-size from victim (=TabNoteHead) to handle
- ;; grace notes properly
- (ly:grob-set-property! grob 'font-size
- (ly:grob-property victim 'font-size))
- (ly:grob-set-property! grob 'padding 0)
- ;; apply whiteout to each element of the list
- (map stencil-whiteout
- (parentheses-item::calc-parenthesis-stencils grob)))
- (parentheses-item::calc-parenthesis-stencils grob))))
-
-;; the handler for ties in tablature;; split ties yield in a parenthesized
-;; fret number, otherwise the fret number will be invisible.
-(define-public (tie::handle-tab-tie grob)
- (let* ((original (ly:grob-original grob))
- (tied-tab-note-head (ly:spanner-bound grob RIGHT))
- (siblings (if (ly:grob? original)
- (ly:spanner-broken-into original) '())))
-
- (if (and (>= (length siblings) 2)
- (eq? (car (last-pair siblings)) grob))
- ;; tie is split -> parenthesize
- (ly:grob-set-property! tied-tab-note-head 'stencil
- (lambda (grob) (parenthesize-tab-note-head grob)))
-
- ;; tie is not split -> make fret number invisible
- (ly:grob-set-property! tied-tab-note-head 'transparent #t))))
+ ;; the grob we want to parenthesize
+ (let ((victim (ly:grob-array-ref (ly:grob-object grob 'elements) 0)))
+
+ ;; check whether it's a note head
+ (if (grob::has-interface victim 'note-head-interface)
+ (begin
+ ;; tweak appearance before retrieving
+ ;; list of stencils '(left-paren right-paren)
+ ;; get the font-size from victim (=TabNoteHead) to handle
+ ;; grace notes properly
+ (ly:grob-set-property! grob 'font-size
+ (ly:grob-property victim 'font-size))
+ (ly:grob-set-property! grob 'padding 0)
+ ;; apply whiteout to each element of the list
+ (map stencil-whiteout
+ (parentheses-item::calc-parenthesis-stencils grob)))
+ (parentheses-item::calc-parenthesis-stencils grob))))
+
+;; the handler for ties in tablature; according to TabNoteHead #'details,
+;; the 'tied to' note is handled differently after a line break
+(define-public (tie::handle-tab-note-head grob)
+ (let* ((original (ly:grob-original grob))
+ (tied-tab-note-head (ly:spanner-bound grob RIGHT))
+ (siblings (if (ly:grob? original)
+ (ly:spanner-broken-into original) '())))
+
+ (if (and (>= (length siblings) 2)
+ (eq? (car (last-pair siblings)) grob))
+ ;; tie is split -> get TabNoteHead #'details
+ (let* ((details (ly:grob-property tied-tab-note-head 'details))
+ (tied-properties (assoc-get 'tied-properties details '()))
+ (tab-note-head-parenthesized (assoc-get 'parenthesize tied-properties #t))
+ ;; we need the begin-of-line entry in the 'break-visibility vector
+ (tab-note-head-visible
+ (vector-ref (assoc-get 'break-visibility
+ tied-properties #(#f #f #t)) 2)))
+
+ (if tab-note-head-visible
+ ;; tab note head is visible
+ (if tab-note-head-parenthesized
+ (ly:grob-set-property! tied-tab-note-head 'stencil
+ (lambda (grob)
+ (parenthesize-tab-note-head grob))))
+ ;; tab note head is invisible
+ (begin
+ (ly:grob-set-property! tied-tab-note-head 'transparent #t)
+ (ly:grob-set-property! tied-tab-note-head 'whiteout #f))))
+
+ ;; tie is not split -> make fret number invisible
+ (begin
+ (ly:grob-set-property! tied-tab-note-head 'transparent #t)
+ (ly:grob-set-property! tied-tab-note-head 'whiteout #f)))))