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

Scroller's thumbs problem

At  3:34 PM 5/25/93 +0000, SHELDON SHEN wrote:
>                      Scroller's thumbs problem
>;; 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
>;; 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.)

UPDATE-THUMBS gets called whenever you change the setting of one of
the scroll bars. If the setting is 0, it will call UPDATE-SCROLL-BAR-SETTING.
It does this in case the SCROLL-BAR-LIMITS have changed so that the
scroll bar should now be disabled (scroll-bar-max = scroll-bar-min).
The protocol expected by the scrollers package is that you will write
for your SCROLLER subclasses. One way to make your example work is the

(require 'scrollers)

(defclass myscroller (ccl::scroller)
  ((limits :initform (cons nil nil)
           :reader scroll-bar-limits-slot)))

(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 scroll-bar-limits ((self myscroller))
  (let ((limits (scroll-bar-limits-slot self))
        (size (view-size self)))
     (or (car limits) (point-h size))
     (or (cdr limits) (point-v size)))))

(defmethod resize ((self myscroller) x y)
  (let ((limits (scroll-bar-limits-slot self)))
    (setf (car limits) (make-point 0 x))
    (setf (cdr limits) (make-point 0 y)))
  (update-scroll-bar-limits self)

(resize *myscroller* 400 400)