… | |
… | |
986 | } |
986 | } |
987 | |
987 | |
988 | sub set_offset { |
988 | sub set_offset { |
989 | my ($self, $x, $y) = @_; |
989 | my ($self, $x, $y) = @_; |
990 | |
990 | |
991 | $self->{view_x} = max 0, min $self->child->{w} - $self->{w}, int $x; |
991 | my $x = max 0, min $self->child->{w} - $self->{w}, int $x; |
992 | $self->{view_y} = max 0, min $self->child->{h} - $self->{h}, int $y; |
992 | my $y = max 0, min $self->child->{h} - $self->{h}, int $y; |
993 | |
993 | |
994 | $self->emit (changed => $self->{view_x}, $self->{view_y}); |
994 | if ($x != $self->{view_x} or $y != $self->{view_y}) { |
|
|
995 | $self->{view_x} = $x; |
|
|
996 | $self->{view_y} = $y; |
|
|
997 | |
|
|
998 | $self->emit (changed => $x, $y); |
995 | $self->update; |
999 | $self->update; |
|
|
1000 | } |
996 | } |
1001 | } |
997 | |
1002 | |
998 | # hmm, this does not work for topleft of $self... but we should not ask for that |
1003 | # hmm, this does not work for topleft of $self... but we should not ask for that |
999 | sub coord2local { |
1004 | sub coord2local { |
1000 | my ($self, $x, $y) = @_; |
1005 | my ($self, $x, $y) = @_; |