… | |
… | |
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 | $self->{view_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 | $self->{view_y} = max 0, min $self->child->{h} - $self->{h}, int $y; |
993 | |
993 | |
|
|
994 | $self->emit (changed => $self->{view_x}, $self->{view_y}); |
994 | $self->update; |
995 | $self->update; |
995 | } |
996 | } |
996 | |
997 | |
997 | # hmm, this does not work for topleft of $self... but we should not ask for that |
998 | # hmm, this does not work for topleft of $self... but we should not ask for that |
998 | sub coord2local { |
999 | sub coord2local { |
… | |
… | |
1074 | row_expand => [1, 0], |
1075 | row_expand => [1, 0], |
1075 | %arg, |
1076 | %arg, |
1076 | ); |
1077 | ); |
1077 | |
1078 | |
1078 | $self->{vp} = new CFPlus::UI::ViewPort |
1079 | $self->{vp} = new CFPlus::UI::ViewPort |
1079 | expand => 1, |
1080 | expand => 1, |
1080 | scroll_x => $self->{scroll_x}, |
1081 | scroll_x => $self->{scroll_x}, |
1081 | scroll_y => $self->{scroll_y}, |
1082 | scroll_y => $self->{scroll_y}, |
|
|
1083 | on_changed => sub { |
|
|
1084 | my ($vp, $x, $y) = @_; |
|
|
1085 | $vp->{parent}{hslider}->set_value ($x); |
|
|
1086 | $vp->{parent}{vslider}->set_value ($y); |
|
|
1087 | |
|
|
1088 | 0 |
|
|
1089 | }, |
1082 | ; |
1090 | ; |
1083 | |
1091 | |
1084 | $self->SUPER::add (0, 0, $self->{vp}); |
1092 | $self->SUPER::add (0, 0, $self->{vp}); |
1085 | |
1093 | |
1086 | $self->add ($child) if $child; |
1094 | $self->add ($child) if $child; |
… | |
… | |
1140 | sub invoke_button_down { |
1148 | sub invoke_button_down { |
1141 | my ($self, $ev, $x, $y) = @_; |
1149 | my ($self, $ev, $x, $y) = @_; |
1142 | |
1150 | |
1143 | if ($ev->{button} == 2) { |
1151 | if ($ev->{button} == 2) { |
1144 | $self->grab_focus; |
1152 | $self->grab_focus; |
|
|
1153 | |
|
|
1154 | my $ox = $self->{vp}{view_x} + $ev->{x}; |
|
|
1155 | my $oy = $self->{vp}{view_y} + $ev->{y}; |
1145 | |
1156 | |
1146 | $self->{motion} = sub { |
1157 | $self->{motion} = sub { |
1147 | my ($ev, $x, $y) = @_; |
1158 | my ($ev, $x, $y) = @_; |
1148 | |
1159 | |
1149 | $self->{vp}->set_offset ( |
1160 | $self->{vp}->set_offset ($ox - $ev->{x}, $oy - $ev->{y}); |
1150 | $self->{vp}{view_x} - $ev->{xrel}, |
1161 | $self->update; |
1151 | $self->{vp}{view_y} - $ev->{yrel}, |
|
|
1152 | ); |
|
|
1153 | }; |
1162 | }; |
1154 | |
1163 | |
1155 | return 1; |
1164 | return 1; |
1156 | } |
1165 | } |
1157 | |
1166 | |