Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions slideshow-doc/scribblings/slideshow/slides.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ paragraph.
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}


@defproc[(nitem [#:aspect aspect aspect? #f]
[#:width width real? ((get-current-para-width #:aspect aspect))]
[#:gap-size sep-gap-size real? (current-gap-size)]
[#:separator string? "."]
[#:number integer? (nitem-counter)]
[#:align (or/c 'left 'center 'right) 'left]
[#:fill? fill? any/c #t]
[#:decode? decode? any/c #t]
[element (flat-rec-contract elem/c
or/c string? pict? (listof elem/c))] ...)
pict?]{

Like @racket[item], but with a number instead of a bullet point. The
number can be specified using @racket[#:number] or automatically
incremented. Furthermore, the character following the number defaults
to "." and can be specified using @racket[separator].}


@defproc[(subitem [#:aspect aspect aspect? #f]
[#:width width real? ((get-current-para-width #:aspect aspect))]
[#:gap-size sep-gap-size real? (current-gap-size)]
Expand Down
14 changes: 14 additions & 0 deletions slideshow-exe/slideshow/tutorial-show.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@
(para #:width w l)))))
(para "where" (code bullet) "is a constant pict:" bullet))

(slide
#:title "Numbering"
(nitem "Numbered items can also occur in slides")
(nitem "You can make a number list using" (code nitem))
(nitem "The numbers are automatically calculated for you!")
(nitem #:separator ")"
"The separator can be modified using" (code #:separator)))

(slide
#:title "More Numbering"
(nitem "The numbers automatically restart with every slide")
(nitem #:number 15
"But the number can also be provided using" (code #:number)))

(slide
#:title "Grouping and Space"
(para "Sometimes you want to group items on a slide")
Expand Down
1 change: 1 addition & 0 deletions slideshow-lib/slideshow/base.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
most-recent-slide retract-most-recent-slide re-slide slide->pict start-at-recent-slide
make-outline
(rename-out [item/kw item]
[nitem/kw nitem]
[subitem/kw subitem]
[para/kw para])
gap-size current-gap-size current-font-size current-line-sep
Expand Down
31 changes: 31 additions & 0 deletions slideshow-lib/slideshow/core.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@
(define o-bullet (baseless
(cc-superimpose (circle (/ gap-size 2))
(blank 0 gap-size))))
(define nitem-start-num 0) ;; start at 0 so that the first number is 1
(define (make-nitem-counter)
(let ([n nitem-start-num])
(lambda ()
(set! n (add1 n))
n)))
(define nitem-counter (make-nitem-counter))


(define margin 20)
Expand Down Expand Up @@ -435,6 +442,7 @@
#:gap-size [a-gap-size (current-gap-size)]
. body)
(check-aspect 'slide aspect)
(set! nitem-counter (make-nitem-counter)) ;; reset the number counter
(let ([t (if s
(if (equal? name s)
(if (string? s)
Expand Down Expand Up @@ -946,6 +954,29 @@
#:decode? decode?
s)))])
item))
(define nitem/kw
(let ([nitem (lambda (#:gap-size [a-gap-size (current-gap-size)]
#:number [number (nitem-counter)]
#:separator [separator "."]
#:aspect [aspect #f]
#:width [width ((hash-ref current-para-widths aspect))]
#:align [align 'left]
#:fill? [fill? #t]
#:decode? [decode? #t]
. s)
(check-aspect 'item aspect)
(htl-append (/ a-gap-size 2)
(para/kw #:aspect aspect
#:width (- width
(pict-width bullet)
(/ a-gap-size 2))
#:align align
#:fill? fill?
#:decode? decode?
(number->string number)
separator
s)))])
nitem))

(define (item*/bullet bullet w . s)
(htl-append (/ gap-size 2)
Expand Down
1 change: 1 addition & 0 deletions slideshow-lib/slideshow/sig.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
scroll-transition pause-transition
comment make-outline
item/kw item item* page-item page-item*
nitem/kw
item/bullet item*/bullet page-item/bullet page-item*/bullet
subitem/kw subitem subitem* page-subitem page-subitem*
itemize itemize* page-itemize page-itemize*
Expand Down
11 changes: 11 additions & 0 deletions slideshow-lib/slideshow/slide.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
#:decode? any/c)
#:rest elem/c
. ->* . pict?))
(define nitem-contract (() (#:number integer?
#:separator string?
#:width real?
#:gap-size real?
#:align (or/c 'left 'center 'right)
#:fill? any/c
#:decode? any/c)
#:rest elem/c
. ->* . pict?))


;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Exports ;;
Expand Down Expand Up @@ -98,6 +108,7 @@
#:rest elem/c
. ->* . pict?)]
[item/kw item-contract]
[nitem/kw nitem-contract]
[subitem/kw item-contract]
[t (string? . -> . pict?)]
[bt (string? . -> . pict?)]
Expand Down