Hi all, in the threads http://lists.gnu.org/archive/html/lilypond-user/2017-03/msg00234.html and espcially http://lists.gnu.org/archive/html/lilypond-user/2017-03/msg00356.html
I struggled with the behaviour of shifting a note column at system start using its X-offset property. Obviously there's some threshold before it takes any visible effect. Using an elaborate testing file drawing rulers and boxes at different positions I now got to the bottom of the problem - nearly. I'll write this down ASAP when I've fully understood the issue. My challenge is to produce space at the beginning of a system to draw an element of a fixed width. You can see that from the red box in the attached PNG (which reflects the final solution). My initial idea to calculate the missing space (from the distance between the clef and the accidentals) and set NoteColumn.X-offset to that value didn't work (as described in the earlier threads). The attached PDF shows what happens when the X-offset is increased step by step. The border of the system-start NonMusicalPaperColumn is indicated with a blue line reflect the accidentals' origin and X-extent. Obviously the reference point of the accidentals is the X position of the note column minus the note column's X-offset, which you can see from the fact that the distance of the pink vertical line always relfects the X-offset value. However, up to a certain point (in the example this is an X-offset of 4.875) the whole thing is shifted to the right and continuously approaches the state when the pink line coincides with the box around the accidentals (or when the accidentals' (car X-extent) has reached zero. Up to that point increasing the X-offset of the note column doesn't have a visible effect but only moves around the origin and the accidentals' X-extent. But *after* that point increasing X-offset beyond 4.875 pushes the chord to the right as one would expect. It seems that the pink reference point (recall: the note column's X position minus its X-offset) remains stable, and it obviously is the point where by default notes would start, as you can see from the last example in the PDF. My conclusion of this is that LilyPond enforces a padding between the clef (or time or key signature, which behave identially if present) and the first note column. However, if there are accidentals attached to the note column they are allowed to protrude into that padding area. ### So, now finally comes my question: I have determined this padding to be exactly 2 staff spaces wide, but I'm wondering if that is hard-coded in LilyPond or ruled by a property. Actually I'd be surprised if it's not possible to modify this aspect of appearance, but I have to know if I can simply insert the "2" into my calculations or if I have to retrieve that value from a property to make the calculation robust. I poked around in the reference for NonMusicalPaperColumn but didn't find anything that looked promising. I can override its #'padding, but that doesn't seem to have any effect at the system start (only within a system). It would seem that line-break-system-details would be a starting point, but http://lilypond.org/doc/v2.19/Documentation/notation/explicit-staff-and-system-positioning doesn't give anything for my question, and the IR for NonMusicalPaperColumn and paper-column-interface seem to be happy with "An alist of properties to use if this column is the start of a system." Any clarification or pointers available? Thanks Urs -- [email protected] https://openlilylib.org http://lilypondblog.org
beginning-of-staff.pdf
Description: Adobe PDF document
\version "2.19.57"
\paper {
indent = 0
}
#(define draw-nc-position #f)
#(define draw-starter-border #t)
#(define draw-x-offset-ref #t)
#(define draw-accs-box #t)
#(define draw-intended-space #f)
#(define draw-clef-acc-dist #f)
#(define assumed-padding 2)
#(define intended-space 4)
#(set-object-property! 'seen 'backend-type? boolean?)
#(define (distance-info tie)
(let*
(;; our helper grobs
(sys (ly:grob-system tie))
(left-nh (ly:grob-parent tie X))
(nc (ly:grob-parent left-nh Y))
; NOTE: For simplicity we don't handle missing accidentals
(accs (ly:note-column-accidentals nc)))
(if (not (ly:grob-property nc 'seen))
(let*
;;;; some lengths and props
((acc-x-extent (ly:grob-property accs 'X-extent))
(acc-width (- (cdr acc-x-extent) (car acc-x-extent)))
(left-acc-x-extent (car acc-x-extent))
;; first NonMusicalPaperColumn, includes clef, key and timesignature
(staff-starter (first (ly:grob-array->list (ly:grob-object sys 'elements))))
(staff-starter-width
(let ((ext (ly:grob-property
staff-starter
'X-extent)))
(- (cdr ext) (car ext))))
(staff-starter-x-pos (ly:grob-relative-coordinate staff-starter sys X))
;; position of note column, relative to system (blue vertical line)
(nc-x-pos (ly:grob-relative-coordinate nc sys X))
(nc-x-offset
(let ((off (ly:grob-property nc 'X-offset)))
(if (null? off) 0 off)))
(nc-acc-dist (- nc-x-offset left-acc-x-extent))
;(staff-starter-nc-dist (- nc-x-pos staff-starter-width))
(clef-acc-dist (- nc-x-pos staff-starter-width nc-acc-dist))
(missing-length
(let ((mw (- intended-space clef-acc-dist)))
(if (> mw 0) mw #f)))
(to-offset
(+
nc-acc-dist
intended-space
(* -1 assumed-padding)))
)
; (ly:message "\nNote column X position: ~a" nc-x-pos)
; (ly:message "Accidentals X position: ~a" acc-x-pos)
; (ly:message "Width of staff starters: ~a" staff-starter-width)
; (ly:message "Space between clef and notes: ~a" staff-starter-nc-dist)
; (ly:message "Accidentals Width: ~a" acc-x-extent)
; (ly:message "nc-acc-dist: ~a" nc-acc-dist)
(ly:message "\n")
(ly:message "Staff start padding: ~a" (ly:grob-property staff-starter 'padding))
(if missing-length
(ly:message "missing space: ~a" missing-length))
(ly:message "Set X-offset to ~a\n\n" to-offset)
(ly:grob-set-property! nc 'seen #t)
(ly:stencil-add
;; the space we want to have
(if draw-intended-space
(ly:stencil-translate
(stencil-with-color
(ly:make-stencil
`(path 0.1
`(moveto 0 -3 rlineto 0 6 rlineto ,,intended-space 0 rlineto 0 -6 rlineto -4 0)))
red)
(cons
(- staff-starter-width nc-x-pos)
0))
empty-stencil)
;; where is the "origin" of the note column?
(if draw-nc-position
(stencil-with-color
(ly:make-stencil `(path 0.1 `(moveto 0 -3 rlineto 0 6))) blue)
empty-stencil)
(if draw-starter-border
(ly:stencil-translate
(stencil-with-color
(ly:make-stencil
`(path 0.1
`(moveto 0 -3.5
rlineto 0 7)))
blue)
(cons
(+
staff-starter-x-pos
(- staff-starter-width nc-x-pos))
0))
empty-stencil)
(if draw-x-offset-ref
(ly:stencil-translate
(stencil-with-color
(ly:make-stencil
`(path 0.1
`(moveto 0 -4.5
rlineto 0 9)))
magenta)
(cons
(* -1 nc-x-offset)
0))
empty-stencil)
;; origin and extent of accidentals
(if draw-accs-box
(ly:stencil-translate
(stencil-with-color
(ly:make-stencil
`(path 0.1
`(moveto ,,(car acc-x-extent) -2.5
rlineto 0 5
rlineto ,,acc-width 0
rlineto 0 -5
rlineto ,,(* -1 acc-width) 0
)))
magenta)
(cons
(* -1 nc-x-offset)
0))
empty-stencil)
;; Available distance between clef and accidentals
(if draw-clef-acc-dist
(ly:stencil-translate
(stencil-with-color
(ly:make-stencil
`(path 0.2
`(moveto 0 1 rlineto 0 -2 moveto 0 0
rlineto ,,clef-acc-dist 0 rmoveto 0 1 rlineto 0 -2)))
green)
(cons
(- staff-starter-width nc-x-pos)
0))
empty-stencil)
(ly:tie::print tie)
))
(ly:tie::print tie)
)))
music = { <c' eis' gis' ais' cis''>1 ~ q }
\markup "Default result (no X-offset):"
{
\music
}
\markup "X-offset: 2"
{
\once \override NoteColumn.X-offset = 2
\music
}
\markup "X-offset: 3"
{
\once \override NoteColumn.X-offset = 3
\music
}
\markup "X-offset: 4"
{
\once \override NoteColumn.X-offset = 4
\music
}
\markup "X-offset: 4.875"
{
\once \override NoteColumn.X-offset = 4.875
\music
}
\markup "X-offset: 5.875"
{
\once \override NoteColumn.X-offset = 5.875
\music
}
\markup "Intended result:"
\markup #(format "X-offset: ~a" 6.875)
{
\once \override NoteColumn.X-offset = 6.875
\music
}
\markup "Default spacing without accidentals"
{
<c' e' g' c''>1
}
\layout {
\context {
\Score
\override Tie.stencil = #distance-info
\override NoteColumn.seen = ##f
}
\context {
\Score
}
}_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
