lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue 3918: Add \alternatingTimeSignatures (issue 97110045)


From: Thomas Morley
Subject: Re: Issue 3918: Add \alternatingTimeSignatures (issue 97110045)
Date: Sun, 18 May 2014 17:41:33 +0200

2014-05-17 9:17 GMT+02:00 David Kastrup <address@hidden>:
> Thomas Morley <address@hidden> writes:
>
>> I think David thought of something at the lines of the following function:
>>
>> appearance =
>> #(define-music-function (parser location mrkp item)
>>    (markup? symbol-list-or-music?)
>>  (let ((stil (lambda (item)
>>                (grob-interpret-markup item mrkp))))
>>    #{ \tweak stencil #stil #item #}))
>>
>> \relative c' {
>>     \appearance
>>       \markup "XY"
>>       Staff.Clef
>>
>>     \appearance
>>       \markup
>>         \override #'(baseline-skip . 0)
>>         \override #'(word-space . 0.2)
>>         \line {
>>           \center-column { \number 3 \number 4 }
>>           \center-column { \number 6 \number 8 }
>>         }
>>       Score.TimeSignature
>>     c1
>> }
>
> Yes, this would work, but there should be a markup command for the stuff
> behind \markup.  Basically the idea was to give a bit more flexibility
> about where to draw the borders for making a nice interface, and also to
> make it easier to substitute one's own stencils when the defaults are
> not sufficient for one's needs.
>
> --
> David Kastrup

Maybe a step in this direction:

\version "2.19.6"

appear =
#(define-music-function (parser location mrkp item)
   (markup? symbol-list-or-music?)
   (let ((stil (lambda (item)
                 (grob-interpret-markup item mrkp))))
     #{ \tweak stencil #stil #item #}))



%% c/p from time-signature-settings.scm
%% Per default, available inside define-markup-commands.scm
#(define (insert-markups l m)
  (let ((ll (reverse l)))
    (let join-markups ((markups (list (car ll)))
                       (remaining (cdr ll)))
      (if (pair? remaining)
          (join-markups (cons (car remaining) (cons m markups)) (cdr remaining))
          markups))))

%% c/p from define-markup-commands.scm
%% Ofcourse available inside define-markup-commands.scm
#(define (general-column align-dir baseline mols)
  "Stack @var{mols} vertically, aligned to  @var{align-dir} horizontally."

  (let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X
align-dir)) mols))
         (stacked-stencil (stack-lines -1 0.0 baseline aligned-mols))
         (stacked-extent (ly:stencil-extent stacked-stencil X)))
    (ly:stencil-translate-axis stacked-stencil (- (car stacked-extent)) X )))


#(define-markup-command (format-time-sig layout props val)
  (list?)
  #:properties ((baseline-skip)
                (word-space)
                (separator? #f)
                (separator-markup (markup #:fontsize 4 "-")
                  ;TODO:
                  ;Using simple "-" is not very nice, though:
                  ;draw-line does not react on further \fontsize settings.
                  ;
                  ;(markup #:override '(thickness . 3.4)
                  ;        #:draw-line (cons 0.9 0))
                          )
                          )

  (if (every (lambda (sig) (eqv? 2 (length+ sig))) val)
      (let* ((time-sig-number-strgs
               (map (lambda (el) (map number->string el)) val))
             (columned-time-sig-stils
               (map
                 (lambda (x)
                   (general-column CENTER (- baseline-skip 3)
                     (interpret-markup-list layout props
                       (map (lambda (m) (make-number-markup m)) x))))
                 time-sig-number-strgs))
             (columned-time-sig-stils-with-sep
               (insert-markups
                 columned-time-sig-stils
                 (interpret-markup layout props separator-markup)))
             (stils
               (map
                 (lambda (stil) (ly:stencil-aligned-to stil Y CENTER))
                 (if separator?
                     columned-time-sig-stils-with-sep
                     columned-time-sig-stils))))

         (stack-stencil-line (- word-space 0.3)
           (remove ly:stencil-empty? stils)))
         (begin
           ;; TODO reword warning
           (ly:warning "Not fitting list. Ignoring")
           empty-stencil)))

\relative c' {
  c1
  \appear
    \markup
      \override #'(separator? . #t)
      \format-time-sig #'((6 8)(4 8))
    Score.TimeSignature
  \time 6/8
  c8 c c c c c c
}

\markup {
  \column {
    \line {
      "A time-signature:"
      \raise #1 \fontsize #-5 \format-time-sig #'((3 4))
    }
    \line {
      "A combined time-signature:"
      \raise #1 \fontsize #-5 \format-time-sig #'((3 4) (6 8))
    }
    \line {
      "A combined time-signature, with separator:"
      \raise #1 \fontsize #-5
      \override #'(separator? . #t)
      \format-time-sig #'((3 4) (6 8))
    }
    \line {
      "A combined time-signature, using other overrides:"
      \raise #1 \fontsize #-5
      \override #'(separator? . #t)
      \override #`(separator-markup . ,(markup #:fontsize 5 #:vcenter "/"))
      \override #'(word-space . 2)
      \override #'(baseline-skip . 5)
      \format-time-sig #'((3 4) (6 8) (7 8))
    }
  }
}


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]