… | |
… | |
293 | |
293 | |
294 | $self->emit (visibility_change => 1); |
294 | $self->emit (visibility_change => 1); |
295 | |
295 | |
296 | $self->realloc if !exists $self->{req_w}; |
296 | $self->realloc if !exists $self->{req_w}; |
297 | |
297 | |
298 | $_->set_visible for $self->children; |
298 | $_->set_visible for $self->visible_children; |
299 | } |
299 | } |
300 | |
300 | |
301 | sub set_invisible { |
301 | sub set_invisible { |
302 | my ($self) = @_; |
302 | my ($self) = @_; |
303 | |
303 | |
… | |
… | |
1361 | my ($class, %arg) = @_; |
1361 | my ($class, %arg) = @_; |
1362 | |
1362 | |
1363 | my $self = $class->SUPER::new ( |
1363 | my $self = $class->SUPER::new ( |
1364 | bg => [1, 1, 1, 1], |
1364 | bg => [1, 1, 1, 1], |
1365 | border_bg => [1, 1, 1, 1], |
1365 | border_bg => [1, 1, 1, 1], |
1366 | border => 1, |
1366 | border => 0.8, |
1367 | can_events => 1, |
1367 | can_events => 1, |
1368 | min_w => 64, |
1368 | min_w => 64, |
1369 | min_h => 32, |
1369 | min_h => 32, |
1370 | %arg, |
1370 | %arg, |
1371 | ); |
1371 | ); |
… | |
… | |
3933 | |
3933 | |
3934 | my $self = $class->SUPER::new ( |
3934 | my $self = $class->SUPER::new ( |
3935 | @_, |
3935 | @_, |
3936 | ); |
3936 | ); |
3937 | |
3937 | |
3938 | $self->{current} = $self->{children}[0] |
3938 | $self->set_current_page (0); |
3939 | if @{ $self->{children} }; |
|
|
3940 | |
3939 | |
3941 | $self |
3940 | $self |
3942 | } |
3941 | } |
3943 | |
3942 | |
3944 | sub add { |
3943 | sub add { |
3945 | my ($self, @widgets) = @_; |
3944 | my ($self, @widgets) = @_; |
3946 | |
3945 | |
3947 | $self->SUPER::add (@widgets); |
3946 | $self->SUPER::add (@widgets); |
3948 | |
3947 | |
3949 | $self->{current} = $self->{children}[0] |
3948 | $self->set_current_page (0) |
3950 | if @{ $self->{children} }; |
3949 | unless @widgets == @{ $self->{children} }; |
3951 | } |
3950 | } |
3952 | |
3951 | |
3953 | sub get_current_page { |
3952 | sub get_current_page { |
3954 | my ($self) = @_; |
3953 | my ($self) = @_; |
3955 | |
3954 | |
… | |
… | |
3961 | |
3960 | |
3962 | my $widget = ref $page_or_widget |
3961 | my $widget = ref $page_or_widget |
3963 | ? $page_or_widget |
3962 | ? $page_or_widget |
3964 | : $self->{children}[$page_or_widget]; |
3963 | : $self->{children}[$page_or_widget]; |
3965 | |
3964 | |
|
|
3965 | $self->{current}->set_invisible if $self->{current} && $self->{visible}; |
|
|
3966 | |
3966 | $self->{current} = $widget; |
3967 | if (($self->{current} = $widget)) { |
|
|
3968 | $self->{current}->set_visible if $self->{current} && $self->{visible}; |
3967 | $self->{current}->configure (0, 0, $self->{w}, $self->{h}); |
3969 | $self->{current}->configure (0, 0, $self->{w}, $self->{h}); |
3968 | |
3970 | |
3969 | $self->emit (page_changed => $self->{current}); |
3971 | $self->emit (page_changed => $self->{current}); |
|
|
3972 | } |
3970 | |
3973 | |
3971 | $self->realloc; |
3974 | $self->realloc; |
3972 | } |
3975 | } |
3973 | |
3976 | |
3974 | sub visible_children { |
3977 | sub visible_children { |
3975 | $_[0]{current} |
3978 | $_[0]{current} || () |
3976 | } |
3979 | } |
3977 | |
3980 | |
3978 | sub size_request { |
3981 | sub size_request { |
3979 | my ($self) = @_; |
3982 | my ($self) = @_; |
3980 | |
3983 | |
|
|
3984 | $self->{current} |
3981 | $self->{current}->size_request |
3985 | ? $self->{current}->size_request |
|
|
3986 | : (0, 0) |
3982 | } |
3987 | } |
3983 | |
3988 | |
3984 | sub invoke_size_allocate { |
3989 | sub invoke_size_allocate { |
3985 | my ($self, $w, $h) = @_; |
3990 | my ($self, $w, $h) = @_; |
3986 | |
3991 | |
3987 | $self->{current}->configure (0, 0, $w, $h); |
3992 | $self->{current}->configure (0, 0, $w, $h) |
|
|
3993 | if $self->{current}; |
3988 | |
3994 | |
3989 | 1 |
3995 | 1 |
3990 | } |
3996 | } |
3991 | |
3997 | |
3992 | sub _draw { |
3998 | sub _draw { |
3993 | my ($self) = @_; |
3999 | my ($self) = @_; |
3994 | |
4000 | |
3995 | $self->{current}->draw; |
4001 | $self->{current}->draw |
|
|
4002 | if $self->{current}; |
3996 | } |
4003 | } |
3997 | |
4004 | |
3998 | ############################################################################# |
4005 | ############################################################################# |
3999 | |
4006 | |
4000 | package DC::UI::Notebook; |
4007 | package DC::UI::Notebook; |
… | |
… | |
4210 | $self |
4217 | $self |
4211 | } |
4218 | } |
4212 | |
4219 | |
4213 | sub reorder { |
4220 | sub reorder { |
4214 | my ($self) = @_; |
4221 | my ($self) = @_; |
4215 | my $NOW = Time::HiRes::time; |
4222 | my $NOW = EV::time; |
4216 | |
4223 | |
4217 | # freeze display when hovering over any label |
4224 | # freeze display when hovering over any label |
4218 | return if $DC::UI::TOOLTIP->{owner} |
4225 | return if $DC::UI::TOOLTIP->{owner} |
4219 | && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, |
4226 | && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, |
4220 | values %{ $self->{item} }; |
4227 | values %{ $self->{item} }; |
… | |
… | |
4270 | $label->{fg}[3] = $item->{fg}[3] || 1; |
4277 | $label->{fg}[3] = $item->{fg}[3] || 1; |
4271 | } |
4278 | } |
4272 | |
4279 | |
4273 | push @widgets, $label; |
4280 | push @widgets, $label; |
4274 | } |
4281 | } |
|
|
4282 | |
|
|
4283 | my $hash = join ",", @widgets; |
|
|
4284 | return if $hash eq $self->{last_widget_hash}; |
|
|
4285 | $self->{last_widget_hash} = $hash; |
4275 | |
4286 | |
4276 | $self->clear; |
4287 | $self->clear; |
4277 | $self->SUPER::add (reverse @widgets); |
4288 | $self->SUPER::add (reverse @widgets); |
4278 | } |
4289 | } |
4279 | |
4290 | |