Gtk3-ImageView
view release on metacpan or search on metacpan
lib/Gtk3/ImageView.pm view on Meta::CPAN
if ( $tool eq 'dragger' ) {
$tool = Gtk3::ImageView::Tool::Dragger->new($self);
}
elsif ( $tool eq 'selector' ) {
$tool = Gtk3::ImageView::Tool::Selector->new($self);
}
else {
croak 'invalid set_tool call';
}
}
$self->set( 'tool', $tool );
return;
}
sub get_tool {
my ($self) = @_;
return $self->get('tool');
}
sub set_selection {
my ( $self, $selection ) = @_;
my $pixbuf_size = $self->get_pixbuf_size;
if ( not defined $pixbuf_size ) { return }
if ( $selection->{x} < 0 ) {
$selection->{width} += $selection->{x};
$selection->{x} = 0;
}
if ( $selection->{y} < 0 ) {
$selection->{height} += $selection->{y};
$selection->{y} = 0;
}
if ( $selection->{x} + $selection->{width} > $pixbuf_size->{width} ) {
$selection->{width} = $pixbuf_size->{width} - $selection->{x};
}
if ( $selection->{y} + $selection->{height} > $pixbuf_size->{height} ) {
$selection->{height} = $pixbuf_size->{height} - $selection->{y};
}
$self->set( 'selection-float', $selection );
return;
}
sub get_selection {
my ($self) = @_;
return $self->get('selection');
}
sub set_resolution_ratio {
my ( $self, $ratio ) = @_;
$self->set( 'resolution-ratio', $ratio );
if ( $self->get_zoom_to_fit ) {
$self->zoom_to_box( $self->get_pixbuf_size );
}
return;
}
sub get_resolution_ratio {
my ($self) = @_;
return $self->get('resolution-ratio');
}
sub update_cursor {
my ( $self, $x, $y ) = @_;
my $pixbuf_size = $self->get_pixbuf_size;
if ( not defined $pixbuf_size ) { return }
my $win = $self->get_window;
my $cursor = $self->get_tool->cursor_at_point( $x, $y );
if ( defined $cursor ) {
$win->set_cursor($cursor);
}
return;
}
sub set_interpolation {
my ( $self, $interpolation ) = @_;
$self->set( 'interpolation', $interpolation );
return;
}
sub get_interpolation {
my ($self) = @_;
return $self->get('interpolation');
}
1;
__END__
=encoding utf8
=head1 NAME
Gtk3::ImageView - Image viewer widget for Gtk3
=head1 VERSION
9
=head1 SYNOPSIS
use Gtk3::ImageView;
Gtk3->init;
$window = Gtk3::Window->new();
$view = Gtk3::ImageView->new;
$view->set_pixbuf($pixbuf, TRUE);
$window->add($view);
$window->show_all;
=head1 DESCRIPTION
The Gtk3::ImageView widget allows the user to zoom, pan and select the specified
image and provides hooks to allow additional tools, e.g. painter, to be created
and used.
Gtk3::ImageView is a Gtk3 port of L<Gtk2::ImageView|Gtk2::ImageView>.
To discuss Gtk3::ImageView or gtk3-perl, ask questions and flame/praise the
authors, join gtk-perl-list@gnome.org at lists.gnome.org.
( run in 2.180 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )