--- deliantra/Deliantra-Client/DC/UI.pm 2006/06/12 13:26:14 1.302 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/06/13 10:28:38 1.303 @@ -1092,6 +1092,15 @@ fontsize => $self->{border}, if exists $self->{title}; + unless ($self->{no_close_button}) { + $self->{close_btn} = + new CFClient::UI::ImageButton + image => 'x1_close.png', + on_activate => sub { $self->hide }; + + $self->CFClient::UI::Container::add ($self->{close_btn}); + } + $self } @@ -1099,6 +1108,7 @@ my ($self, @widgets) = @_; $self->SUPER::add (@widgets); + $self->CFClient::UI::Container::add ($self->{close_btn}) if $self->{close_btn}; $self->CFClient::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; } @@ -1112,6 +1122,9 @@ $self->{title_widget}->size_request if $self->{title_widget}; + $self->{close_btn}->size_request + if $self->{close_btn}; + my ($w, $h) = $self->SUPER::size_request; ( @@ -1133,8 +1146,11 @@ $h -= List::Util::max 0, $border * 2; $w -= List::Util::max 0, $border * 2; - + $self->child->configure ($border, $border, $w, $h); + + $self->{close_btn}->configure ($self->{w} - (2 * $border), 0, $border, $border) + if $self->{close_btn}; } sub button_down { @@ -1190,6 +1206,9 @@ sub button_up { my ($self, $ev, $x, $y) = @_; + $self->{close_btn}->button_up ($ev, $x, $y) + if $self->{close_btn}; + !!delete $self->{motion} } @@ -1237,7 +1256,12 @@ if ($self->{title_widget}) { glTranslate 0, $border - $self->{h}; $self->{title_widget}->_draw; + + glTranslate 0, - ($border - $self->{h}); } + + $self->{close_btn}->draw + if $self->{close_btn}; } ############################################################################# @@ -1961,6 +1985,44 @@ } ############################################################################# + +package CFClient::UI::ImageButton; + +our @ISA = CFClient::UI::Image::; + +use CFClient::OpenGL; + +my %textures; + +sub new { + my $class = shift; + + my $self = $class->SUPER::new ( + padding_x => 4, + padding_y => 4, + fg => [1, 1, 1], + active_fg => [0, 0, 1], + can_hover => 1, + align => 0, + valign => 0, + can_events => 1, + @_ + ); +} + +sub activate { } + +sub button_up { + my ($self, $ev, $x, $y) = @_; + + $self->emit ("activate") + if $x >= 0 && $x < $self->{w} + && $y >= 0 && $y < $self->{h}; + + 1 +} + +############################################################################# package CFClient::UI::CheckBox;