[REBOL] Dynamic scroller step adjustment
From: gerardcote::sympatico::ca at: 25-Feb-2004 11:05
Hello list,
Can somebody help me to find how to dynamically adjust the horizontal and vertical steps
(here xs and ys) of scrollers (or sliders)
so they fit themselves with the real length contents of the area (i.e. a function of
the real number of lines and number of columns
contained inside the area to be scrolled - or even some number of pixels but since we
can have proportional fonts here this will
require additional calculations).
As you'll find when trying the following demo, when the number of lines is small, may
be 10 lines or so, the -1 part of the ys
vertical scroll seems to work fine since I can display all the data but when the number
of lines goes up to 100 or so lines, then I
have to change the value -1 to -15 to let the user see all the data enclosed and then
generally when the end of data is crossed the
scroller doesn't really indicate visually that there is no more data to come since the
bar is not placed at the end either..
So is there any mean to keep this value dynamically dependant of the real contents of
the area or not ? and if yes how to proceed ?
I suppose I should go and work within the System/view object to adapt the scroll step
after the content of the area is known but
where and how do I do this if necessary ? ...
Here is the small script I use to experiment scroll bars:
win: layout [
across
a: area 300x100 edge [
size: 2x2
] para [
scroll: 0x0
]
s: scroller 15x100 [
ys: -1 * (to-integer (s/data * 100))
a/para/scroll: make pair! reduce [ 0 ys ]
show a
]
return
s2: scroller 300x15 [
xs: -1 * (to-integer (s2/data * 100))
a/para/scroll: make pair! reduce [ xs 0 ]
show a
]
]
ys:0
a/text: copy {}
for Ligne 1 100 1 [
append a/text reduce ["Ligne " Ligne " : "]
for Col 1 20 1 [
append a/text reduce [ Col " "]
]
append a/text reduce [ "^/" ]
]
view win
Thanks for any cue,
Gerard