--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/12 15:35:54 1.86 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/12 17:11:02 1.87 @@ -1229,15 +1229,11 @@ use SDL; use SDL::OpenGL; -my @tex = - map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } - qw(b1_button_active.png); - sub new { my $class = shift; $class->SUPER::new ( - padding => 4, + padding => 2, fg => [1, 1, 1], active_fg => [1, 1, 0], state => 0, @@ -1245,39 +1241,54 @@ ) } +sub size_request { + my ($self) = @_; + + ($self->{padding} * 2 + 6) x 2 +} + +sub size_allocate { + my ($self, $x, $y, $w, $h) = @_; + + $self->_size_allocate ($x, $y, $w, $h); +} + sub button_down { my ($self, $ev, $x, $y) = @_; if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { $self->{state} = !$self->{state}; - $self->emit ("changed"); + $self->emit (changed => $self->{state}); } } sub _draw { my ($self) = @_; - local $self->{fg} = $self->{fg}; - my $tex = $tex[0]; - - glEnable GL_BLEND; - glEnable GL_TEXTURE_2D; - glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; - - if ($GRAB == $self) { - $self->{fg} = $self->{active_fg}; - } - - glBindTexture GL_TEXTURE_2D, $tex->{name}; - glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; + $self->SUPER::_draw; - $tex->draw_quad (0, 0, $self->{w}, $self->{h}); + glTranslate $self->{padding} + 0.375, $self->{padding} + 0.375, 0; - glDisable GL_TEXTURE_2D; - glDisable GL_BLEND; + my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2; + + glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} }; + + glBegin GL_LINE_LOOP; + glVertex 0 , 0; + glVertex 0 , $s; + glVertex $s, $s; + glVertex $s, 0; + glEnd; - $self->SUPER::_draw; + if ($self->{state}) { + glBegin GL_LINES; + glVertex 0 , 0; + glVertex $s, $s; + glVertex $s, 0; + glVertex 0 , $s; + glEnd; + } } ############################################################################# @@ -1531,6 +1542,18 @@ } glCallList $self->{list}; + + if ($FOCUS != $self) { + glEnable GL_BLEND; + glColor 0, 0, 1, 0.4; + glBegin GL_QUADS; + glVertex 0, 0; + glVertex 0, $::HEIGHT; + glVertex $::WIDTH, $::HEIGHT; + glVertex $::WIDTH, 0; + glEnd; + glDisable GL_BLEND; + } } my %DIR = (