ui.gadgets.plot: Keyboard controls
parent
52085a4e49
commit
28abbfc6c2
|
@ -62,3 +62,76 @@ M: plot draw-slate ( plot -- plot )
|
||||||
|
|
||||||
: add-function ( plot function -- plot )
|
: add-function ( plot function -- plot )
|
||||||
over functions>> swap suffix >>functions ;
|
over functions>> swap suffix >>functions ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
: x-span ( plot -- span ) [ x-max>> ] [ x-min>> ] bi - ;
|
||||||
|
: y-span ( plot -- span ) [ y-max>> ] [ y-min>> ] bi - ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
USING: ui.gestures ui.gadgets ;
|
||||||
|
|
||||||
|
: left ( plot -- plot )
|
||||||
|
dup [ x-min>> ] [ x-span 1/10 * ] bi - >>x-min
|
||||||
|
dup [ x-max>> ] [ x-span 1/10 * ] bi - >>x-max
|
||||||
|
dup relayout-1 ;
|
||||||
|
|
||||||
|
: right ( plot -- plot )
|
||||||
|
dup [ x-min>> ] [ x-span 1/10 * ] bi + >>x-min
|
||||||
|
dup [ x-max>> ] [ x-span 1/10 * ] bi + >>x-max
|
||||||
|
dup relayout-1 ;
|
||||||
|
|
||||||
|
: down ( plot -- plot )
|
||||||
|
dup [ y-min>> ] [ y-span 1/10 * ] bi - >>y-min
|
||||||
|
dup [ y-max>> ] [ y-span 1/10 * ] bi - >>y-max
|
||||||
|
dup relayout-1 ;
|
||||||
|
|
||||||
|
: up ( plot -- plot )
|
||||||
|
dup [ y-min>> ] [ y-span 1/10 * ] bi + >>y-min
|
||||||
|
dup [ y-max>> ] [ y-span 1/10 * ] bi + >>y-max
|
||||||
|
dup relayout-1 ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
: zoom-in-horizontal ( plot -- plot )
|
||||||
|
dup [ x-min>> ] [ x-span 1/10 * ] bi + >>x-min
|
||||||
|
dup [ x-max>> ] [ x-span 1/10 * ] bi - >>x-max ;
|
||||||
|
|
||||||
|
: zoom-in-vertical ( plot -- plot )
|
||||||
|
dup [ y-min>> ] [ y-span 1/10 * ] bi + >>y-min
|
||||||
|
dup [ y-max>> ] [ y-span 1/10 * ] bi - >>y-max ;
|
||||||
|
|
||||||
|
: zoom-in ( plot -- plot )
|
||||||
|
zoom-in-horizontal
|
||||||
|
zoom-in-vertical
|
||||||
|
dup relayout-1 ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
: zoom-out-horizontal ( plot -- plot )
|
||||||
|
dup [ x-min>> ] [ x-span 1/10 * ] bi - >>x-min
|
||||||
|
dup [ x-max>> ] [ x-span 1/10 * ] bi + >>x-max ;
|
||||||
|
|
||||||
|
: zoom-out-vertical ( plot -- plot )
|
||||||
|
dup [ y-min>> ] [ y-span 1/10 * ] bi - >>y-min
|
||||||
|
dup [ y-max>> ] [ y-span 1/10 * ] bi + >>y-max ;
|
||||||
|
|
||||||
|
: zoom-out ( plot -- plot )
|
||||||
|
zoom-out-horizontal
|
||||||
|
zoom-out-vertical
|
||||||
|
dup relayout-1 ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
plot
|
||||||
|
H{
|
||||||
|
{ T{ mouse-enter } [ request-focus ] }
|
||||||
|
{ T{ key-down f f "LEFT" } [ left drop ] }
|
||||||
|
{ T{ key-down f f "RIGHT" } [ right drop ] }
|
||||||
|
{ T{ key-down f f "DOWN" } [ down drop ] }
|
||||||
|
{ T{ key-down f f "UP" } [ up drop ] }
|
||||||
|
{ T{ key-down f f "a" } [ zoom-in drop ] }
|
||||||
|
{ T{ key-down f f "z" } [ zoom-out drop ] }
|
||||||
|
}
|
||||||
|
set-gestures
|
Loading…
Reference in New Issue