ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.44 by root, Sun Apr 9 22:17:40 2006 UTC vs.
Revision 1.49 by root, Sun Apr 9 22:26:51 2006 UTC

7use SDL::OpenGL; 7use SDL::OpenGL;
8use SDL::OpenGL::Constants; 8use SDL::OpenGL::Constants;
9 9
10use Crossfire::Client; 10use Crossfire::Client;
11 11
12our $FOCUS; # the widget with current focus
13
14# class methods for events 12# class methods for events
15sub feed_sdl_key_down_event { $FOCUS->key_down ($_[0]) if $FOCUS } 13sub feed_sdl_key_down_event { $::FOCUS->key_down ($_[0]) if $::FOCUS }
16sub feed_sdl_key_up_event { $FOCUS->key_up ($_[0]) if $FOCUS } 14sub feed_sdl_key_up_event { $::FOCUS->key_up ($_[0]) if $::FOCUS }
17sub feed_sdl_button_down_event { } 15sub feed_sdl_button_down_event { }
18sub feed_sdl_button_up_event { } 16sub feed_sdl_button_up_event { }
19 17
20sub new { 18sub new {
21 my $class = shift; 19 my $class = shift;
46 $self->{h} = $h; 44 $self->{h} = $h;
47} 45}
48 46
49sub focus_in { 47sub focus_in {
50 my ($widget) = @_; 48 my ($widget) = @_;
51 $FOCUS = $widget; 49 $::FOCUS = $widget;
52} 50}
53 51
54sub focus_out { 52sub focus_out {
55 my ($widget) = @_; 53 my ($widget) = @_;
56} 54}
81 my ($self) = @_; 79 my ($self) = @_;
82 80
83 glPushMatrix; 81 glPushMatrix;
84 glTranslate $self->{x}, $self->{y}, 0; 82 glTranslate $self->{x}, $self->{y}, 0;
85 $self->_draw; 83 $self->_draw;
84 if ($self == $::HOVER) {
85 glColor 1, 1, 1, 0.4;
86 glBegin GL_QUADS;
87 glVertex 0, 0;
88 glVertex $self->{w} - 1, 0;
89 glVertex $self->{w} - 1, $self->{h} - 1;
90 glVertex 0, $self->{h} - 1;
91 glEnd;
92 }
86 glPopMatrix; 93 glPopMatrix;
87} 94}
88 95
89sub _draw { 96sub _draw {
90 my ($self) = @_; 97 my ($self) = @_;
177} 184}
178 185
179sub find_widget { 186sub find_widget {
180 my ($self, $x, $y) = @_; 187 my ($self, $x, $y) = @_;
181 188
189 $x -= $self->{x};
190 $y -= $self->{y};
191
182 my $res; 192 my $res;
183 193
184 for (@{ $self->{children} }) { 194 for (reverse @{ $self->{children} }) {
185 $res = $_->find_widget ($x - $self->{x}, $y - $self->{y}) 195 $res = $_->find_widget ($x, $y)
186 and return $res; 196 and return $res;
187 } 197 }
188 198
189 () 199 $self->SUPER::find_widget ($x + $self->{x}, $y + $self->{y})
190} 200}
191 201
192sub _draw { 202sub _draw {
193 my ($self) = @_; 203 my ($self) = @_;
194 204

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines