Skip to content

Commit 5e395e6

Browse files
committed
add widescreen support
1 parent 01cc4f0 commit 5e395e6

File tree

23 files changed

+786
-319
lines changed

23 files changed

+786
-319
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#lang at-exp racket/base
2+
(require scribble/manual
3+
(for-syntax racket/base))
4+
5+
(provide declare-aspect-adjust
6+
define-aspect-select)
7+
8+
(define-syntax-rule (declare-aspect-adjust proc def)
9+
(begin
10+
(define-syntax-rule (define-it from-base)
11+
(begin
12+
(require (for-label (only-in slideshow/base [proc proc])))
13+
(define from-base @racket[proc])))
14+
(define-it from-base)
15+
@defthing[proc procedure?]{
16+
The same as @from-base frmo @racketmodname[slideshow/base], but with @racket[def] as the default
17+
value of the @racket[#:aspect] argument.}))
18+
19+
(define-syntax-rule (define-aspect-select id get-id def)
20+
@defidform[id]{The same as @racket[(get-id def)].})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#lang scribble/doc
2+
@(require "ss.rkt")
3+
4+
@title[#:tag "aspect"]{Fullscreen vs. Widescreen Aspect Ratio}
5+
6+
Fullscreen (4:3) versus widescreen (16:9) aspect mode is a property of
7+
an individual slide that can be selected using the @racket[#:aspect]
8+
argument to @racket[slide]. The @racketmodname[slideshow/widescreen]
9+
language provides a variant of @racket[slide] that makes
10+
@racket['widescreen] the default value of @racket[#:aspect], while
11+
@racketmodname[slideshow/fullscreen] provides a variant of
12+
@racket[slide] that makes @racket['fullscreen] the default.
13+
14+
When a slide's aspect is not specified, then it adopts an aspect that
15+
can be selected via the @DFlag{widescreen} or @DFlag{fullscreen} flag
16+
when Slideshow starts. (That selection can be made ``sticky'' as the
17+
default for future runs by using the @DFlag{save-aspect} flag.)
18+
Selecting an aspect also affects the values of @racket[client-w],
19+
@racket[client-h], @racket[full-page], and @racket[titleless-page]
20+
from @racketmodname[slideshow], but it does not affect the bindings
21+
from @racketmodname[slideshow/widescreen] or
22+
@racketmodname[slideshow/fullscreen]. Keep in mind that specifying
23+
@racket[#:aspect] for @racket[slide] does not affect the value of
24+
@racket[client-w], etc., for constructing the slide's content, but you
25+
can use @racket[get-client-w], etc., to obtain the aspect-specific
26+
metrics.
27+
28+
Use the @racketmodname[slideshow] language for slides and libraries
29+
that are meant to adapt to a user's selected aspect, and use
30+
@racketmodname[slideshow/fullscreen] or
31+
@racketmodname[slideshow/widescreen] for slides and libraries that
32+
assume specific values for a slide's drawing area.
33+
34+
@include-section["fullscreen.scrbl"]
35+
@include-section["widescreen.scrbl"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#lang scribble/manual
2+
@(require (for-label slideshow/fullscreen/base)
3+
"adjust-aspect.rkt")
4+
5+
@title[#:tag "fullscreen"]{Fullscreen Slides}
6+
7+
@declare-exporting[slideshow/fullscreen/base slideshow/fullscreen]
8+
9+
@defmodulelang*/no-declare[(slideshow/fullscreen)]
10+
@defmodule*/no-declare[(slideshow/fullscreen/base)]
11+
12+
The @racketmodname[slideshow/fullscreen/base] module is reprovided by
13+
the @racket[slideshow/fullscreen] language along with
14+
@racketmodname[racket] and @racketmodname[pict].
15+
16+
@history[#:added "1.5"]
17+
18+
@(declare-aspect-adjust slide 'fullscreen)
19+
@(declare-aspect-adjust para 'fullscreen)
20+
@(declare-aspect-adjust item 'fullscreen)
21+
@(declare-aspect-adjust subitem 'fullscreen)
22+
@(declare-aspect-adjust make-outline 'fullscreen)
23+
@(declare-aspect-adjust size-in-pixels 'fullscreen)
24+
25+
@(define-aspect-select client-w get-client-w 'fullscreen)
26+
@(define-aspect-select client-h get-client-h 'fullscreen)
27+
@(define-aspect-select full-page full-page 'fullscreen)
28+
@(define-aspect-select titleless-page titleless-page 'fullscreen)

slideshow-doc/scribblings/slideshow/guide.scrbl

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ the presentation with a given content. For example, the ``Hello
4545
World'' presentation can be defined by the following module:
4646

4747
@racketmod[
48-
slideshow
48+
slideshow (code:comment @#,t{or @racketmodname[slideshow/widescreen]})
4949

5050
(slide
5151
#:title "How to Say Hello"
@@ -187,39 +187,44 @@ slideshow
187187

188188
@; ------------------------------------------------------------------------
189189

190-
@section[#:tag "display-size"]{Display Size and Fonts}
191-
192-
Slideshow is configured for generating slides in @math{1024} by
193-
@math{768} pixel format. When the current display has a different
194-
size as Slideshow is started, the Slideshow display still
195-
occupies the entire screen, and pictures are scaled just before
196-
they are displayed. Thus, one picture unit reliably corresponds
197-
to a ``pixel'' that occupies @math{1/1024} by @math{1/768} of the
198-
screen.
199-
200-
The @racket[text] form for generating text pictures takes into
201-
account any expected scaling for the display when measuring
202-
text. (All Slideshow text functions, such as @racket[t] and
203-
@racket[item] are built on @racket[text].) In particular, scaling
204-
the picture causes a different font size to be used for drawing
205-
the slide---rather than bitmap-scaling the original font---and
206-
changing the font size by a factor of @math{k} does not
207-
necessarily scale all text dimensions equally by a factor of
208-
@math{k}---because, for most devices, each character must have
209-
integer dimensions. Nevertheless, especially if you use the
210-
@racket[current-expected-text-scale] parameter, Slideshow is
211-
usually able to produce good results when the slide is scaled.
212-
213-
More generally, different font sets on different platforms can
214-
change the way a slide is rendered. For example, the @racket[tt]
215-
font on one platform might be slightly wider than on another,
216-
causing different line breaks, and so on. Beware.
217-
218-
Beware also of using bitmaps in slides when the presentation
219-
screen is not @math{1024} by @math{768}. In that case, consider
220-
using @racket[size-in-pixels] (with the caveat that the resulting
221-
picture will take up different amounts of the slide on different
222-
displays).
190+
@section[#:tag "display-size"]{Display Size and Font Selection}
191+
192+
Slideshow is configured for generating slides in either @math{1024} by
193+
@math{768} for fullscreen (4:3) mode or @math{1360} by @math{766} for
194+
widescreen (16:9) mode. When the current display has a different size as
195+
Slideshow is started, the Slideshow display still occupies the entire
196+
screen, and pictures are scaled just before they are displayed. Thus,
197+
one picture unit reliably corresponds to a ``pixel'' that occupies
198+
@math{1/1024} by @math{1/768} of the screen or @math{1/1360} by
199+
@math{1/766} of the screen.
200+
201+
Fullscreen versus widescreen mode is a property of an individual slide
202+
that can be selected using the @racket[#:aspect] argument to
203+
@racket[slide], but the default is to adapt to a mode that the user
204+
selects with @DFlag{widescreen} or @DFlag{fullscreen}. See
205+
@secref["aspect"] for more information.
206+
207+
Beware that different font sets on different platforms can change the
208+
way a slide is rendered. For example, the @racket[tt] font on one
209+
platform might be slightly wider than on another, causing different
210+
line breaks, and so on. Beware also of using bitmaps in slides when
211+
the presentation screen's pixels do not exactly match the slide's
212+
drawing units. In that case, consider using @racket[size-in-pixels]
213+
(with the caveat that the resulting picture will take up different
214+
amounts of the slide on different displays).
215+
216+
Finally, beware that the @racket[text] form for generating text
217+
pictures attempts to take into account any expected scaling for the
218+
display when measuring text. (All Slideshow text functions, such as
219+
@racket[t] and @racket[item] are built on @racket[text].) On some
220+
devices, scaling the picture potentially causes a different font size
221+
to be used for drawing the slide---rather than bitmap-scaling the
222+
original font---and changing the font size by a factor of @math{k}
223+
does not necessarily scale all text dimensions equally by a factor of
224+
@math{k}. Modern displays and drawing libraries make this scaling
225+
compensation a smaller effect than it used to be, but using
226+
@racket[current-expected-text-scale] parameter can sometimes improve
227+
text scaling.
223228

224229
@; ------------------------------------------------------------------------
225230

slideshow-doc/scribblings/slideshow/slides.scrbl

Lines changed: 91 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
@defproc[(slide [#:title title (or/c #f string? pict?) #f]
2424
[#:name name (or/c #f string?) title]
25+
[#:aspect aspect aspect? #f]
2526
[#:layout layout (or/c 'auto 'center 'top 'tall) 'auto]
2627
[#:gap-size sep-gap-size real? (current-gap-size)]
2728
[#:inset inset slide-inset? (make-slide-inset 0 0 0 0)]
@@ -69,7 +70,9 @@ after @racket[secs] seconds, and manual advancing skips this slide.
6970

7071
If @racket[condense?] is true, then in condense mode (as specified by
7172
the @Flag{c} command-line flag), the slide is not created and
72-
registered.}
73+
registered.
74+
75+
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}
7376

7477

7578
@defproc[(t [str string?]) pict?]{
@@ -106,7 +109,8 @@ The normal way to make serif text. Returns @racket[(text str 'roman
106109

107110
Creates title text. Returns @racket[((current-titlet) str)].}
108111

109-
@defproc[(para [#:width width real? (current-para-width)]
112+
@defproc[(para [#:aspect aspect aspect? #f]
113+
[#:width width real? ((get-current-para-width #:aspect aspect))]
110114
[#:align align (or/c 'left 'center 'right) 'left]
111115
[#:fill? fill? any/c #t]
112116
[#:decode? decode? any/c #t]
@@ -144,10 +148,13 @@ The @racket[align] argument specifies how to align lines within the
144148
paragraph.
145149

146150
See the spacing between lines is determined by the
147-
@racket[current-line-sep] parameter.}
151+
@racket[current-line-sep] parameter.
152+
153+
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}
148154

149155

150-
@defproc[(item [#:width width real? (current-para-width)]
156+
@defproc[(item [#:aspect aspect aspect? #f]
157+
[#:width width real? ((get-current-para-width #:aspect aspect))]
151158
[#:gap-size sep-gap-size real? (current-gap-size)]
152159
[#:bullet blt pict? (scale bullet (/ sep-gap-size gap-size))]
153160
[#:align align (or/c 'left 'center 'right) 'left]
@@ -161,10 +168,13 @@ Like @racket[para], but with @racket[blt] followed by @racket[(/
161168
sep-gap-size 2)] space appended horizontally to the resulting paragraph,
162169
aligned with the top line. The paragraph width of @racket[blt] plus
163170
@racket[(/ sep-gap-size 2)] is subtracted from the maximum width of the
164-
paragraph.}
171+
paragraph.
165172

173+
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}
166174

167-
@defproc[(subitem [#:width width real? (current-para-width)]
175+
176+
@defproc[(subitem [#:aspect aspect aspect? #f]
177+
[#:width width real? ((get-current-para-width #:aspect aspect))]
168178
[#:gap-size sep-gap-size real? (current-gap-size)]
169179
[#:bullet blt pict? (scale o-bullet (/ sep-gap-size gap-size))]
170180
[#:align align (or/c 'left 'center 'right) 'left]
@@ -177,7 +187,9 @@ paragraph.}
177187
Like @racket[item], but an additional @racket[(* 2 sep-gap-size)] is
178188
subtracted from the paragraph width and added as space to the left of
179189
the pict. Also, @racket[o-bullet] is the default bullet, instead of
180-
@racket[bullet].}
190+
@racket[bullet].
191+
192+
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}
181193

182194

183195
@defproc[(clickback [pict pict?] [thunk (-> any)])
@@ -199,12 +211,17 @@ must be a procedure that is called when the window is removed (because
199211
the slide changes, for example).}
200212

201213

202-
@defproc[(size-in-pixels [pict pict?]) pict?]{
214+
@defproc[(size-in-pixels [pict pict?]
215+
[#:aspect aspect aspect? #f])
216+
pict?]{
203217

204218
Scales @racket[pict] so that it is displayed on the screen as
205219
@racket[(pict-width pict)] pixels wide and @racket[(pict-height pict)]
206220
pixels tall. The result is @racket[pict] when using a 1024 by 768
207-
display.}
221+
display with a fullscreen aspect or when using a 1360 by 766
222+
display with a widescreen aspect.
223+
224+
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}
208225

209226

210227
@defproc[(pict->pre-render-pict [pict pict?]) pict?]{
@@ -220,7 +237,8 @@ to reduce drawing times for for large bitmaps or complex drawings.
220237
[title (or/c string? pict?)]
221238
[subitems (or/c #f null?
222239
(symbol? . -> . pict?))]
223-
...)
240+
...
241+
[#:aspect aspect aspect? #f])
224242
(symbol? . -> . void?)]{
225243

226244
Returns a function that takes a symbol and generates an outline
@@ -245,7 +263,9 @@ trio of arguments defines a section for the outline:
245263
should be a function that takes a symbol (the same one passed
246264
to the outline maker) and produces a pict.}
247265

248-
]}
266+
]
267+
268+
@history[#:changed "1.5" @elem{Added the @racket[#:aspect] argument.}]}
249269

250270
@defproc[(comment [text (or/c string? pict?)] ...)
251271
comment?]{
@@ -364,6 +384,20 @@ this function with @racket[#t] enables new slides to start a new slideshow.
364384

365385
@section{Constants and Layout Variables}
366386

387+
@defproc[(aspect? [v any/c]) boolean?]{
388+
389+
Return @racket[#t] if @racket[v] is @racket['fullscreen],
390+
@racket['widescreen], or @racket[#f], otherwise returns @racket[#f].
391+
392+
A symbolic @racket[v] selects a specific aspect, while @racket[#f] as
393+
an aspect corresponds to a user-selected aspect through the
394+
@DFlag{widescreen} or @DFlag{fullscreen} flag.
395+
396+
See also @seclink["aspect"].
397+
398+
@history[#:added "1.5"]}
399+
400+
367401
@defthing[gap-size 24]{
368402

369403
A width commonly used for layout.}
@@ -399,32 +433,56 @@ It's implementation is:
399433
(blank 0 gap-size)))]
400434
}
401435

436+
@deftogether[(
437+
@defidform[client-w]
438+
@defproc[(get-client-w [#:aspect aspect aspect? #f]) exact-nonnegative-integer?]
439+
)]{
402440

403-
@defidform[client-w]{
441+
Produces the width of the display area, minus @racket[margin]s for a
442+
given @racket[aspect], where @racket[client-w] is equivalent to
443+
@racket[(get-client-w)]. The result changes if the margin is adjusted
444+
via @racket[set-margin!].
404445

405-
Produces the width of the display area, minus @racket[margin]s. The
406-
result of the form changes if the margin is adjusted via
407-
@racket[set-margin!].}
446+
@history[#:changed "1.5" @elem{Added @racket[get-client-w].}]}
408447

409448

410-
@defidform[client-h]{
449+
@deftogether[(
450+
@defidform[client-h]
451+
@defproc[(get-client-h [#:aspect aspect aspect? #f]) exact-nonnegative-integer?]
452+
)]{
411453

412-
Produces the height of the display area, minus @racket[margin]s, but
413-
including the title area). The result of the form changes if the
414-
margin is adjusted via @racket[set-margin!].}
454+
Produces the height of the display area, minus @racket[margin]s for a
455+
given @racket[aspect], where @racket[client-h] is equivalent to
456+
@racket[(get-client-h)]. The result changes if the margin is adjusted
457+
via @racket[set-margin!].
415458

459+
@history[#:changed "1.5" @elem{Added @racket[get-client-h].}]}
416460

417-
@defidform[full-page]{
461+
462+
@deftogether[(
463+
@defidform[full-page]
464+
@defproc[(get-full-page [#:aspect aspect aspect? #f]) pict?]
465+
)]{
418466

419467
Produces an empty pict that is the same size as the client area, which
420-
is like @racket[(blank client-w client-h)].}
468+
is like @racket[(blank client-w client-h)]. The @racket[full-page]
469+
form is equivalent to @racket[(get-full-page)].
470+
471+
@history[#:changed "1.5" @elem{Added @racket[get-full-page].}]}
421472

422473

423-
@defidform[titleless-page]{
474+
@deftogether[(
475+
@defidform[titleless-page]
476+
@defproc[(get-titleless-page [#:aspect aspect aspect? #f]) pict?]
477+
)]{
424478

425479
Produces an empty pict that is the same size as the client area minus
426480
the title area in @racket['top] layout mode, which is like
427-
@racket[(blank client-w (- client-h title-h (* 2 gap-size)))].}
481+
@racket[(blank client-w (- client-h title-h (* 2 gap-size)))]. The
482+
@racket[titleless-page] form is equivalent to
483+
@racket[(get-titleless-page)].
484+
485+
@history[#:changed "1.5" @elem{Added @racket[get-titleless-page].}]}
428486

429487

430488
@defidform[margin]{
@@ -485,10 +543,18 @@ Parameter that controls the amount of space used between lines by
485543
@racket[para], @racket[item], and @racket[subitem].}
486544

487545

488-
@defparam[current-para-width n exact-nonnegative-integer?]{
546+
@deftogether[(
547+
@defparam[current-para-width n exact-nonnegative-integer?]
548+
@defproc[(get-current-para-width (#:aspect aspect aspect? #f))
549+
(parameter/c exact-nonnegative-integer?)]
550+
)]{
489551

490552
Parameter that controls the width of a pict created by
491-
@racket[para], @racket[item], and @racket[subitem].}
553+
@racket[para], @racket[item], and @racket[subitem]. The value
554+
of @racket[current-para-width] is the same as
555+
@racket[(get-current-para-width)].
556+
557+
@history[#:changed "1.5" @elem{Added @racket[get-current-para-width].}]}
492558

493559

494560
@defparam[current-title-color color (or/c string? (is-a?/c color%))]{

0 commit comments

Comments
 (0)