From caec6d0711e3df46dd5383be9a6b95cf288c3c05 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 8 Apr 2013 09:45:50 -0500 Subject: [PATCH] shortcircuit some of the code involved in drawing the margin highlight for online expansion errors This avoids drawing the margin highlight when it isn't inside the region being repainted and it avoids even figuring anything out about it when there is currently no error range NOT for the release branch --- collects/drracket/private/module-language.rkt | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/collects/drracket/private/module-language.rkt b/collects/drracket/private/module-language.rkt index 108be61b3f..265db2e92c 100644 --- a/collects/drracket/private/module-language.rkt +++ b/collects/drracket/private/module-language.rkt @@ -1224,34 +1224,41 @@ (define/override (on-paint before? dc left top right bottom dx dy draw-caret) (super on-paint before? dc left top right bottom dx dy draw-caret) - (unless before? - (define saved-brush (send dc get-brush)) - (define saved-pen (send dc get-pen)) - (define smoothing (send dc get-smoothing)) - (send dc set-smoothing 'smoothed) - - (send dc set-brush "red" 'solid) - (send dc set-pen (send the-pen-list find-or-create-pen "red" 1 'transparent)) - (send dc set-alpha - (if (preferences:get 'framework:white-on-black?) - .5 - .25)) - (define path (new dc-path%)) + (unless (null? online-error-ranges) + (unless before? - (for ([an-error-range (in-list online-error-ranges)]) - (define-values (x y w h) (get-box an-error-range)) + (define path (new dc-path%)) + (define found-something-to-draw? #f) - (send path move-to (+ dx x) (+ dy y)) - (send path line-to (+ dx x w) (+ dy y)) - (send path line-to (+ dx x w) (+ dy y h)) - (send path arc (+ dx x) (+ dy y) (* w 2/3) h (* pi 3/2) (* pi 1/2)) - (send path close)) - - (send dc draw-path path) - (send dc set-alpha 1) - (send dc set-brush saved-brush) - (send dc set-pen saved-pen) - (send dc set-smoothing smoothing))) + (for ([an-error-range (in-list online-error-ranges)]) + (define-values (x y w h) (get-box an-error-range)) + (when (rectangles-intersect? x y (+ x w) (+ y h) + left top right bottom) + (set! found-something-to-draw? #t) + (send path move-to (+ dx x) (+ dy y)) + (send path line-to (+ dx x w) (+ dy y)) + (send path line-to (+ dx x w) (+ dy y h)) + (send path arc (+ dx x) (+ dy y) (* w 2/3) h (* pi 3/2) (* pi 1/2)) + (send path close))) + + (when found-something-to-draw? + (define saved-brush (send dc get-brush)) + (define saved-pen (send dc get-pen)) + (define smoothing (send dc get-smoothing)) + (send dc set-smoothing 'smoothed) + + (send dc set-brush "red" 'solid) + (send dc set-pen "red" 1 'transparent) + (send dc set-alpha + (if (preferences:get 'framework:white-on-black?) + .5 + .25)) + + (send dc draw-path path) + (send dc set-alpha 1) + (send dc set-brush saved-brush) + (send dc set-pen saved-pen) + (send dc set-smoothing smoothing))))) (define/override (on-event evt) (define-values (mx my)