]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
Some clean up about grace-settings in music-functions.scm
[lilypond.git] / scm / music-functions.scm
index 5e07229a3744663147f734bd0be659449b9eaaba..c07a935fe4512cf3cef5061bbc84b3b4132e2112 100644 (file)
@@ -503,6 +503,28 @@ in @var{grob}."
     TupletBracket
     TrillSpanner))
 
+(define general-grace-settings
+  `((Voice Stem font-size -3)
+    (Voice Flag font-size -3)
+    (Voice NoteHead font-size -3)
+    (Voice TabNoteHead font-size -4)
+    (Voice Dots font-size -3)
+    (Voice Stem length-fraction 0.8)
+    (Voice Stem no-stem-extend #t)
+    (Voice Beam beam-thickness 0.384)
+    (Voice Beam length-fraction 0.8)
+    (Voice Accidental font-size -4)
+    (Voice AccidentalCautionary font-size -4)
+    (Voice Script font-size -3)
+    (Voice Fingering font-size -8)
+    (Voice StringNumber font-size -8)))
+
+(define-public score-grace-settings
+  (append
+    `((Voice Stem direction ,UP)
+      (Voice Slur direction ,DOWN))
+    general-grace-settings))
+
 (define-safe-public (make-voice-props-set n)
   (make-sequential-music
    (append
@@ -510,26 +532,9 @@ in @var{grob}."
                                              (if (odd? n) -1 1)))
          direction-polyphonic-grobs)
     (list
-     (make-property-set 'graceSettings
-                        ;; TODO: take this from voicedGraceSettings or similar.
-                        '((Voice Stem font-size -3)
-                          (Voice Flag font-size -3)
-                          (Voice NoteHead font-size -3)
-                          (Voice TabNoteHead font-size -4)
-                          (Voice Dots font-size -3)
-                          (Voice Stem length-fraction 0.8)
-                          (Voice Stem no-stem-extend #t)
-                          (Voice Beam beam-thickness 0.384)
-                          (Voice Beam length-fraction 0.8)
-                          (Voice Accidental font-size -4)
-                          (Voice AccidentalCautionary font-size -4)
-                          (Voice Script font-size -3)
-                          (Voice Fingering font-size -8)
-                          (Voice StringNumber font-size -8)))
-
+     (make-property-set 'graceSettings general-grace-settings)
      (make-grob-property-set 'NoteColumn 'horizontal-shift (quotient n 2))))))
 
-
 (define-safe-public (make-voice-props-override n)
   (make-sequential-music
    (append
@@ -537,23 +542,7 @@ in @var{grob}."
                                                   (if (odd? n) -1 1)))
          direction-polyphonic-grobs)
     (list
-     (make-property-set 'graceSettings
-                        ;; TODO: take this from voicedGraceSettings or similar.
-                        '((Voice Stem font-size -3)
-                          (Voice Flag font-size -3)
-                          (Voice NoteHead font-size -3)
-                          (Voice TabNoteHead font-size -4)
-                          (Voice Dots font-size -3)
-                          (Voice Stem length-fraction 0.8)
-                          (Voice Stem no-stem-extend #t)
-                          (Voice Beam beam-thickness 0.384)
-                          (Voice Beam length-fraction 0.8)
-                          (Voice Accidental font-size -4)
-                          (Voice AccidentalCautionary font-size -4)
-                          (Voice Script font-size -3)
-                          (Voice Fingering font-size -8)
-                          (Voice StringNumber font-size -8)))
-
+     (make-property-set 'graceSettings general-grace-settings)
      (make-grob-property-override 'NoteColumn 'horizontal-shift (quotient n 2))
      (make-grob-property-override 'MultiMeasureRest 'staff-position (if (odd? n) -4 4))))))
 
@@ -879,17 +868,23 @@ actually fully cloned."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; warn for bare chords at start.
 
-(define-public (ly:music-message music msg)
+(define-public (ly:music-message music msg . rest)
   (let ((ip (ly:music-property music 'origin)))
     (if (ly:input-location? ip)
-        (ly:input-message ip msg)
-        (ly:message msg))))
+        (apply ly:input-message ip msg rest)
+        (apply ly:message msg rest))))
 
-(define-public (ly:music-warning music msg)
+(define-public (ly:music-warning music msg . rest)
   (let ((ip (ly:music-property music 'origin)))
     (if (ly:input-location? ip)
-        (ly:input-warning ip msg)
-        (ly:warning msg))))
+        (apply ly:input-warning ip msg rest)
+        (apply ly:warning msg rest))))
+
+(define-public (ly:event-warning event msg . rest)
+  (let ((ip (ly:event-property event 'origin)))
+    (if (ly:input-location? ip)
+        (apply ly:input-warning ip msg rest)
+        (apply ly:warning msg rest))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
@@ -1089,6 +1084,8 @@ set to the @code{location} parameter."
              (clef (ly:music-property quote-music 'quoted-music-clef #f))
              (main-voice (case dir ((1) 1) ((-1) 0) (else #f)))
              (cue-voice (and main-voice (- 1 main-voice)))
+             (cue-type (ly:music-property quote-music 'quoted-context-type #f))
+             (cue-id (ly:music-property quote-music 'quoted-context-id))
              (main-music (ly:music-property quote-music 'element))
              (return-value quote-music))
 
@@ -1110,17 +1107,15 @@ set to the @code{location} parameter."
          (delq! #f
                 (list
                  (and clef (make-cue-clef-set clef))
-
-                 ;; Need to establish CueVoice context even in #CENTER case
-                 (context-spec-music
-                  (if cue-voice
-                      (make-voice-props-override cue-voice)
-                      (make-music 'Music))
-                  'CueVoice "cue")
+                 (and cue-type cue-voice
+                      (context-spec-music
+                       (make-voice-props-override cue-voice)
+                       cue-type cue-id))
                  quote-music
-                 (and cue-voice
+                 (and cue-type cue-voice
                       (context-spec-music
-                       (make-voice-props-revert) 'CueVoice "cue"))
+                       (make-voice-props-revert)
+                       cue-type cue-id))
                  (and clef (make-cue-clef-unset))))))
       quote-music))
 
@@ -1756,7 +1751,11 @@ Entries that conform with the current key signature are not invalidated."
 
 (define-public (map-some-music map? music)
   "Walk through @var{music}, transform all elements calling @var{map?}
-and only recurse if this returns @code{#f}."
+and only recurse if this returns @code{#f}.  @code{elements} or
+@code{articulations} that are not music expressions are discarded:
+this allows some amount of filtering.
+
+@code{map-some-music} may overwrite the original @var{music}."
   (let loop ((music music))
     (or (map? music)
         (let ((elt (ly:music-property music 'element))
@@ -1767,10 +1766,10 @@ and only recurse if this returns @code{#f}."
                     (loop elt)))
           (if (pair? elts)
               (set! (ly:music-property music 'elements)
-                    (map loop elts)))
+                    (filter! ly:music? (map! loop elts))))
           (if (pair? arts)
               (set! (ly:music-property music 'articulations)
-                    (map loop arts)))
+                    (filter! ly:music? (map! loop arts))))
           music))))
 
 (define-public (for-some-music stop? music)