--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/25 11:48:31 1.175 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/25 12:10:58 1.176 @@ -790,7 +790,7 @@ my $self = $class->SUPER::new ( bg => [1, 1, 1, 1], border_bg => [1, 1, 1, 1], - border => 0.8, + border => 0.6, can_events => 1, @_ ); @@ -799,7 +799,7 @@ align => 0, valign => 1, text => $self->{title}, - fontsize => 1; + fontsize => $self->{border}; $self } @@ -834,27 +834,33 @@ sub button_down { my ($self, $ev, $x, $y) = @_; + my ($w, $h) = @$self{qw(w h)}; my $border = $self->border; - if ($x < $self->{w} && $x >= $self->{w} - $border - && $y < $self->{h} && $y >= $self->{h} - $border) { + my $lr = ($x >= 0 && $x < $border) || ($x > $w - $border && $x < $w); + my $td = ($y >= 0 && $y < $border) || ($y > $h - $border && $y < $h); + if ($lr & $td) { + my ($wx, $wy) = ($self->{x}, $self->{y}); my ($ox, $oy) = ($ev->{x}, $ev->{y}); my ($bw, $bh) = ($self->{w}, $self->{h}); + my $mx = $x < $border; + my $my = $y < $border; + $self->{motion} = sub { my ($ev, $x, $y) = @_; - ($x, $y) = ($ev->{x}, $ev->{y}); + my $dx = $ev->{x} - $ox; + my $dy = $ev->{y} - $oy; - $self->{user_w} = $bw + $x - $ox; - $self->{user_h} = $bh + $y - $oy; + $self->{user_w} = $bw + $dx * ($mx ? -1 : 1); + $self->{user_h} = $bh + $dy * ($my ? -1 : 1); + $self->move ($wx + $dx * $mx, $wy + $dy * $my); $self->check_size; }; - } elsif ($x >= 0 && $x < $self->{w} - && $y >= 0 && $y < $border) { - + } elsif ($lr ^ $td) { my ($ox, $oy) = ($ev->{x}, $ev->{y}); my ($bx, $by) = ($self->{x}, $self->{y}); @@ -2085,9 +2091,7 @@ ], ); - $self->{children}[1]->connect (changed => sub { - $self->update; - }); + $self->{children}[1]->connect (changed => sub { $self->update }); $self } @@ -2105,7 +2109,7 @@ my $layout = $self->{layout}; $layout->set_height ($self->{fontsize} * $::FONTSIZE); - $layout->set_width ($self->{w}); + $layout->set_width ($self->{children}[0]{w}); $layout->set_text ($text); ($layout->size)[1] @@ -2168,7 +2172,7 @@ delete $self->{texture}; } - $self->{texture} ||= new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { + $self->{texture} ||= new_from_opengl CFClient::Texture $self->{children}[0]{w}, $self->{children}[0]{h}, sub { glClearColor 0, 0, 0, 0; glClear GL_COLOR_BUFFER_BIT; @@ -2211,16 +2215,14 @@ sub _draw { my ($self) = @_; - if ($self->{texture}) { - glEnable GL_BLEND; - glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; - glEnable GL_TEXTURE_2D; - glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; - glColor 1, 1, 1, 1; - $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); - glDisable GL_TEXTURE_2D; - glDisable GL_BLEND; - } + glEnable GL_BLEND; + glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; + glEnable GL_TEXTURE_2D; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; + glColor 1, 1, 1, 1; + $self->{texture}->draw_quad (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); + glDisable GL_TEXTURE_2D; + glDisable GL_BLEND; $self->{children}[1]->draw;