Skip to content

Commit

Permalink
Start implementation of middle scrollbutton support for zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
devel-chm committed Oct 3, 2016
1 parent 3efdac2 commit 257c73a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Graphics/TriD/TriD/ButtonControl.pm
Expand Up @@ -74,7 +74,7 @@ sub ButtonRelease{
print "ButtonRelease @_\n" if $PDL::Graphics::TriD::verbose;
}

=head2 ButtonPressed
=head2 ButtonPress
=for ref
Expand Down
34 changes: 34 additions & 0 deletions Graphics/TriD/TriD/ScrollButtonScaler.pm
@@ -0,0 +1,34 @@
######################################################################
######################################################################
## ScrollButtonController -- 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::ScrollButtonController;
use base qw/PDL::Graphics::TriD::ButtonControl/;
use fields qw/Dist Zoom/;

sub new {
my($type,$win,$dist,$zoom) = @_;

my $this = $type->SUPER::new($win);

$this->{Dist} = $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;
}

sub ButtonPress{
my ($this,$x,$y) = @_;

print "ButtonPress @_ ",ref($this->{Win}),"\n" if $PDL::Graphics::TriD::verbose;
}

1;
10 changes: 4 additions & 6 deletions Graphics/TriD/TriD/Window.pm
Expand Up @@ -85,12 +85,10 @@ sub new_viewport {

$vp->transformer($cont);
if(ref($ev)){
$ev->set_button(0,new PDL::Graphics::TriD::ArcCone(
$vp, 0,
$cont->{WRotation}));
$ev->set_button(2,new PDL::Graphics::TriD::SimpleScaler(
$vp,
\$cont->{CDistance}));
$ev->set_button(0,new PDL::Graphics::TriD::ArcCone( $vp, 0, $cont->{WRotation}));
$ev->set_button(2,new PDL::Graphics::TriD::SimpleScaler( $vp, \$cont->{CDistance}));
$ev->set_button(3,new PDL::Graphics::TriD::ScrollButtonScaler();
$ev->set_button(4,new PDL::Graphics::TriD::ScrollButtonScaler();

$vp->eventhandler($ev);
}
Expand Down

0 comments on commit 257c73a

Please sign in to comment.