/view slider data (size - 4) ?
[1/5] from: rchristiansen::pop::isdfa::sei-it::com at: 1-Aug-2000 14:41
When I make a slider, how come the slider /data value reaches a maximum
of four integers less than the size of the slider?
For example, to return a maximum /data value of 255, use the following...
REBOL []
face-one: layout [
s: slider 10x259 [s/color: 0.0.0 + s/data show s print s/data]
]
view/title face-one "face one"
[2/5] from: jkinraid:clear at: 2-Aug-2000 14:57
[RChristiansen--pop--isdfa--sei-it--com] wrote:
> When I make a slider, how come the slider /data value reaches a maximum
> of four integers less than the size of the slider?
<<quoted lines omitted: 4>>
> ]
> view/title face-one "face one"
The problem is because of the edges on the slider. Because they use up
4 pixels of space, you end up with a maximum value of the slider width -
4. So if you did this -
face-one: layout [
s: slider 10x259 with [edge/size: 4x4]
[s/color: 0.0.0 + s/data show s print s/data]
]
view/title face-one "face one"
You can use these functions to get/set the position of a slider -
get-slider-position: func [
"Returns the sliders position, a value between 0.0 and 1.0"
slider [object!]
/scale amount [number!]
"Scales the position by amount, and converts to an integer"
/local result way
] [
way: not zero? slider/pane/way/1
result: (slider/data - 1) / pick
(slider/size - (2 * slider/edge/size) - slider/pane/way) way
if scale [result: to-integer result * amount]
result
]
set-slider-position: func [
slider [object!]
position [number!]
/scale amount [number!]
"Scale the position down to a number between 0.0 and 1.0"
/local way offset
] [
if scale [position: position / amount]
way: not zero? slider/pane/way/1
offset: to-integer (position * pick
(slider/size - (2 * slider/edge/size) - slider/pane/way) way) + 1
slider/data: offset
slider/pane/offset: slider/pane/way * (to-integer position * pick
(slider/size - slider/pane/size - (2 * slider/edge/size)) way)
]
So now the code becomes -
face-one: layout [
s: slider 10x300 [
s/color: 0.0.0 + get-slider-position/scale s 255
show s
print s/color
]
]
view/title face-one "face one"
Julian Kinraid
[3/5] from: g:santilli:tiscalinet:it at: 2-Aug-2000 19:06
Hello [RChristiansen--pop--isdfa--sei-it--com]!
On 01-Ago-00, you wrote:
R> When I make a slider, how come the slider /data value reaches
R> a maximum of four integers less than the size of the slider?
That's a bug in the default slider style. For a better one (IMHO :)
download http://web.tiscalinet.it/rebol/scroller-styles.r.
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[4/5] from: rchristiansen:pop:isdfa:sei-it at: 2-Aug-2000 13:33
Do you have a usage guide for the scrollers?
-Ryan
[5/5] from: g:santilli:tiscalinet:it at: 3-Aug-2000 19:12
Hello [RChristiansen--pop--isdfa--sei-it--com]!
On 02-Ago-00, you wrote:
R> Do you have a usage guide for the scrollers?
Not yet, but the slider is 99% compatible with the predefined one.
Anyway, as a short summary:
slider ; goes from 1 to its size (like predefined)
slider 256 ; from 1 to 256
slider minimum 0 maximum 255 ; from 0 to 255
The other two styles (scroller and pixmap-scroller) are more
general (slider is based on scroller); the pixmap-scroller allows
using images for the arrows, the knob and the background.
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted