.
original commit: b2b0f08835f89f00c7a41d113fa511d66f0b4a7a
This commit is contained in:
parent
6283c93edf
commit
66f3d1bb81
|
@ -1,5 +1,8 @@
|
|||
|
||||
The canvas test frame is primarily for checking the behvaiour of the
|
||||
Overview
|
||||
--------
|
||||
|
||||
This canvas test frame is for checking the behvaiour of the
|
||||
scrollbars. Canvas scrollbars work in one of two modes:
|
||||
1) Managing: the scrollbar determines the size and offset of
|
||||
the canvas's drawing area.
|
||||
|
@ -10,9 +13,9 @@ In the test frame, the top canvas is initially unmanaged, and the
|
|||
bottom is managed.
|
||||
|
||||
An HVCanvas has both horizontal and vertical scrollbars, but the
|
||||
scrollbars are initially disabled. Clikcing the "Vertical Scroll"
|
||||
scrollbars are initially disabled. Clikcing the "Enable Vertical"
|
||||
checkbox enables the vertical scroll. A VCanvas has only a vertical
|
||||
scrollbar; clicking "Horizontal Scroll" in this case has no effect.
|
||||
scrollbar; clicking "ENable Horizontal" in this case has no effect.
|
||||
When a canvas is managed by its scrollbars and a scrollbar is missing
|
||||
in a particular direction, it should act the same as an unmanaged
|
||||
canvas in that direction.
|
||||
|
@ -29,24 +32,144 @@ On each canvas, the following are painted at 0,0:
|
|||
- The client size of the canvas
|
||||
- The drawing area of the canvas
|
||||
These should be the same for UNMANAGED canvases/directions
|
||||
* Two lines showing the boundaries of the canvas if it
|
||||
is managed and the scrollbars is enabled. When the canvas
|
||||
is managed with a vertical scrollbar, the bottom boundary
|
||||
line should not be visible (i.e., it should be clipped).
|
||||
* Two lines showing what each `virtual boundary' of the canvas would
|
||||
be if it is managed and the scrollbar is enabled. (Initially, the
|
||||
bottom canvas's boundaries are probably beyond the visible region.)
|
||||
When the canvas is managed with a vertical scrollbar, the bottom
|
||||
boundary line might not be visible, i.e., it might be clipped - but
|
||||
it must be clipped eactly in that case.
|
||||
|
||||
As the scroll is changed for the bottom canvas, the information will
|
||||
move, because the scrolls are automatically adjusting the offset of
|
||||
the canvas. For the top canvas, the information is always visible in
|
||||
As the scroll is changed for the managed canvas, the information will
|
||||
move, because the scrolls automatically adjust the offset of the
|
||||
canvas. For the unmanaged canvas, the information is always visible in
|
||||
the same place; it is just updated.
|
||||
|
||||
The top's scrollbars have a range of 10 and a page step of 3. The
|
||||
bottom's scrollbars have a range of 20 and a page step of 3 (although
|
||||
the page step is generally ignored for a managed canvas). In the
|
||||
bottom frame, one vertical scroll step is mapped to 10 pixels and one
|
||||
horizontal step to 25 pixels, making the drawing area 200 pixels high
|
||||
and 500 pixels wide.
|
||||
the page step is sometimes ignored for a managed canvas). In managed
|
||||
mode:
|
||||
|
||||
The "Small" checkbox changes the bottom's range to 2 instead of
|
||||
20. This will make the drawing area of the canvas small.
|
||||
* In the bottom canvas, one vertical scroll step is mapped to 10
|
||||
pixels and one horizontal step to 25 pixels, making the virtual
|
||||
area 200 pixels high and 500 pixels wide.
|
||||
|
||||
When the "Small" checkbox is checked, the range is changed to 2
|
||||
instead of 20, making the virtual size 20 high by 50 wide.
|
||||
|
||||
* In the bottom canvas, one vertical or horizontal scroll step is
|
||||
mapped to 1 pixel, making the virtual area 10x10.
|
||||
|
||||
Initially, the top canvas is unmanaged and the bottom is managed.
|
||||
Checking the "swap" checkbox makes the top canvas unmanaged and the
|
||||
bottom canvas managed.
|
||||
|
||||
The steps below assume an HVCanvas. Don't resize the window before
|
||||
starting the steps.
|
||||
|
||||
HVCanvas Steps
|
||||
--------------
|
||||
|
||||
Enable vertical scroll. The scroll should be at position 1 for both
|
||||
canvases. The bottom canvas should be scrolled up 10 pixels. The
|
||||
displayed info should change:
|
||||
-------------------------------------------
|
||||
| Unmanaged Scroll |
|
||||
| V: p: 1 r: 10 g: 3 H: 0 0 0 |
|
||||
| Client: <m> x <n> Virtual: <m> x <n> | ; for some <m> and <n>
|
||||
-------------------------------------------
|
||||
| Automanaged Scroll | ; <- actually, scrolled up
|
||||
| V: p: 0 r: 0 g: 0 H: 0 0 0 | ; all zero for managed
|
||||
| Client: <m> x <n'> Virtual: <m> x 200 | ; <n'> within 1 of <n>
|
||||
-------------------------------------------
|
||||
(You might not be able to read 200 in the lower right.)
|
||||
Make the window slightly wider. Make sure the <m> gets bigger to
|
||||
reflect the new width of the canvases.
|
||||
|
||||
Set the bottom canvas's vertical scroll to 0. The "Automanaged Scroll"
|
||||
should scroll back down into the original location.
|
||||
|
||||
Scroll the bottom canvas's vertical scroll to its maximum value (which
|
||||
is less than 10) You may see the bottom border close to the bottom
|
||||
edge of the canvas.
|
||||
|
||||
Adjust the top canvas's scroll, and watch the `p' value change each
|
||||
time. The maximum value is 10. Use the `page up/down' areas and make
|
||||
sure the `p' value changes by 3.
|
||||
|
||||
Turn off the vertical scroll. The bottom canvas's image should snap
|
||||
back to its original place. All the `V:' values in the top should
|
||||
return to zeros.
|
||||
|
||||
Perform the above steps for horizontal scrolling.
|
||||
|
||||
Turn on both vertical and horizontal scrolling. You should see the
|
||||
obvious combined effect. In particular, the bottom canvas's text
|
||||
should be scrolled both up and to the left.
|
||||
|
||||
Move all scrolls to 1 step beyond the smallest setting.
|
||||
|
||||
Make the frame larger. The top canvas's scrolls should still have 10
|
||||
steps, but the bottom canvas's scrolls will have fewer steps,
|
||||
reflecting the fact that less scrolling is needed to see the same
|
||||
virtual area.
|
||||
|
||||
Test the bottom canvas's scrolls to ensure that the maximum values of
|
||||
the scrolls show the edges of the canvas's virtual area.
|
||||
|
||||
Make the frame large enough to see the whole bottom canvas's virtual
|
||||
area. The scrollbars should become disabled in both directions.
|
||||
|
||||
Make the frame smaller again. The bottom canvas's scrolls should
|
||||
adjust correctly. Make the frame small enough that all scrollbars are
|
||||
active.
|
||||
|
||||
Move all scrolls to 1 step beyond the smallest setting.
|
||||
|
||||
Check "swap". Now, the top canvas is managed and the bottom canvas is
|
||||
unmanaged. But the top canvas's area is so small that its scrollbars
|
||||
are always disabled. (It may also be clipped to the tiny 10x10 box.)
|
||||
The bottom canvas's scrollbars should now act the the top ones used
|
||||
to: there are 20 steps in each direction and the `V:' and `H:' values
|
||||
change as the scrolls are moved.
|
||||
|
||||
Uncheck "swap". The scrollbars should all go back to the 1 position.
|
||||
The bottom canvas should be scrolled in the usual way.
|
||||
|
||||
Check "small". The top canvas should be unaffected. The bottom canvas
|
||||
should scroll back to 0,0, the scrollbars should be disabled, and a
|
||||
50x20 box should be drawn in the upper left (or the entire canvas is
|
||||
clipped to that box).
|
||||
|
||||
Check "swap". The bottom canvas should not be clipped.
|
||||
|
||||
Check "swap". The bottom canvas might be clipped again.
|
||||
|
||||
Uncheck "small". The bottom canvas should not be clipped.
|
||||
|
||||
Check "small" and disable vertical scrolls. The bottom canvas should
|
||||
be clipped horizontally or the boundary drawn at a small offset from
|
||||
the left.
|
||||
|
||||
Enable vertical and disable horizontal. The bottom canvas will be
|
||||
narrowly clipped of have a short boundary from the top.
|
||||
|
||||
HCanvas Steps
|
||||
--------------
|
||||
|
||||
A vertical scrollbar should not be visible at all.
|
||||
|
||||
Check both "Enable Vertical" and "Enable Horizontal". Verify that the
|
||||
canvases act exactly like an HVCanvas with vertical scrolls disabled.
|
||||
|
||||
VCanvas Steps
|
||||
--------------
|
||||
|
||||
Transpose the approve appropriately
|
||||
|
||||
Canvas Steps
|
||||
------------
|
||||
|
||||
No scrollbars, checking the enabler boxes has no effect.
|
||||
|
||||
Click "small" and make sure the bottom canvas is not clipped.
|
||||
|
||||
* Enable vertical scroll. Displayed info should change.
|
||||
|
|
|
@ -1331,9 +1331,9 @@
|
|||
(send f show #t))
|
||||
|
||||
(define (canvas-frame flags)
|
||||
(define f (make-object mred:frame% null "Canvas Test"))
|
||||
(define f (make-object mred:frame% null "Canvas Test" -1 -1 -1 250))
|
||||
(define p (make-object mred:vertical-panel% f))
|
||||
(define c% (class mred:canvas% (name p)
|
||||
(define c% (class mred:canvas% (name swapped-name p)
|
||||
(inherit clear draw-text draw-line set-clipping-region
|
||||
get-scroll-pos get-scroll-range get-scroll-page
|
||||
get-client-size get-virtual-size)
|
||||
|
@ -1355,7 +1355,7 @@
|
|||
(get-virtual-size w2 h2)
|
||||
; (set-clipping-region 0 0 (unbox w2) (unbox h2))
|
||||
(clear)
|
||||
(draw-text name 3 3)
|
||||
(draw-text (if (send ck-w get-value) swapped-name name) 3 3)
|
||||
; (draw-line 3 12 40 12)
|
||||
(draw-text s 3 15)
|
||||
(draw-text (format "client: ~s x ~s virtual: ~s x ~s"
|
||||
|
@ -1369,8 +1369,10 @@
|
|||
(lambda (e) (on-paint))])
|
||||
(sequence
|
||||
(super-init p -1 -1 -1 -1 flags))))
|
||||
(define c1 (make-object c% "Unmanaged scroll" p))
|
||||
(define c2 (make-object c% "Automanaged scroll" p))
|
||||
(define un-name "Unmanaged scroll")
|
||||
(define m-name "Automanaged scroll")
|
||||
(define c1 (make-object c% un-name m-name p))
|
||||
(define c2 (make-object c% m-name un-name p))
|
||||
(define (reset-scrolls for-small?)
|
||||
(let* ([h? (send ck-h get-value)]
|
||||
[v? (send ck-v get-value)]
|
||||
|
@ -1387,11 +1389,17 @@
|
|||
; Otherwise, we have to specifically refresh the unmanaged canvas
|
||||
(send (if swap? c2 c1) refresh))))
|
||||
(define p2 (make-object mred:horizontal-panel% p))
|
||||
(define jumk (send p2 stretchable-in-y #f))
|
||||
(define junk (send p2 stretchable-in-y #f))
|
||||
(define ck-v (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #f)) "Vertical Scroll"))
|
||||
(define ck-h (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #f)) "Horizontal Scroll"))
|
||||
(define ck-s (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #t)) "Small"))
|
||||
(define ck-w (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #f)) "Swap"))
|
||||
(define ip (make-object mred:horizontal-panel% p))
|
||||
(send ip stretchable-in-y #f)
|
||||
(make-object mred:button% ip
|
||||
(lambda (b e)
|
||||
(send (send (mred:edit-file (local-path "canvas-steps.txt")) get-edit) lock #t))
|
||||
"Get Instructions")
|
||||
(send c1 set-vsize 10 10)
|
||||
(send c2 set-vsize 500 200)
|
||||
(send f show #t))
|
||||
|
|
Loading…
Reference in New Issue
Block a user