--- deliantra/Deliantra-Client/DC/UI.pm 2006/06/12 12:28:06 1.301 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/06/12 13:26:14 1.302 @@ -274,8 +274,8 @@ $_->set_invisible for $self->children; - delete $self->{root}; delete $self->{visible}; + delete $self->{root}; undef $GRAB if $GRAB == $self; undef $HOVER if $HOVER == $self; @@ -595,7 +595,9 @@ my ($self) = @_; delete $WIDGET{$self+0}; - #$self->deactivate; + + eval { $self->destroy }; + warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; } ############################################################################# @@ -770,8 +772,7 @@ sub add { my ($self, $child) = @_; - $self->{children} = []; - + $self->SUPER::remove ($_) for @{ $self->{children} }; $self->SUPER::add ($child); } @@ -1074,8 +1075,6 @@ sub new { my ($class, %arg) = @_; - my $title = delete $arg{title}; - my $self = $class->SUPER::new ( bg => [1, 1, 1, 1], border_bg => [1, 1, 1, 1], @@ -1086,12 +1085,12 @@ %arg, ); - $self->{title} = new CFClient::UI::Label + $self->{title_widget} = new CFClient::UI::Label align => 0, valign => 1, - text => $title, - fontsize => $self->{border} - if defined $title; + text => $self->{title}, + fontsize => $self->{border}, + if exists $self->{title}; $self } @@ -1100,7 +1099,7 @@ my ($self, @widgets) = @_; $self->SUPER::add (@widgets); - $self->CFClient::UI::Container::add ($self->{title}) if $self->{title}; + $self->CFClient::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; } sub border { @@ -1110,8 +1109,8 @@ sub size_request { my ($self) = @_; - $self->{title}->size_request - if $self->{title}; + $self->{title_widget}->size_request + if $self->{title_widget}; my ($w, $h) = $self->SUPER::size_request; @@ -1124,10 +1123,10 @@ sub size_allocate { my ($self, $w, $h) = @_; - if ($self->{title}) { - $self->{title}{w} = $w; - $self->{title}{h} = $h; - $self->{title}->size_allocate ($w, $h); + if ($self->{title_widget}) { + $self->{title_widget}{w} = $w; + $self->{title_widget}{h} = $h; + $self->{title_widget}->size_allocate ($w, $h); } my $border = $self->border; @@ -1235,9 +1234,9 @@ $child->draw; - if ($self->{title}) { + if ($self->{title_widget}) { glTranslate 0, $border - $self->{h}; - $self->{title}->_draw; + $self->{title_widget}->_draw; } } @@ -1273,6 +1272,12 @@ $self->realloc; } +sub remove { + my ($self, $child) = @_; + + # TODO: not yet implemented +} + # TODO: move to container class maybe? send children a signal on removal? sub clear { my ($self) = @_; @@ -2899,13 +2904,13 @@ } } -sub DESTROY { +sub destroy { my ($self) = @_; $self->{timer}->cancel if $self->{timer}; - $self->SUPER::DESTROY; + $self->SUPER::destroy; } ############################################################################# @@ -3294,12 +3299,12 @@ $self->SUPER::reconfigure; } -sub DESTROY { +sub destroy { my ($self) = @_; $self->{timer}->cancel; - $self->SUPER::DESTROY; + $self->SUPER::destroy; } ############################################################################# @@ -3576,6 +3581,8 @@ $CFClient::UI::ROOT->on_refresh ($self => sub { $self->clear; + return unless $::CONN; + $self->add (1, 0, new CFClient::UI::Label text => "Spell Name", @TOOLTIP_NAME); $self->add (2, 0, new CFClient::UI::Label text => "Skill", @TOOLTIP_SKILL); $self->add (3, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL);