… | |
… | |
953 | $self->{view_x} = $x; |
953 | $self->{view_x} = $x; |
954 | $self->{view_y} = $y; |
954 | $self->{view_y} = $y; |
955 | |
955 | |
956 | $self->emit (changed => $x, $y); |
956 | $self->emit (changed => $x, $y); |
957 | $self->update; |
957 | $self->update; |
|
|
958 | } |
|
|
959 | } |
|
|
960 | |
|
|
961 | sub set_center { |
|
|
962 | my ($self, $x, $y) = @_; |
|
|
963 | |
|
|
964 | $self->set_offset ($x - $self->{w} * .5, $y - $self->{h} * .5); |
|
|
965 | } |
|
|
966 | |
|
|
967 | sub make_visible { |
|
|
968 | my ($self, $x, $y, $border) = @_; |
|
|
969 | |
|
|
970 | if ( $x < $self->{view_x} + $self->{w} * $border |
|
|
971 | || $x > $self->{view_x} + $self->{w} * (1 - $border) |
|
|
972 | || $y < $self->{view_y} + $self->{h} * $border |
|
|
973 | || $y > $self->{view_y} + $self->{h} * (1 - $border) |
|
|
974 | ) { |
|
|
975 | $self->set_center ($x, $y); |
958 | } |
976 | } |
959 | } |
977 | } |
960 | |
978 | |
961 | # hmm, this does not work for topleft of $self... but we should not ask for that |
979 | # hmm, this does not work for topleft of $self... but we should not ask for that |
962 | sub coord2local { |
980 | sub coord2local { |
… | |
… | |
1074 | sub add { |
1092 | sub add { |
1075 | my ($self, $widget) = @_; |
1093 | my ($self, $widget) = @_; |
1076 | |
1094 | |
1077 | $self->{vp}->add ($self->{child} = $widget); |
1095 | $self->{vp}->add ($self->{child} = $widget); |
1078 | } |
1096 | } |
|
|
1097 | |
|
|
1098 | sub set_offset { shift->{vp}->set_offset (@_) } |
|
|
1099 | sub set_center { shift->{vp}->set_center (@_) } |
|
|
1100 | sub make_visible { shift->{vp}->make_visible (@_) } |
1079 | |
1101 | |
1080 | sub update_slider { |
1102 | sub update_slider { |
1081 | my ($self) = @_; |
1103 | my ($self) = @_; |
1082 | |
1104 | |
1083 | my $child = ($self->{vp} or return)->child; |
1105 | my $child = ($self->{vp} or return)->child; |