From ab6b766cf42a59dadda50fd9ada69192d43dfbe4 Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Fri, 15 Jan 2010 00:34:04 +0000 Subject: [PATCH] LSR: Update. --- ...changing-a-single-notes-size-in-a-chord.ly | 2 +- .../snippets/displaying-grob-ancestry.ly | 121 ++++++++++++++++++ .../new/numbers-as-easy-note-heads.ly | 3 + .../snippets/numbers-as-easy-note-heads.ly | 3 + Documentation/snippets/simple-lead-sheet.ly | 15 +-- .../tweaks-and-overrides.snippet-list | 2 + ...grob-object-to-access-grobs-with--tweak.ly | 75 +++++++++++ 7 files changed, 212 insertions(+), 9 deletions(-) create mode 100644 Documentation/snippets/displaying-grob-ancestry.ly create mode 100644 Documentation/snippets/using-ly-grob-object-to-access-grobs-with--tweak.ly diff --git a/Documentation/snippets/changing-a-single-notes-size-in-a-chord.ly b/Documentation/snippets/changing-a-single-notes-size-in-a-chord.ly index b7e524e5c1..a3ea65e6fd 100644 --- a/Documentation/snippets/changing-a-single-notes-size-in-a-chord.ly +++ b/Documentation/snippets/changing-a-single-notes-size-in-a-chord.ly @@ -29,7 +29,7 @@ property. Inside the chord (within the brackets @code{< >}), before the note to be altered, place the @code{\\tweak} command, followed by @code{#'font-size} and define the proper size like @code{#-2} (a tiny -notehead). +note head). diff --git a/Documentation/snippets/displaying-grob-ancestry.ly b/Documentation/snippets/displaying-grob-ancestry.ly new file mode 100644 index 0000000000..d26184ffb6 --- /dev/null +++ b/Documentation/snippets/displaying-grob-ancestry.ly @@ -0,0 +1,121 @@ +%% Do not edit this file; it is automatically +%% generated from LSR http://lsr.dsi.unimi.it +%% This file is in the public domain. +\version "2.13.10" + +\header { + lsrtags = "tweaks-and-overrides" + + texidoc = " +When working with grob callbacks, it can be helpful to understand a +grob's @qq{ancestry}. Most grobs have @qq{parents} which influence the +positioning of the grob. X- and Y-parents influence the horizontal and +vertical positions for the grob, respectively. Additionally, each +parent may have parents of its own. + + +Unfortunately, there are several aspects of a grob's ancestry can lead +to confusion: + +* The types of parents a grob has may depend on context. * For some +grobs, the X- and Y-parents are the same. * A particular @qq{ancestor} +may be related to a grob in multiple ways. * The concept of +@qq{generations} is misleading. + + +For example, the @code{System} grob can be both parent (on the Y-side) +and grandparent (twice on the X-side) to a @code{VerticalAlignment} +grob. + + +This macro prints (to the console) a textual representation of a grob's +ancestry. + + +When called this way + + +@{ + \\once \\override NoteHead #'before-line-breaking = #display-ancestry + c @} + + +The following output is generated: + + +------------------------------------ + +NoteHead X,Y: NoteColumn + X: PaperColumn + X,Y: System + Y: VerticalAxisGroup + X: NonMusicalPaperColumn + X,Y: System + Y: VerticalAlignment + X: NonMusicalPaperColumn + X,Y: System + Y: System + + + +" + doctitle = "Displaying grob ancestry" +} % begin verbatim + +#(define (grob-name grob) + (if (ly:grob? grob) + (assoc-ref (ly:grob-property grob 'meta) 'name) + #f)) + +#(define (get-ancestry grob) + (if (not (null? (ly:grob-parent grob X))) + (list (grob-name grob) + (get-ancestry (ly:grob-parent grob X)) + (get-ancestry (ly:grob-parent grob Y))) + (grob-name grob))) + +#(define (format-ancestry lst padding) + (string-append + (symbol->string (car lst)) + "\n" + (let ((X-ancestry + (if (list? (cadr lst)) + (format-ancestry (cadr lst) (+ padding 3)) + (symbol->string (cadr lst)))) + (Y-ancestry + (if (list? (caddr lst)) + (format-ancestry (caddr lst) (+ padding 3)) + (symbol->string (caddr lst))))) + (if (equal? X-ancestry Y-ancestry) + (string-append + (format #f "~&") + (make-string padding #\space) + "X,Y: " + (if (list? (cadr lst)) + (format-ancestry (cadr lst) (+ padding 5)) + (symbol->string (cadr lst)))) + (string-append + (format #f "~&") + (make-string padding #\space) + "X: " X-ancestry + "\n" + (make-string padding #\space) + "Y: " Y-ancestry + (format #f "~&")))) + (format #f "~&"))) + +#(define (display-ancestry grob) + (display + (string-append + (format #f "~3&~a~2%" (make-string 36 #\-)) + (format-ancestry (get-ancestry grob) 0) + (format #f "~2&")))) + +\relative c' { + \once \override NoteHead #'before-line-breaking = #display-ancestry + f + \once \override Accidental #'before-line-breaking = #display-ancestry + \once \override Arpeggio #'before-line-breaking = #display-ancestry + \arpeggio +} + diff --git a/Documentation/snippets/new/numbers-as-easy-note-heads.ly b/Documentation/snippets/new/numbers-as-easy-note-heads.ly index 2df46c56b3..16b6002d33 100644 --- a/Documentation/snippets/new/numbers-as-easy-note-heads.ly +++ b/Documentation/snippets/new/numbers-as-easy-note-heads.ly @@ -29,7 +29,10 @@ object it sees. (note-names (make-vector 7 (number->string (+ 1 delta))))) (ly:grob-set-property! grob 'note-names note-names)))))))) +#(set-global-staff-size 26) + \layout { + ragged-right = ##t \context { \Voice \consists \Ez_numbers_engraver diff --git a/Documentation/snippets/numbers-as-easy-note-heads.ly b/Documentation/snippets/numbers-as-easy-note-heads.ly index 9ccb26181a..7cd88fa11b 100644 --- a/Documentation/snippets/numbers-as-easy-note-heads.ly +++ b/Documentation/snippets/numbers-as-easy-note-heads.ly @@ -34,7 +34,10 @@ object it sees. (note-names (make-vector 7 (number->string (+ 1 delta))))) (ly:grob-set-property! grob 'note-names note-names)))))))) +#(set-global-staff-size 26) + \layout { + ragged-right = ##t \context { \Voice \consists \Ez_numbers_engraver diff --git a/Documentation/snippets/simple-lead-sheet.ly b/Documentation/snippets/simple-lead-sheet.ly index 21cf367d50..db6808885a 100644 --- a/Documentation/snippets/simple-lead-sheet.ly +++ b/Documentation/snippets/simple-lead-sheet.ly @@ -4,14 +4,6 @@ \version "2.13.10" \header { -%% Translation of GIT committish: b7ec64504da87595509ae6e88ae546d6a0ce633d - texidocfr = " -Pour obtenir la partition d'un chanson, il suffit d'assembler -des noms d'accords, une mélodie et des paroles : - -" - doctitlefr = "Chanson simple" - lsrtags = "chords" %% Translation of GIT committish: b2d4318d6c53df8469dfa4da09b27c15a374d0ca @@ -28,6 +20,13 @@ Ein Liedblatt besteht aus Akkordbezeichnungen, einer Melodie und dem Liedtext: " doctitlede = "Ein einfaches Liedblatt" +%% Translation of GIT committish: b7ec64504da87595509ae6e88ae546d6a0ce633d + texidocfr = " +Pour obtenir la partition d'un chanson, il suffit d'assembler +des noms d'accords, une mélodie et des paroles : + +" + doctitlefr = "Chanson simple" texidoc = " When put together, chord names, a melody, and lyrics form a lead sheet: diff --git a/Documentation/snippets/tweaks-and-overrides.snippet-list b/Documentation/snippets/tweaks-and-overrides.snippet-list index 67efdd20a1..d5fd97c312 100644 --- a/Documentation/snippets/tweaks-and-overrides.snippet-list +++ b/Documentation/snippets/tweaks-and-overrides.snippet-list @@ -17,6 +17,7 @@ custodes.ly customizing-fretboard-fret-diagrams.ly customizing-markup-fret-diagrams.ly display-bracket-with-only-one-staff-in-a-system.ly +displaying-grob-ancestry.ly dotted-harmonics.ly drawing-boxes-around-grobs.ly drawing-circles-around-various-objects.ly @@ -53,6 +54,7 @@ time-signature-printing-only-the-numerator-as-a-number-instead-of-the-fraction.l transcription-of-ancient-music-with-incipit.ly tweaking-clef-properties.ly tweaking-grace-layout-within-music.ly +using-ly-grob-object-to-access-grobs-with--tweak.ly using-postscript-to-generate-special-note-head-shapes.ly using-the--tweak-command-to-tweak-individual-grobs.ly vertically-aligned-dynamics-and-textscripts.ly diff --git a/Documentation/snippets/using-ly-grob-object-to-access-grobs-with--tweak.ly b/Documentation/snippets/using-ly-grob-object-to-access-grobs-with--tweak.ly new file mode 100644 index 0000000000..5e38377ccf --- /dev/null +++ b/Documentation/snippets/using-ly-grob-object-to-access-grobs-with--tweak.ly @@ -0,0 +1,75 @@ +%% Do not edit this file; it is automatically +%% generated from LSR http://lsr.dsi.unimi.it +%% This file is in the public domain. +\version "2.13.10" + +\header { + lsrtags = "tweaks-and-overrides" + + texidoc = " +Some grobs can be accessed @qq{laterally} from within another grob's +callback. These are usually listed as @qq{layout objects} in the +@qq{Internal properties} section of a grob-interface. The function +@code{ly:grob-object} is used to access these grobs. + + +Demonstrated below are some ways of accessing grobs from within a +NoteHead callback, but the technique is not limited to NoteHeads. +However, the NoteHead callback is particularly important, since it is +the implicit callback used by the @code{\\tweak} command. + + +The example function defined below (\"display-grobs\") is probably not +that useful, but it demonstrates that the grobs are indeed being +accessed. + + +Example console output: + + +-------------------- #-Grob Accidental - #-Grob Arpeggio - #-Grob Stem - + + + +" + doctitle = "Using ly:grob-object to access grobs with \\tweak" +} % begin verbatim + +#(define (notehead-get-accidental notehead) + ;; notehead is grob + (ly:grob-object notehead 'accidental-grob)) + +#(define (notehead-get-arpeggio notehead) + ;; notehead is grob + (let ((notecolumn (notehead-get-notecolumn notehead))) + (ly:grob-object notecolumn 'arpeggio))) + +#(define (notehead-get-notecolumn notehead) + ;; notehead is grob + (ly:grob-parent notehead X)) + +#(define (notehead-get-stem notehead) + ;; notehead is grob + (let ((notecolumn (notehead-get-notecolumn notehead))) + (ly:grob-object notecolumn 'stem))) + +#(define (display-grobs notehead) + ;; notehead is grob + (let ((accidental (notehead-get-accidental notehead)) + (arpeggio (notehead-get-arpeggio notehead)) + (stem (notehead-get-stem notehead))) + (format #t "~2&~a\n" (make-string 20 #\-)) + (for-each + (lambda (x) (format #t "~a\n" x)) + (list accidental arpeggio stem)))) + +\relative c' { + %% display grobs for each note head: + %\override NoteHead #'before-line-breaking = #display-grobs + 1\arpeggio +} + -- 2.39.5