… | |
… | |
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; |
… | |
… | |
3746 | buttonbar => (new CFPlus::UI::Buttonbar), |
3768 | buttonbar => (new CFPlus::UI::Buttonbar), |
3747 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3769 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3748 | # filter => # will be put between multiplexer and $self |
3770 | # filter => # will be put between multiplexer and $self |
3749 | @_, |
3771 | @_, |
3750 | ); |
3772 | ); |
3751 | |
3773 | |
3752 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
3774 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
3753 | $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer}); |
3775 | $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer}); |
3754 | |
3776 | |
3755 | { |
3777 | { |
3756 | Scalar::Util::weaken (my $wself = $self); |
3778 | Scalar::Util::weaken (my $wself = $self); |
… | |
… | |
3797 | |
3819 | |
3798 | sub remove { |
3820 | sub remove { |
3799 | my ($self, @widgets) = @_; |
3821 | my ($self, @widgets) = @_; |
3800 | |
3822 | |
3801 | $self->{multiplexer}->remove (@widgets) |
3823 | $self->{multiplexer}->remove (@widgets) |
|
|
3824 | } |
|
|
3825 | |
|
|
3826 | sub pages { |
|
|
3827 | my ($self) = @_; |
|
|
3828 | $self->{multiplexer}->children |
3802 | } |
3829 | } |
3803 | |
3830 | |
3804 | sub add_tab { |
3831 | sub add_tab { |
3805 | my ($self, $title, $widget, $tooltip) = @_; |
3832 | my ($self, $title, $widget, $tooltip) = @_; |
3806 | |
3833 | |