|
Class: Slider
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--Scroller
|
+--Slider
|
+--FractionalWidgetView
|
+--HorizontalSlider
- Package:
- stx:libwidg2
- Category:
- Views-Interactors
- Version:
- rev:
1.42
date: 2017/12/20 20:13:45
- user: cg
- file: Slider.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
- Author:
- Claus Gittinger
this class implements sliders - which are simply scrollers
with a constant thumbHeight. For details on actionBlocks and
MVC operation, see the documentation in Scroller.
Compatibility-VW
-
beHorizontal
-
ST-80 compatibility: make the slider a horizontalSlider
-
beVertical
-
ST-80 compatibility: make the slider a verticalSlider
accessing
-
sliderHeight: numPixels
-
-
thumbHeight
-
redefined since a slider has no height - just origin
event handling
-
buttonPress: butt x: x y: y
-
-
keyPress: key x: x y: y
-
Modified (format): / 16-11-2016 / 23:13:56 / cg
forced scroll
-
pageDown
-
fallback to scroll-stepping (same as kbd-right/down)
-
pageUp
-
fallback to scroll-stepping (same as kbd-right/down)
initialization
-
initStyle
-
initialize style specifics
-
initialize
-
private
-
absFromPercent: percent
-
given a percentage, compute number of pixels
-
computeThumbFrame
-
redefined, since the thumb-height stays constant
-
percentFromAbs: absValue
-
given a number of pixels, compute percentage
a slider with action block (ST/X style):
|top s|
top := StandardSystemView new extent:200@200.
s := Slider in:top.
s origin:(0.0@0.0) corner:(15@1.0).
s scrollAction:[:percent | Transcript show:'moved to: '; showCR:percent asFloat].
top open
|
same, horizontal:
|top s|
top := StandardSystemView new extent:200@200.
s := HorizontalSlider in:top.
s origin:(0.0@0.0) corner:(1.0@15).
s scrollAction:[:percent | Transcript show:'moved to: '; showCR:percent asFloat].
top open
|
with a range other than the default:
|top s|
top := StandardSystemView new extent:200@200.
s := Slider in:top.
s origin:(0.0@0.0) corner:(20@1.0).
s scrollAction:[:percent | Transcript show:'moved to: '; showCR:percent asFloat].
s start:-50 stop:50.
top open
|
using a model (ST-80 style):
(see the changing value in the inspector)
|top s m|
m := 0 asValue.
m inspect.
top := StandardSystemView new extent:200@200.
s := Slider in:top.
s origin:(0.0@0.0) corner:(20@1.0).
s model:m.
top open
|
reacting to changes from the model:
(look at and/or change value using 'self value:' in the inspector).
|top s m|
m := 0 asValue.
m inspect.
top := StandardSystemView new extent:200@200.
s := Slider in:top.
s origin:(0.0@0.0) corner:(20@1.0).
s model:m.
top open
|
using a different changeSelector:
|top s1 s2 m|
m := Plug new.
m respondTo:#value1: with:[:v | Transcript show:'scroller 1 moved to: '; showCR:v].
m respondTo:#value2: with:[:v | Transcript show:'scroller 2 moved to: '; showCR:v].
top := StandardSystemView new extent:200@200.
s1 := Slider in:top.
s1 origin:(0.0@0.0) corner:(20@1.0).
s1 thumbHeight:10. 'percent'.
s1 model:m; change:#value1:.
s2 := Slider in:top.
s2 origin:(30@0.0) corner:(50@1.0).
s2 thumbHeight:10. 'percent'.
s2 model:m; change:#value2:.
top open
|
another example:
|top redVal greenVal blueVal
colorVal upd s1 s2 s3 l|
redVal := 0 asValue.
greenVal := 0 asValue.
blueVal := 0 asValue.
upd := [colorVal value:(Color red:redVal value
green:greenVal value
blue:blueVal value)].
colorVal := (Color red:0 green:0 blue:0) asValue.
colorVal onChangeSend:#value to:[l backgroundColor:colorVal value].
redVal onChangeSend:#value to:upd.
greenVal onChangeSend:#value to:upd.
blueVal onChangeSend:#value to:upd.
top := StandardSystemView new extent:200@200.
top label:'Color mixer'.
s1 := Slider in:top.
s1 origin:(0.0@0.0) corner:(20@1.0).
s1 thumbHeight:10. 'percent'.
s1 model:redVal.
s2 := Slider in:top.
s2 origin:(30@0.0) corner:(50@1.0).
s2 thumbHeight:10. 'percent'.
s2 model:greenVal.
s3 := Slider in:top.
s3 origin:(60@0.0) corner:(80@1.0).
s3 thumbHeight:10. 'percent'.
s3 model:blueVal.
l := Label in:top.
l origin:90@0.0 corner:1.0@1.0.
l backgroundColor:Color black.
top open
|
the same setup, using action blocks:
|top red green blue
colorVal upd s1 s2 s3 labelModel l|
red := green := blue := 0.
top := StandardSystemView new extent:200@200.
top label:'Color mixer'.
s1 := Slider in:top.
s1 origin:(0.0@0.0) corner:(20@1.0).
s1 thumbHeight:10. 'percent'.
s1 action:[:percent | red := percent.
l backgroundColor:(Color red:red green:green blue:blue)].
s2 := Slider in:top.
s2 origin:(30@0.0) corner:(50@1.0).
s2 thumbHeight:10. 'percent'.
s2 action:[:percent | green := percent.
l backgroundColor:(Color red:red green:green blue:blue)].
s3 := Slider in:top.
s3 origin:(60@0.0) corner:(80@1.0).
s3 thumbHeight:10. 'percent'.
s3 action:[:percent | blue := percent.
l backgroundColor:(Color red:red green:green blue:blue)].
l := Label in:top.
l origin:90@0.0 corner:1.0@1.0.
l backgroundColor:Color black.
top open
|
|