1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
## ScrollButtonScaler -- this is the module that enables support
## for middle button scrollwheels to zoom in and out of the display
## window. Scrolling forward zooms in, while scrolling backwards zooms
## out.
package PDL::Graphics::TriD::ScrollButtonScaler;
use base qw/PDL::Graphics::TriD::ButtonControl/;
use fields qw/DistRef Zoom/;
sub new {
my($type,$win,$dist,$zoom) = @_;
my $this = $type->SUPER::new($win);
$this->{DistRef} = $dist;
$this->{Zoom} = $zoom; # multiplier for zooming
# >1 zooms out, <1 zooms in
return $this;
}
sub ButtonRelease{
my ($this,$x,$y) = @_;
print "ButtonRelease @_\n" if $PDL::Graphics::TriD::verbose;
${$this->{DistRef}} *= $this->{Zoom};
1;
}
sub ButtonPress{
my ($this,$x,$y) = @_;
print "ButtonPress @_ ",ref($this->{Win}),"\n" if $PDL::Graphics::TriD::verbose;
}
1;
|