Appearance tweak: frame color change on focus

This commit is contained in:
Tony Garnock-Jones 2017-10-23 17:53:47 +01:00
parent 28f337b6cc
commit f6302cb668
1 changed files with 11 additions and 5 deletions

16
gui.rkt
View File

@ -17,7 +17,8 @@
(define theme-title-font (make-parameter "Roboto Condensed")) (define theme-title-font (make-parameter "Roboto Condensed"))
(define theme-title-font-size (make-parameter 20)) (define theme-title-font-size (make-parameter 20))
(define theme-title-font-color (make-parameter "white")) (define theme-title-font-color (make-parameter "white"))
(define theme-title-bar-color (make-parameter (hsv->color 260 1 1))) (define theme-title-bar-color (make-parameter (hsv->color 260 1 0.6)))
(define theme-title-bar-selected-color (make-parameter (hsv->color 260 1 1)))
(define theme-title-bar-height (make-parameter 48)) (define theme-title-bar-height (make-parameter 48))
(define theme-button-background-color (make-parameter (hsv->color 30 0.9 1))) (define theme-button-background-color (make-parameter (hsv->color 30 0.9 1)))
(define theme-button-color (make-parameter "white")) (define theme-button-color (make-parameter "white"))
@ -363,12 +364,15 @@
(define title-text-i (title-font-text title)) (define title-text-i (title-font-text title))
(define title-text-w (i:image-width title-text-i)) (define title-text-w (i:image-width title-text-i))
(define title-text-h (i:image-height title-text-i)) (define title-text-h (i:image-height title-text-i))
(define title-bar-i (i:rectangle 1 1 "solid" (theme-title-bar-color))) (define (title-bar-i focus?) (i:rectangle 1 1 "solid"
(if focus?
(theme-title-bar-selected-color)
(theme-title-bar-color))))
(define close-icon-w (i:image-width close-icon-i)) (define close-icon-w (i:image-width close-icon-i))
(define close-icon-h (i:image-height close-icon-i)) (define close-icon-h (i:image-height close-icon-i))
(define gap (/ (- (theme-title-bar-height) close-icon-w) 2)) (define gap (/ (- (theme-title-bar-height) close-icon-w) 2))
(define backdrop (i:rectangle 1 1 "solid" backdrop-color)) (define backdrop (i:rectangle 1 1 "solid" backdrop-color))
(lambda (z rect) (lambda (z rect focus?)
(match-define (rectangle left top width height) rect) (match-define (rectangle left top width height) rect)
(sprite #:id id (sprite #:id id
#:parent parent-id #:parent parent-id
@ -379,7 +383,7 @@
(scale ,(+ width (* 2 (theme-window-border-width))) (scale ,(+ width (* 2 (theme-window-border-width)))
,(+ height (theme-title-bar-height) (theme-window-border-width))) ,(+ height (theme-title-bar-height) (theme-window-border-width)))
(touchable (,id window-backdrop) ,in-unit-square?) (touchable (,id window-backdrop) ,in-unit-square?)
(texture ,title-bar-i)) (texture ,(title-bar-i focus?)))
(push-matrix (translate 0 ,(- (theme-title-bar-height))) (push-matrix (translate 0 ,(- (theme-title-bar-height)))
(scale ,width ,(theme-title-bar-height)) (scale ,width ,(theme-title-bar-height))
(touchable (,id title-bar) ,in-unit-square?)) (touchable (,id title-bar) ,in-unit-square?))
@ -426,9 +430,11 @@
(on (message (raise-widget window-id)) (on (message (raise-widget window-id))
(z (- (current-inexact-milliseconds)))) (z (- (current-inexact-milliseconds))))
(define/query-value focus? #f (top-widget window-id) #t)
(define/dataflow bounds (rectangle (x) (y) (width) (height)) #:default zero-rectangle) (define/dataflow bounds (rectangle (x) (y) (width) (height)) #:default zero-rectangle)
(assert (window-state window-id window-title (bounds))) (assert (window-state window-id window-title (bounds)))
(assert (outbound (c (z) (bounds))))) (assert (outbound (c (z) (bounds) (focus?)))))
(spawn #:name 'top-widget-monitor (spawn #:name 'top-widget-monitor
(local-require data/heap) (local-require data/heap)