diff --git a/collects/unstable/gui/pict.rkt b/collects/unstable/gui/pict.rkt index 31136abe40..e86df7cb26 100644 --- a/collects/unstable/gui/pict.rkt +++ b/collects/unstable/gui/pict.rkt @@ -20,6 +20,10 @@ (blank (or w (pict-width pict)) (or h (pict-height pict))))) +(provide colorize/alpha) +(define (colorize/alpha pict r g b a) + (colorize pict (make-object color% r g b a))) + (define (color c p) (colorize p c)) (define color/c diff --git a/collects/unstable/gui/slideshow.rkt b/collects/unstable/gui/slideshow.rkt index 84554fcbd9..f8b725ae1f 100644 --- a/collects/unstable/gui/slideshow.rkt +++ b/collects/unstable/gui/slideshow.rkt @@ -2,7 +2,7 @@ (require slideshow/base slideshow/pict racket/contract/base racket/list racket/match racket/stxparam - (for-syntax racket/base racket/list racket/set) + (for-syntax racket/base racket/list racket/set syntax/parse) "pict.rkt") (provide (all-from-out "pict.rkt")) @@ -153,7 +153,7 @@ ;; Revealing slides. Similar to staging slides, can probably be implemented ;; in terms of staged slides. -(provide reveal revealing-slide) +(provide reveal revealing-slide items-slide) (define-syntax-parameter reveal (lambda (stx) (raise-syntax-error 'reveal "reveal"))) @@ -188,3 +188,42 @@ (slide stuff ...)))))) (with-syntax ([(slides ...) slides]) #'(begin slides ...)))])) + +;; (items-slide ("a" "b" "c") #:title "whatever" (reveal 0 ...) (reveal 1 ...) (reveal 2 ...) +;; this will show a, b, c on the left side with one of them highlighted at a time. +;; the first element, a, will be synchronized with showing the first reveal, then +;; the second element, b, will be synchronized with the second reveal, etc. +(define-syntax (items-slide stx) + (syntax-parse stx + [(_ (item ...) (~seq keyword-name:keyword keyword-value:expr) ... stuff:expr ...) + (let () + (define max-reveals (length (syntax->list #'(item ...)))) + (define slides (for/list ([i max-reveals]) + (with-syntax ([i i] + [(keywords ...) + (apply append (syntax->list + #'((keyword-name keyword-value) ...)))]) + (syntax (syntax-parameterize ([reveal (syntax-rules () + [(reveal n pict) + (show pict (= i n))])]) + (let ([show-items + (for/fold ([start (blank)]) + ([in '(item ...)] + [current (in-naturals)]) + (vr-append start + (if (= current i) + (text in null (current-font-size)) + (colorize/alpha (text in null (- (current-font-size) 3)) + + 0 0 0 0.3)) + (blank 1 10)))] + [data (for/fold ([start (blank)]) + ([thing (list stuff ...)]) + (lt-superimpose start thing))]) + (slide keywords ... + (ht-append + show-items + (blank 50 1) + data)))))))) + (with-syntax ([(slides ...) slides]) + #'(begin slides ...)))]))