|
Class: Slider
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--Scroller
|
+--Slider
|
+--FractionalWidgetView
|
+--HorizontalSlider
- Package:
- stx:libwidg2
- Category:
- Views-Interactors
- Version:
- rev:
1.44
date: 2021/03/14 14:30:32
- user: cg
- file: Slider.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
this class implements sliders - which are simply scrollers
with a constant thumbHeight. For details on actionBlocks and
MVC operation, see the documentation in Scroller.
copyrightCOPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
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
-
(comment from inherited method)
button was pressed - if above thumb, page up; if below thumb, page down;
otherwise start scrolling.
If either shift is pressed, or the 'scrollerMiddleButtonJump' styleSheet
value is true and its the middle button, do a jump to the clicked position.
-
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
-
(comment from inherited method)
initialize - setup instvars from defaults
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
|
|