Skip to content

Commit 2394988

Browse files
committed
improve the prefs dialog
1 parent 27a85b4 commit 2394988

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

gui-lib/framework/private/color-prefs.rkt

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,8 @@
12631263
(define check-box
12641264
(new check-box%
12651265
[label (if (color-scheme-white-on-black-base? color-scheme)
1266-
"Dark Mode Color Scheme"
1267-
"Light Mode Color Scheme")]
1266+
(string-constant dark-mode-color-scheme)
1267+
(string-constant light-mode-color-scheme))]
12681268
[parent bp]
12691269
[value (equal?
12701270
(preferences:get (if (color-scheme-white-on-black-base? color-scheme)
@@ -1285,16 +1285,64 @@
12851285
(equal? val (color-scheme-name color-scheme)))))
12861286
(update-colors #f)
12871287
msg))
1288+
(define bottom-hp
1289+
(new horizontal-panel%
1290+
[parent vp]
1291+
[stretchable-height #f]))
12881292
(define revert-button%
12891293
(new button%
1290-
[label "Revert Colors to Color Scheme’s Default Colors"]
1291-
[parent vp]
1294+
[label (string-constant revert-colors-to-color-scheme-defaults)]
1295+
[parent bottom-hp]
12921296
[callback
12931297
(λ (x y)
12941298
(revert-to-color-scheme-defaults
12951299
(get-current-color-scheme
12961300
#:wob?
12971301
(white-on-black-panel-scheme?))))]))
1302+
(define white-on-black-mode-choice
1303+
(case (system-type)
1304+
[(windows)
1305+
(new choice%
1306+
[parent bottom-hp]
1307+
[label (string-constant color-mode)]
1308+
[choices (list (string-constant light-mode)
1309+
(string-constant dark-mode))]
1310+
[selection (if (preferences:get 'framework:white-on-black-mode?) 1 0)]
1311+
[callback
1312+
(λ (_1 _2)
1313+
(preferences:set 'framework:white-on-black-mode?
1314+
(match (send white-on-black-mode-choice get-selection)
1315+
[0 #f]
1316+
[1 #t])))])
1317+
(preferences:add-callback
1318+
'framework:white-on-black-mode?
1319+
(λ (_1 val)
1320+
(send white-on-black-mode-choice
1321+
set-selection
1322+
(if val 1 0))))]
1323+
[else
1324+
(new choice%
1325+
[parent bottom-hp]
1326+
[label (string-constant color-mode)]
1327+
[choices (list (string-constant use-os-dark-mode-selection)
1328+
(string-constant always-light-mode)
1329+
(string-constant always-dark-mode))]
1330+
[callback
1331+
(λ (_1 _2)
1332+
(preferences:set 'framework:white-on-black-mode?
1333+
(match (send white-on-black-mode-choice get-selection)
1334+
[0 'platform]
1335+
[1 #f]
1336+
[2 #t])))])
1337+
(preferences:add-callback
1338+
'framework:white-on-black-mode?
1339+
(λ (_1 val)
1340+
(send white-on-black-mode-choice
1341+
set-selection
1342+
(match val
1343+
['platform 0]
1344+
[#t 2]
1345+
[#f 1]))))]))
12981346
(define wid (apply max (map (λ (x) (send x get-width)) buttons)))
12991347
(for ([b (in-list buttons)])
13001348
(send b min-width wid))

gui-lib/framework/private/main.rkt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,3 +630,20 @@
630630
(color-prefs:change-colors-to-match-color-scheme
631631
(or (color-prefs:lookup-color-scheme val)
632632
(color-prefs:built-in-wob-color-scheme))))))
633+
634+
(preferences:add-callback
635+
'framework:white-on-black-mode?
636+
(λ (sym val)
637+
(define wob?
638+
(match val
639+
['platform (white-on-black-panel-scheme?)]
640+
[#t #t]
641+
[#f #f]))
642+
(define pref-name (if wob? 'framework:color-scheme-wob 'framework:color-scheme))
643+
(define pref-val (preferences:get pref-name))
644+
(define found-color-scheme (color-prefs:lookup-color-scheme pref-val))
645+
(color-prefs:change-colors-to-match-color-scheme
646+
(or found-color-scheme
647+
(if wob?
648+
(color-prefs:built-in-wob-color-scheme)
649+
(color-prefs:built-in-color-scheme))))))

gui-lib/info.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"pict-lib"
1414
"scheme-lib"
1515
["scribble-lib" #:version "1.36"]
16-
["string-constants-lib" #:version "1.41"]
16+
["string-constants-lib" #:version "1.55"]
1717
"option-contract-lib"
1818
"2d-lib"
1919
"compatibility-lib"

0 commit comments

Comments
 (0)