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

Re: Problem Example -- Scroll-bar Max

> Earlier I described a problem with set-scroll-bar-max.  Here's an
> example, lifted from the "library" folder, file "scroller.lisp":
> [elided]

The initial scroll-bar-max value was 75, and it was calculated for you,
based on the scroll bar's length, and the "normal" view size. As you
say, the code that kicks in when setting reaches min that checks to see
if the scroll bar should be disabled (entire content of scrollee visible)
is setting max back to the "normal" value. In the case of your example
you need to also change (as before you need to be in package :ccl):
(defmethod scroll-bar-limits ((view scroller1))
  (normal-scroll-bar-limits view 275 275))

More generally, you will -not- want to override the default
scroll-bar-limits method as the example does. To see this with the
example already loaded, you'll need to remove the method:
(let* ((generic-function (symbol-function 'scroll-bar-limits))
       (method (find-method generic-function '() (list (find-class
  (remove-method generic-function method))

Call the following function instead of setting max explicitly:
(defun adjust-scroll-sizes (view h-increment v-increment)
  "Called when the size of the scrollable image changes. This
adjusts the scroll-bar-max and the field-size slots."
  (let ((h-scroller (slot-value view 'h-scroller))
        (v-scroller (slot-value view 'v-scroller))
        (old-size (slot-value view 'field-size))
        (old-h-max 0)
        (old-v-max 0))
    (when h-scroller
      (setf old-h-max (scroll-bar-max h-scroller))
      (when (not (zerop h-increment))
        (set-scroll-bar-max h-scroller (+ old-h-max h-increment))))
    (when v-scroller
      (setf old-v-max (scroll-bar-max v-scroller))
      (when (not (zerop v-increment))
        (set-scroll-bar-max v-scroller (+ old-v-max v-increment))))
    (unless old-size
      (setf old-size
            (add-points (view-size view) (make-point old-h-max old-v-max))))
    (setf (slot-value view 'field-size)
          (add-points old-size (make-point h-increment v-increment)))))

In your case, to increase max from 75 to 150 (for both scrollers):
(adjust-scroll-sizes bar  75  75)
[I have not been able to figure out why the scrollee is called bar]