Skip to content

Commit 8a24cf0

Browse files
committed
add the increment-splash argument to start-splash
1 parent ed332bc commit 8a24cf0

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

gui-doc/scribblings/framework/splash.scrbl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ that number to control the gauge along the bottom of the splash screen.
3232
(is-a?/c bitmap%)
3333
(cons/c (is-a?/c bitmap%)
3434
(is-a?/c bitmap%)))
35-
#f])
35+
#f]
36+
[#:increment-splash increment-splash
37+
(or/c #f (-> (-> void?) any))])
3638
void?]{
3739
Starts a new splash screen. The splash screen is created in its own, new
3840
@tech[#:doc '(lib "scribblings/gui/gui.scrbl") #:key "eventspace"]{eventspace}.
@@ -63,6 +65,14 @@ that number to control the gauge along the bottom of the splash screen.
6365

6466
The @racket[frame-icon] is used just like the value of the parameter @racket[frame:current-icon] is used,
6567
but for the splash screen.
68+
69+
If @racket[increment-splash] is @racket[#false],
70+
@racket[start-splah] sets the @racket[current-load]
71+
parameter to a function that advances the splash screen
72+
progress bar. If @racket[increment-splash] is a function, it
73+
calls the function with a thunk that will advance the splash
74+
screen progress bar.
75+
6676
}
6777

6878
@defproc[(shutdown-splash) void?]{

gui-lib/framework/splash.rkt

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
exact-nonnegative-integer?))
3737
string?
3838
exact-nonnegative-integer?)
39-
(#:allow-funny?
39+
(#:increment-splash
40+
(or/c #f (-> (-> void?) any))
41+
#:allow-funny?
4042
boolean?
4143
#:frame-icon
4244
(or/c #f
@@ -185,13 +187,18 @@
185187
(set! icons (cons (make-icon bm x y) icons))
186188
(refresh-splash)))
187189

188-
(define (start-splash splash-draw-spec _splash-title width-default
190+
(define (start-splash splash-draw-spec _splash-title width-default
191+
#:increment-splash [increment-splash #f]
189192
#:allow-funny? [allow-funny? #f]
190193
#:frame-icon [frame-icon #f])
191194
(unless allow-funny? (set! funny? #f))
192195
(set! splash-title _splash-title)
193196
(set! splash-max-width (max 1 (splash-get-preference (get-splash-width-preference-name) width-default)))
194197

198+
(cond
199+
[increment-splash (increment-splash inc-splash)]
200+
[else (install-splash-load-handler)])
201+
195202
(on-splash-eventspace/ret
196203
(let/ec k
197204
(define (no-splash)
@@ -288,7 +295,7 @@
288295
;; example)
289296
(define splash-range-ready? #f)
290297

291-
(define (splash-load-handler old-load f expected)
298+
(define (inc-splash)
292299
(set! splash-current-width (+ splash-current-width 1))
293300
(when (<= splash-current-width splash-max-width)
294301
(let ([splash-save-width splash-current-width])
@@ -298,22 +305,27 @@
298305
(when (or (not (member (get-gauge) (send gauge-panel get-children)))
299306
;; when the gauge is not visible, we'll redraw the canvas regardless
300307
(refresh-splash-on-gauge-change? splash-save-width splash-max-width))
301-
(refresh-splash)))))
308+
(refresh-splash))))))
309+
310+
(define (splash-load-handler old-load f expected)
311+
(inc-splash)
302312
(old-load f expected))
303313

304-
(let ([make-compilation-manager-load/use-compiled-handler
305-
(if (or (getenv "PLTDRCM")
306-
(getenv "PLTDRDEBUG"))
307-
(parameterize ([current-namespace (make-base-namespace)])
308-
(dynamic-require 'compiler/cm
309-
'make-compilation-manager-load/use-compiled-handler))
310-
#f)])
314+
(define (install-splash-load-handler)
315+
(set! install-splash-load-handler void)
316+
(define make-compilation-manager-load/use-compiled-handler
317+
(if (or (getenv "PLTDRCM")
318+
(getenv "PLTDRDEBUG"))
319+
(parameterize ([current-namespace (make-base-namespace)])
320+
(dynamic-require 'compiler/cm
321+
'make-compilation-manager-load/use-compiled-handler))
322+
#f))
311323

312324
(current-load
313325
(let ([old-load (current-load)])
314326
(λ (f expected)
315327
(splash-load-handler old-load f expected))))
316-
328+
317329
(when make-compilation-manager-load/use-compiled-handler
318330
(printf "PLTDRCM/PLTDRDEBUG: reinstalling CM load handler after setting splash load handler\n")
319331
(current-load/use-compiled (make-compilation-manager-load/use-compiled-handler))))

0 commit comments

Comments
 (0)