[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scroller's thumbs problem

On Tue May 25 at 18:39:47 1993 Sheldon Shen writes:
>  ;; I found a strange problem in the following situation.
>  ;
>  ;; A initial scroller size is setup as #@(184 184).
>  ;; Resize the scrollable size to #@(400 400) by calling resize.
>  ;; Click the window and the view size is changed correctly.
>  ;; Now try to move (click) any of the scroller thumbs away from 0, and then
>    move it back to 0.
>  ;; (This problem only happens when the thumbs are moved away and back to 0)
>   ;; Click the view again, and the view size is automatically set back to
#@(184 184).
> ;; But the view size at this point should still be #@(400 400).
;; (i.e., Moving the thumbs away and back to 0 triggers the view size change.)

(require 'scrollers)
(defclass myscroller (ccl::scroller) ())
(defmethod view-click-event-handler ((self myscroller) where)
  (declare (ignore where))
  (print (point-string (make-point (scroll-bar-max (ccl::h-scroller self))
(scroll-bar-max (ccl::v-scroller self)))))
(setq *w* (make-instance 'window
            :view-size #@(200 200)
(setq *myscroller*
           (make-instance 'myscroller
             :view-container *w*
             :track-thumb-p t
             :view-size #@(184 184)
             :view-position #@(0 0)
(defmethod resize ((self myscroller) x y)
  (setf (scroll-bar-max (ccl::h-scroller self)) x)
  (setf (scroll-bar-max (ccl::v-scroller self)) y)
(resize *myscroller* 400 400)
;;The problem can be fixed by adding the following code.
;;But should this be necessary?
;;What is the intended behavior of moving thumbs away and back to 0.
(defmethod view-click-event-handler :after ((self ccl::scroll-bar-dialog-item)
  (declare (ignore where))
  (if (eq 0 (ccl::scroll-bar-setting self)) (resize *myscroller* 400 400))

->   Although you didn't include it in you code, I assume you
->   executed the following (add-subviews *w* *myscroller*)

To avoid the problems, create a ccl::scrolling-window to handle the scrolling
view directly. The code in the examples folder in scrolling-window.lisp
includes code to handle window-zoom-event directly:
  (defmethod window-zoom-event-handler ((self scrolling-window) message)
    (declare (ignore message))
     (let* ((new-size (subtract-points (view-size self) #@(15 15))))
       (set-view-size (my-scroller self) new-size))))

The following code works correctly and is simpler:
(require 'scrolling-window "Examples:scrolling-window")

(setq *w* (make-instance 'ccl::scrolling-window
            :view-size #@(200 200)
;(set-view-size *w* 400 400)
;(set-view-size *w* 100 100)