From 32374df5567628b5266351b6bebf5e63577b3fe2 Mon Sep 17 00:00:00 2001 From: Neil Toronto Date: Sat, 5 Apr 2014 16:04:47 -0600 Subject: [PATCH] Create plot frames in current eventspace; fix plot snip resize override As suggested by Robby and Eli here: http://lists.racket-lang.org/users/archive/2013-March/056771.html both `plot-frame' and `plot' (when `plot-new-window?' is #t) now create frames in the caller's eventspace. Doing so fixes the problem talked about in that thread, and seems like good behavior overall. Plots created a separate eventspace because of the issue raised here: http://lists.racket-lang.org/users/archive/2012-April/051485.html in which a user was flummoxed by the fact that framed plots don't draw during read loops in which events can't be processed, and the suggested solution wasn't easy or obvious. Users may get Plot's old behavior by (parameterize ([current-eventspace (make-eventspace)]) (plot ...)) which, though still not obvious, is at least easy. Related to PR 13535: from the user's feedback, plots having their own eventspaces may cause framed plots to render at the wrong size initially, and may partly cause them to not redraw when their frame is resized. Hopefully the eventspace change fixes one or both problems. If not, maybe this will: 2d-plot-snip% and 3d-plot-snip%, which descend from image-snip%, now properly call the superclass method within their `resize' overrides, so their editors will be notified of the change and hopefully redraw them. --- pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/gui.rkt | 7 +------ pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt | 4 ++-- pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot3d.rkt | 4 ++-- pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip2d.rkt | 2 +- pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip3d.rkt | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/gui.rkt b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/gui.rkt index e07b1b319f..404dc863c6 100644 --- a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/gui.rkt +++ b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/gui.rkt @@ -20,8 +20,7 @@ (define (make-snip w h) snip) (define frame - (parameterize ([current-eventspace (make-eventspace)]) - (new snip-frame% [label label] [width (+ 20 width)] [height (+ 20 height)]))) + (new snip-frame% [label label] [width (+ 20 width)] [height (+ 20 height)])) (new snip-canvas% [parent frame] @@ -30,7 +29,3 @@ [horizontal-inset 5] [vertical-inset 5]) frame) - -(define (with-new-eventspace thnk) - (parameterize ([current-eventspace (make-eventspace)]) - (thnk))) diff --git a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt index e646f19bd7..a8330352ae 100644 --- a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt +++ b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt @@ -17,7 +17,7 @@ ;; Require lazily, in case someone wants to just (require plot) in a headless setup (lazy-require ["snip2d.rkt" (make-2d-plot-snip)] - ["gui.rkt" (make-snip-frame with-new-eventspace)]) + ["gui.rkt" (make-snip-frame)]) (provide plot-snip plot-frame plot) @@ -128,7 +128,7 @@ (when out-file (call plot-file out-file out-kind)) - (cond [(plot-new-window?) (define frame (with-new-eventspace (λ () (call plot-frame)))) + (cond [(plot-new-window?) (define frame (call plot-frame)) (send frame show #t) (void)] [else (call plot-snip)]))) diff --git a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot3d.rkt b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot3d.rkt index be1be1a715..648e1a47c3 100644 --- a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot3d.rkt +++ b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot3d.rkt @@ -17,7 +17,7 @@ ;; Require lazily, in case someone wants to just (require plot) in a headless setup (lazy-require ["snip3d.rkt" (make-3d-plot-snip)] - ["gui.rkt" (make-snip-frame with-new-eventspace)]) + ["gui.rkt" (make-snip-frame)]) (provide plot3d-snip plot3d-frame plot3d) @@ -160,7 +160,7 @@ (when out-file (call plot3d-file out-file out-kind)) - (cond [(plot-new-window?) (define frame (with-new-eventspace (λ () (call plot3d-frame)))) + (cond [(plot-new-window?) (define frame (call plot3d-frame)) (send frame show #t) (void)] [else (call plot3d-snip)]))) diff --git a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip2d.rkt b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip2d.rkt index a6d39bbdf8..2b948fed49 100644 --- a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip2d.rkt +++ b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip2d.rkt @@ -205,7 +205,7 @@ (when (not (update-thread-running?)) (start-update-thread #t)) (set-update #t)) - #f) + (super resize w h)) )) (define (make-2d-plot-snip diff --git a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip3d.rkt b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip3d.rkt index f244afddf8..bc7aadc227 100644 --- a/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip3d.rkt +++ b/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/snip3d.rkt @@ -131,7 +131,7 @@ (when (not (update-thread-running?)) (start-update-thread #t)) (set-update #t)) - #f) + (super resize w h)) )) (define (make-3d-plot-snip