|
105 | 105 | (define-values (max-rx max-ry) (get-max/min-x/y max running-points)) |
106 | 106 | (define-values (min-wx min-wy) (get-max/min-x/y min waiting-points)) |
107 | 107 | (define-values (max-wx max-wy) (get-max/min-x/y max waiting-points)) |
108 | | - (let* ([running-w (* small-factor (- max-rx min-rx))] |
109 | | - [waiting-w (* small-factor (- max-wx min-wx))] |
110 | | - [running-h (* small-factor (- max-ry min-ry))] |
111 | | - [waiting-h (* small-factor (- max-wy min-wy))] |
112 | | - [w (+ 2 (ceiling (max running-w waiting-w)))] |
113 | | - [h (+ 2 (ceiling (max running-h waiting-h)))] |
114 | | - [running-dx (+ 1 (- (/ w 2) (/ running-w 2)))] |
115 | | - [running-dy (+ 1 (- (/ h 2) (/ running-h 2)))] |
116 | | - [waiting-dx (+ 1 (- (/ w 2) (/ waiting-w 2)))] |
117 | | - [waiting-dy (+ 1 (- (/ h 2) (/ waiting-h 2)))]) |
118 | | - (values w h running-dx running-dy waiting-dx waiting-dy))) |
| 108 | + (define running-w (* small-factor (- max-rx min-rx))) |
| 109 | + (define waiting-w (* small-factor (- max-wx min-wx))) |
| 110 | + (define running-h (* small-factor (- max-ry min-ry))) |
| 111 | + (define waiting-h (* small-factor (- max-wy min-wy))) |
| 112 | + (define w (+ 2 (ceiling (max running-w waiting-w)))) |
| 113 | + (define h (+ 2 (ceiling (max running-h waiting-h)))) |
| 114 | + (define running-dx (+ 1 (- (/ w 2) (/ running-w 2)))) |
| 115 | + (define running-dy (+ 1 (- (/ h 2) (/ running-h 2)))) |
| 116 | + (define waiting-dx (+ 1 (- (/ w 2) (/ waiting-w 2)))) |
| 117 | + (define waiting-dy (+ 1 (- (/ h 2) (/ waiting-h 2)))) |
| 118 | + (values w h running-dx running-dy waiting-dx waiting-dy)) |
119 | 119 |
|
120 | 120 | (define (get-bitmap points green) |
121 | 121 | (define-values (min-rx min-ry) (get-max/min-x/y min points)) |
122 | 122 | (define-values (max-rx max-ry) (get-max/min-x/y max points)) |
123 | | - (let* ([margin 2] |
124 | | - [bw (+ margin margin (ceiling (* small-factor (- max-rx min-rx))))] |
125 | | - [bh (+ margin margin (ceiling (* small-factor (- max-ry min-ry))))] |
126 | | - [w (ceiling (* bw small-bitmap-factor))] |
127 | | - [h (ceiling (* bh small-bitmap-factor))] |
128 | | - [bm-big (make-object bitmap% bw bh)] |
129 | | - [bm-solid (make-object bitmap% w h)] |
130 | | - [bm-small (make-object bitmap% w h)] |
131 | | - [bdc-big (make-object bitmap-dc% bm-big)] |
132 | | - [bdc-solid (make-object bitmap-dc% bm-solid)] |
133 | | - [bdc-small (make-object bitmap-dc% bm-small)]) |
134 | | - (send bdc-big clear) |
135 | | - (draw-callback bdc-big small-factor #f points |
136 | | - (+ margin (- (* small-factor min-rx))) |
137 | | - (+ margin #;(- (* small-factor min-ry))) |
138 | | - 3) |
139 | | - |
140 | | - (send bdc-small clear) |
141 | | - (send bdc-small set-scale small-bitmap-factor small-bitmap-factor) |
142 | | - (send bdc-small draw-bitmap bm-big 0 0) |
143 | | - (send bdc-small set-scale 1 1) |
144 | | - |
145 | | - (send bdc-solid set-brush green 'solid) |
146 | | - (send bdc-solid set-pen green 1 'solid) |
147 | | - (send bdc-solid draw-rectangle 0 0 w h) |
148 | | - |
149 | | - (send bdc-solid set-bitmap #f) |
150 | | - (send bdc-small set-bitmap #f) |
151 | | - (send bdc-big set-bitmap #f) |
152 | | - |
153 | | - (send bm-solid set-loaded-mask bm-small) |
154 | | - bm-solid)) |
| 123 | + (define margin 2) |
| 124 | + (define bw (+ margin margin (ceiling (* small-factor (- max-rx min-rx))))) |
| 125 | + (define bh (+ margin margin (ceiling (* small-factor (- max-ry min-ry))))) |
| 126 | + (define w (ceiling (* bw small-bitmap-factor))) |
| 127 | + (define h (ceiling (* bh small-bitmap-factor))) |
| 128 | + (define bm-big (make-object bitmap% bw bh)) |
| 129 | + (define bm-solid (make-object bitmap% w h)) |
| 130 | + (define bm-small (make-object bitmap% w h)) |
| 131 | + (define bdc-big (make-object bitmap-dc% bm-big)) |
| 132 | + (define bdc-solid (make-object bitmap-dc% bm-solid)) |
| 133 | + (define bdc-small (make-object bitmap-dc% bm-small)) |
| 134 | + (send bdc-big clear) |
| 135 | + (draw-callback bdc-big small-factor #f points |
| 136 | + (+ margin (- (* small-factor min-rx))) |
| 137 | + (+ margin #;(- (* small-factor min-ry))) |
| 138 | + 3) |
| 139 | + (send bdc-small clear) |
| 140 | + (send bdc-small set-scale small-bitmap-factor small-bitmap-factor) |
| 141 | + (send bdc-small draw-bitmap bm-big 0 0) |
| 142 | + (send bdc-small set-scale 1 1) |
| 143 | + (send bdc-solid set-brush green 'solid) |
| 144 | + (send bdc-solid set-pen green 1 'solid) |
| 145 | + (send bdc-solid draw-rectangle 0 0 w h) |
| 146 | + (send bdc-solid set-bitmap #f) |
| 147 | + (send bdc-small set-bitmap #f) |
| 148 | + (send bdc-big set-bitmap #f) |
| 149 | + (send bm-solid set-loaded-mask bm-small) |
| 150 | + bm-solid) |
155 | 151 |
|
156 | 152 | (define (get-running-bitmap) (get-bitmap running-points (make-object color% 30 100 30))) |
157 | 153 | (define (get-waiting-bitmap) (get-bitmap waiting-points (make-object color% 30 100 30))) |
158 | 154 |
|
159 | 155 | (define (normalize points) |
160 | 156 | (define-values (min-x min-y) (get-max/min-x/y min points)) |
161 | 157 | (map (λ (x) (list (car x) |
162 | | - (+ (- (list-ref x 1) min-x)) |
163 | | - (+ (- (list-ref x 2) min-y)))) |
| 158 | + (- (list-ref x 1) min-x) |
| 159 | + (- (list-ref x 2) min-y))) |
164 | 160 | points)) |
165 | 161 |
|
166 | 162 | (define (get-max/min-x/y choose points) |
|
242 | 238 | (cond |
243 | 239 | [(send evt button-down? 'left) |
244 | 240 | (define-values (w h) (get-client-size)) |
245 | | - (let ([x (send evt get-x)] |
246 | | - [y (send evt get-y)]) |
247 | | - (let ([point (find-point this x y)]) |
248 | | - (when point |
249 | | - (set! clicked-x x) |
250 | | - (set! clicked-y y) |
251 | | - (set! clicked-point point) |
252 | | - (let ([orig-point (assoc point points)]) |
253 | | - (set! orig-x (list-ref orig-point 1)) |
254 | | - (set! orig-y (list-ref orig-point 2))))))] |
| 241 | + (define x (send evt get-x)) |
| 242 | + (define y (send evt get-y)) |
| 243 | + (let ([point (find-point this x y)]) |
| 244 | + (when point |
| 245 | + (set! clicked-x x) |
| 246 | + (set! clicked-y y) |
| 247 | + (set! clicked-point point) |
| 248 | + (let ([orig-point (assoc point points)]) |
| 249 | + (set! orig-x (list-ref orig-point 1)) |
| 250 | + (set! orig-y (list-ref orig-point 2)))))] |
255 | 251 | [(and clicked-point (send evt moving?)) |
256 | 252 | (set! points |
257 | 253 | (map (λ (x) |
|
0 commit comments