anchor.diff:              (rads (mod (* pi degrees (/ 180)) (* 2 pi))))
           (unless (equal (elt transform-parameters param) rads)
             (setf (elt transform-parameters param) rads
  -                transform nil))))
  -    (handle-repaint viewer (sheet-region viewer))))
  +                transform nil)
  +          (handle-repaint viewer (or (pane-viewport-region viewer)
  +                                     (sheet-region viewer))))))))
   
   (defun y-shear-callback (gadget shear)
     (declare (ignore gadget))
     (let ((viewer (find-pane-named *application-frame* 'spectacle-pane)))
  -    (with-accessors ((image gadget-value)
  +    (with-accessors ((image image)
                        (transform-parameters transform-parameters)
                        (transform transform))
           viewer
         (let ((param 4))
           (unless (equal (elt transform-parameters param) shear)
             (setf (elt transform-parameters param) shear
  -                transform nil))))
  -    (handle-repaint viewer (sheet-region viewer))))
  +                transform nil)
  +          (handle-repaint viewer (or (pane-viewport-region viewer)
  +                                     (sheet-region viewer))))))))
   
   (defun x-shear-callback (gadget shear)
     (declare (ignore gadget))
     (let ((viewer (find-pane-named *application-frame* 'spectacle-pane)))
  -    (with-accessors ((image gadget-value)
  +    (with-accessors ((image image)
                        (transform-parameters transform-parameters)
                        (transform transform))
           viewer
         (let ((param 5))
           (unless (equal (elt transform-parameters param) shear)
             (setf (elt transform-parameters param) shear
  -                transform nil))))
  -    (handle-repaint viewer (sheet-region viewer))))
  +                transform nil)
  +          (handle-repaint viewer (or (pane-viewport-region viewer)
  +                                     (sheet-region viewer))))))))
   
   (define-application-frame spectacle ()
     ()
     (:menu-bar menubar-command-table)
     (:panes
  -   (viewer (make-clim-stream-pane 
  -            :type 'spectacle-pane
  -            :incremental-redisplay t
  -            :name 'spectacle-pane
  -            :width 500
  -            :background +black+
  -            :foreground +white+
  -            :scroll-bars :both))
  +   (viewer (scrolling ()
  +             (make-pane 'spectacle-pane
  +                        :name 'spectacle-pane
  +                        :width 500
  +                        :incremental-redisplay t
  +                        :background +black+
  +                        :foreground +white+)))
      (lock-scale :toggle-button
                  :label "Lock X and Y Scale"
                  :value t
  
positive.code:       (reset-transform-parameters transform-parameters)
        (setf transform nil
              image img)
        (com-zoom))))
  
  (define-spectacle-command (com-zoom :name t)
      ()
  
negative.code:                     (gadget-value x-scale-slider) scale)
                (setf (elt transform-parameters 0) scale
                      (elt transform-parameters 1) scale
                      transform nil))
              (change-space-requirements viewer :height oldy :width oldx))
            (handle-repaint viewer (or (pane-viewport-region viewer)
                                       (sheet-region viewer))))))))
  
  (define-spectacle-command (com-redraw :name t)
      ()
    (let ((viewer (find-pane-named *application-frame* 'spectacle-pane)))
      (handle-repaint viewer (or (pane-viewport-region viewer)
                                 (sheet-region viewer)))))
  
  (define-spectacle-command (com-reset :name t)
      ()
    (let ((viewer (find-pane-named *application-frame* 'spectacle-pane)))
      (with-accessors ((image image)
                       (transform-parameters transform-parameters)
                       (transform transform))
          viewer
        (reset-sliders)
        (reset-transform-parameters transform-parameters)
        (setf transform nil))
      (handle-repaint viewer (or (pane-viewport-region viewer)
                                 (sheet-region viewer)))))
  
  (define-spectacle-command (com-quit :name t :keystroke (#\q :meta)) ()
    (frame-exit *application-frame*))
  