2 ;;;; slur.scm -- Slur scheme stuff
4 ;;;; source file of the GNU LilyPond music typesetter
6 ;;;; (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
9 (define (attached-to-stem slur dir)
10 (let* ((note-columns (ly:grob-property slur 'note-columns))
11 (col (if (= dir RIGHT)
13 (car (last-pair note-columns))))
14 (stem (ly:grob-property col 'stem)))
16 (eq? col (ly:spanner-get-bound slur dir))
18 ;(pair? (ly:grob-property stem 'heads))
24 ;; Currently, we have attachments:
26 ;; 'head 'along-side-stem 'stem 'loose-end
28 (define (calc-slur-extremity slur dir)
29 (let* ((note-columns (ly:grob-property slur 'note-columns))
32 (car (last-pair note-columns))))
33 (stem (ly:grob-property col 'stem))
34 (beaming (if (and (ly:grob? stem)
35 (ly:grob? (ly:grob-property stem 'beam)))
36 (ly:grob-property stem 'beaming)
38 (one-side-beaming (if (= dir RIGHT)
45 ((< (length note-columns) 1) 'head)
46 ((not (attached-to-stem slur dir))
50 (not (equal? (ly:grob-property slur 'direction)
51 (ly:grob-property stem 'direction)))) 'head)
52 ((and (memq (ly:spanner-get-bound slur dir)
53 (ly:grob-property slur 'note-columns))
56 ;; slur would go under beam for 'head
57 (> (length one-side-beaming ) 0)
58 ;; and beam on same side as slur
60 (ly:grob-property stem 'direction)
61 (ly:grob-property slur 'direction))
64 ((not (attached-to-stem slur dir))
71 ;; This list defines the offsets for each type of attachment.
72 ;; The format of each element is
73 ;; (attachment stem-dir*dir slur-dir*dir)
74 ;; Different attachments have different default points:
76 ;; head: Default position is centered in X, on outer side of head Y
77 ;; along-side-stem: Default position is on stem X, on outer side of head Y
78 ;; stem: Default position is on stem X, at stem end Y
79 (define default-slur-extremity-offset-alist
81 ((head 1 1) . (-0.25 . 0.75))
82 ((head 1 -1) . (-0.25 . 0.75))
83 ((head -1 1) . (-0.25 . 0.75))
84 ((head -1 -1) . (-0.85 . 0.75))
86 ((stem 1 1) . (-0.125 . 0.5))
87 ((stem -1 -1) . (-0.125 . 0.5))
89 ((loose-end 1 1) . (-0.4 . 0))
90 ((loose-end 1 -1) . (-0.4 . 0))
91 ((loose-end -1 -1) . (-4 . 0))
92 ((loose-end -1 1) . (-4 . 0))
95 ;; This is a bit of a hack: slurs and phrasing slurs
96 ;; attaching at the same note must not collide.
97 ;; However, slurs (and phrasing slurs) should look
98 ;; at scripts and eachother.
99 (define default-phrasing-slur-extremity-offset-alist
101 ((head 1 1) . (-0.25 . 1.25))
102 ((head 1 -1) . (-0.25 . 1.25))
103 ((head -1 1) . (-0.25 . 1.25))
104 ((head -1 -1) . (-0.85 . 1.25))
106 ((stem 1 1) . (-0.25 . 1.5))
107 ((stem -1 -1) . (-0.25 . 1.5))
109 ((loose-end 1 1) . (-0.4 . 0))
110 ((loose-end 1 -1) . (-0.4 . 0))
111 ((loose-end -1 -1) . (-4 . 0))
112 ((loose-end -1 1) . (-4 . 0))