… | |
… | |
5 | use Scalar::Util; |
5 | use Scalar::Util; |
6 | |
6 | |
7 | use SDL::OpenGL; |
7 | use SDL::OpenGL; |
8 | use SDL::OpenGL::Constants; |
8 | use SDL::OpenGL::Constants; |
9 | |
9 | |
10 | our $FOCUS; # the widget with current focus |
10 | use Crossfire::Client; |
11 | |
11 | |
12 | # class methods for events |
12 | # class methods for events |
13 | sub feed_sdl_key_down_event { $FOCUS->key_down ($_[0]) if $FOCUS } |
13 | sub feed_sdl_key_down_event { $::FOCUS->key_down ($_[0]) if $::FOCUS } |
14 | sub feed_sdl_key_up_event { $FOCUS->key_up ($_[0]) if $FOCUS } |
14 | sub feed_sdl_key_up_event { $::FOCUS->key_up ($_[0]) if $::FOCUS } |
15 | sub feed_sdl_button_down_event { } |
15 | sub feed_sdl_button_down_event { } |
16 | sub feed_sdl_button_up_event { } |
16 | sub feed_sdl_button_up_event { } |
17 | |
17 | |
18 | sub new { |
18 | sub new { |
19 | my $class = shift; |
19 | my $class = shift; |
… | |
… | |
37 | Carp::confess "size_request is abtract"; |
37 | Carp::confess "size_request is abtract"; |
38 | } |
38 | } |
39 | |
39 | |
40 | sub size_allocate { |
40 | sub size_allocate { |
41 | my ($self, $w, $h) = @_; |
41 | my ($self, $w, $h) = @_; |
|
|
42 | |
42 | $self->w ($w); |
43 | $self->{w} = $w; |
43 | $self->h ($h); |
44 | $self->{h} = $h; |
44 | } |
45 | } |
45 | |
46 | |
46 | sub focus_in { |
47 | sub focus_in { |
47 | my ($widget) = @_; |
48 | my ($widget) = @_; |
48 | $FOCUS = $widget; |
49 | $::FOCUS = $widget; |
49 | } |
50 | } |
50 | |
51 | |
51 | sub focus_out { |
52 | sub focus_out { |
52 | my ($widget) = @_; |
53 | my ($widget) = @_; |
53 | } |
54 | } |
… | |
… | |
78 | my ($self) = @_; |
79 | my ($self) = @_; |
79 | |
80 | |
80 | glPushMatrix; |
81 | glPushMatrix; |
81 | glTranslate $self->{x}, $self->{y}, 0; |
82 | glTranslate $self->{x}, $self->{y}, 0; |
82 | $self->_draw; |
83 | $self->_draw; |
|
|
84 | if ($self == $::HOVER) { |
|
|
85 | glColor 1, 1, 1, 0.4; |
|
|
86 | glEnable GL_BLEND; |
|
|
87 | glBegin GL_QUADS; |
|
|
88 | glVertex 0, 0; |
|
|
89 | glVertex $self->{w} - 1, 0; |
|
|
90 | glVertex $self->{w} - 1, $self->{h} - 1; |
|
|
91 | glVertex 0, $self->{h} - 1; |
|
|
92 | glEnd; |
|
|
93 | glDisable GL_BLEND; |
|
|
94 | } |
83 | glPopMatrix; |
95 | glPopMatrix; |
84 | } |
96 | } |
85 | |
97 | |
86 | sub _draw { |
98 | sub _draw { |
87 | my ($self) = @_; |
99 | my ($self) = @_; |
… | |
… | |
134 | my ($self) = @_; |
146 | my ($self) = @_; |
135 | |
147 | |
136 | #$self->deactivate; |
148 | #$self->deactivate; |
137 | } |
149 | } |
138 | |
150 | |
|
|
151 | ############################################################################# |
|
|
152 | |
139 | package Crossfire::Client::Widget::Container; |
153 | package Crossfire::Client::Widget::Container; |
140 | |
154 | |
141 | our @ISA = Crossfire::Client::Widget::; |
155 | our @ISA = Crossfire::Client::Widget::; |
142 | |
156 | |
143 | sub new { |
157 | sub new { |
… | |
… | |
157 | |
171 | |
158 | @{$self->{children}} = |
172 | @{$self->{children}} = |
159 | sort { $a->{z} <=> $b->{z} } |
173 | sort { $a->{z} <=> $b->{z} } |
160 | @{$self->{children}}, $chld; |
174 | @{$self->{children}}, $chld; |
161 | |
175 | |
162 | $self->size_allocate ($self->{w}, $self->{h}); |
176 | $self->size_allocate ($self->{w}, $self->{h}) |
|
|
177 | if $self->{w}; #TODO: check for "realised state" |
163 | } |
178 | } |
164 | |
179 | |
165 | sub remove { |
180 | sub remove { |
166 | my ($self, $widget) = @_; |
181 | my ($self, $widget) = @_; |
167 | |
182 | |
… | |
… | |
171 | } |
186 | } |
172 | |
187 | |
173 | sub find_widget { |
188 | sub find_widget { |
174 | my ($self, $x, $y) = @_; |
189 | my ($self, $x, $y) = @_; |
175 | |
190 | |
|
|
191 | $x -= $self->{x}; |
|
|
192 | $y -= $self->{y}; |
|
|
193 | |
176 | my $res; |
194 | my $res; |
177 | |
195 | |
178 | for (@{ $self->{children} }) { |
196 | for (reverse @{ $self->{children} }) { |
179 | $res = $_->find_widget ($x, $y) |
197 | $res = $_->find_widget ($x, $y) |
180 | and return $res; |
198 | and return $res; |
181 | } |
199 | } |
182 | |
200 | |
183 | () |
201 | $self->SUPER::find_widget ($x + $self->{x}, $y + $self->{y}) |
184 | } |
|
|
185 | |
|
|
186 | sub size_request { |
|
|
187 | my ($self) = @_; |
|
|
188 | |
|
|
189 | my ($hs, $ws) = (0, 0); |
|
|
190 | for (@{$self->{children} || []}) { |
|
|
191 | my ($w, $h) = $_->size_request; |
|
|
192 | $hs += $h; |
|
|
193 | if ($ws < $w) { $ws = $w } |
|
|
194 | } |
|
|
195 | |
|
|
196 | return ($ws, $hs); |
|
|
197 | } |
202 | } |
198 | |
203 | |
199 | sub _draw { |
204 | sub _draw { |
200 | my ($self) = @_; |
205 | my ($self) = @_; |
201 | |
206 | |
202 | $_->draw for @{$self->{children}}; |
207 | $_->draw for @{$self->{children}}; |
203 | } |
208 | } |
204 | |
209 | |
|
|
210 | ############################################################################# |
|
|
211 | |
205 | package Crossfire::Client::Widget::Bin; |
212 | package Crossfire::Client::Widget::Bin; |
206 | |
213 | |
207 | our @ISA = Crossfire::Client::Widget::Container::; |
214 | our @ISA = Crossfire::Client::Widget::Container::; |
208 | |
215 | |
209 | sub get { $_[0]->{children}[0] } |
216 | sub child { $_[0]->{children}[0] } |
210 | |
217 | |
211 | sub size_request { |
218 | sub size_request { |
212 | $_[0]{children}[0]->size_request if $_[0]{children}[0]; |
219 | $_[0]{children}[0]->size_request if $_[0]{children}[0]; |
213 | } |
220 | } |
214 | |
221 | |
215 | sub size_allocate { |
222 | sub size_allocate { |
216 | my ($self, $w, $h) = @_; |
223 | my ($self, $w, $h) = @_; |
|
|
224 | |
217 | $self->SUPER::size_allocate ($w, $h); |
225 | $self->SUPER::size_allocate ($w, $h); |
218 | $self->{children}[0]->size_allocate ($w, $h) |
226 | $self->{children}[0]->size_allocate ($w, $h) |
219 | if $self->{children}[0] |
227 | if $self->{children}[0] |
220 | } |
228 | } |
221 | |
229 | |
|
|
230 | ############################################################################# |
|
|
231 | |
222 | package Crossfire::Client::Widget::Toplevel; |
232 | package Crossfire::Client::Widget::Toplevel; |
223 | |
233 | |
224 | our @ISA = Crossfire::Client::Widget::Container::; |
234 | our @ISA = Crossfire::Client::Widget::Container::; |
225 | |
235 | |
226 | sub update { |
236 | sub update { |
227 | my ($self) = @_; |
237 | my ($self) = @_; |
228 | |
238 | |
229 | ::refresh (); |
239 | ::refresh (); |
230 | } |
240 | } |
231 | |
241 | |
|
|
242 | sub add { |
|
|
243 | my ($self, $widget) = @_; |
|
|
244 | |
|
|
245 | $self->SUPER::add ($widget); |
|
|
246 | |
|
|
247 | $widget->size_allocate ($widget->size_request); |
|
|
248 | } |
|
|
249 | |
|
|
250 | ############################################################################# |
|
|
251 | |
232 | package Crossfire::Client::Widget::Window; |
252 | package Crossfire::Client::Widget::Window; |
233 | |
253 | |
234 | our @ISA = Crossfire::Client::Widget::Bin::; |
254 | our @ISA = Crossfire::Client::Widget::Bin::; |
235 | |
255 | |
236 | use SDL::OpenGL; |
256 | use SDL::OpenGL; |
237 | |
257 | |
238 | sub add { |
258 | sub new { |
239 | my ($self, $chld) = @_; |
259 | my ($class, $x, $y, $z, $w, $h) = @_; |
240 | warn "ADD $chld\n"; |
|
|
241 | $self->SUPER::add ($chld); |
|
|
242 | $chld->set_parent ($self); |
|
|
243 | } |
|
|
244 | |
260 | |
245 | sub remove { |
261 | my $self = $class->SUPER::new; |
246 | my ($self) = @_; |
262 | |
247 | # TODO FIXME: removing a child from a window will crash, see render_chld |
263 | @$self{qw(x y z w h)} = ($x, $y, $z, $w, $h); |
248 | # $self->update; |
|
|
249 | } |
264 | } |
250 | |
265 | |
251 | sub update { |
266 | sub update { |
252 | my ($self) = @_; |
267 | my ($self) = @_; |
|
|
268 | |
253 | $self->render_chld; |
269 | $self->render_chld; |
|
|
270 | $self->SUPER::update; |
254 | } |
271 | } |
255 | |
272 | |
256 | sub render_chld { |
273 | sub render_chld { |
257 | my ($self) = @_; |
274 | my ($self) = @_; |
258 | my $chld = $self->get; |
|
|
259 | my ($w, $h) = $self->size_request; |
|
|
260 | |
275 | |
261 | require Carp; |
|
|
262 | Carp::cluck "RENDERCHI $w $h"; |
|
|
263 | warn "RENDERCHI $w $h\n"; |
|
|
264 | $self->{texture} = |
276 | $self->{texture} = |
265 | Crossfire::Client::Texture->new_from_opengl ( |
277 | Crossfire::Client::Texture->new_from_opengl ( |
266 | $w, $h, sub { $chld->draw } |
278 | $self->{w}, $self->{h}, sub { $self->child->draw } |
267 | ); |
279 | ); |
268 | $self->{texture}->upload; |
|
|
269 | } |
|
|
270 | |
|
|
271 | sub size_request { |
|
|
272 | my ($self) = @_; |
|
|
273 | ($self->w, $self->h) |
|
|
274 | } |
280 | } |
275 | |
281 | |
276 | sub size_allocate { |
282 | sub size_allocate { |
277 | my ($self, $w, $h) = @_; |
283 | my ($self, $w, $h) = @_; |
278 | |
284 | |
279 | $self->w ($w); |
285 | $self->{w} = $w; |
280 | $self->h ($h); |
286 | $self->{h} = $h; |
|
|
287 | |
281 | $self->get->size_allocate ($w, $h); |
288 | $self->child->size_allocate ($w, $h); |
282 | |
289 | |
283 | $self->update; #TODO: Move this to the size_request event propably? |
290 | $self->render_chld; |
284 | } |
291 | } |
285 | |
292 | |
286 | sub _draw { |
293 | sub _draw { |
287 | my ($self) = @_; |
294 | my ($self) = @_; |
288 | |
295 | |
… | |
… | |
305 | |
312 | |
306 | glDisable GL_BLEND; |
313 | glDisable GL_BLEND; |
307 | glDisable GL_TEXTURE_2D; |
314 | glDisable GL_TEXTURE_2D; |
308 | } |
315 | } |
309 | |
316 | |
|
|
317 | ############################################################################# |
|
|
318 | |
310 | package Crossfire::Client::Widget::Frame; |
319 | package Crossfire::Client::Widget::Frame; |
311 | |
320 | |
312 | our @ISA = Crossfire::Client::Widget::Bin::; |
321 | our @ISA = Crossfire::Client::Widget::Bin::; |
313 | |
322 | |
314 | use SDL::OpenGL; |
323 | use SDL::OpenGL; |
315 | |
324 | |
316 | sub size_request { |
325 | sub size_request { |
317 | my ($self) = @_; |
326 | my ($self) = @_; |
318 | my $chld = $self->get |
327 | my $chld = $self->child |
319 | or return (0, 0); |
328 | or return (0, 0); |
320 | |
329 | |
321 | $chld->move (2, 2); |
330 | $chld->move (2, 2); |
322 | |
331 | |
323 | map { $_ + 4 } $chld->size_request; |
332 | map { $_ + 4 } $chld->size_request; |
324 | } |
333 | } |
325 | |
334 | |
326 | sub size_allocate { |
335 | sub size_allocate { |
327 | my ($self, $w, $h) = @_; |
336 | my ($self, $w, $h) = @_; |
328 | |
337 | |
329 | $self->w ($w); |
338 | $self->{w} = $w; |
330 | $self->h ($h); |
339 | $self->{h} = $h; |
331 | |
340 | |
332 | $self->get->size_allocate ($w - 4, $h - 4); |
341 | $self->child->size_allocate ($w - 4, $h - 4); |
333 | $self->get->move (2, 2); |
342 | $self->child->move (2, 2); |
334 | } |
343 | } |
335 | |
344 | |
336 | sub _draw { |
345 | sub _draw { |
337 | my ($self) = @_; |
346 | my ($self) = @_; |
338 | |
347 | |
339 | my $chld = $self->get; |
348 | my $chld = $self->child; |
340 | |
349 | |
341 | my ($w, $h) = $chld->size_request; |
350 | my ($w, $h) = $chld->size_request; |
342 | |
351 | |
343 | glBegin GL_QUADS; |
352 | glBegin GL_QUADS; |
344 | glColor 0, 0, 0; |
353 | glColor 0, 0, 0; |
… | |
… | |
349 | glEnd; |
358 | glEnd; |
350 | |
359 | |
351 | $chld->draw; |
360 | $chld->draw; |
352 | } |
361 | } |
353 | |
362 | |
|
|
363 | ############################################################################# |
|
|
364 | |
354 | package Crossfire::Client::Widget::FancyFrame; |
365 | package Crossfire::Client::Widget::FancyFrame; |
355 | |
366 | |
356 | our @ISA = Crossfire::Client::Widget::Frame::; |
367 | our @ISA = Crossfire::Client::Widget::Bin::; |
357 | |
368 | |
358 | use SDL::OpenGL; |
369 | use SDL::OpenGL; |
359 | |
370 | |
360 | sub new { |
371 | my @tex = |
361 | my ($self, $theme) = @_; |
|
|
362 | $self = $self->SUPER::new; |
|
|
363 | |
|
|
364 | $self->{txts} = [ |
|
|
365 | map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } |
372 | map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } |
366 | qw/d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png/ |
373 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
367 | ]; |
|
|
368 | $self |
|
|
369 | } |
|
|
370 | |
374 | |
371 | sub size_request { |
375 | sub size_request { |
372 | my ($self) = @_; |
376 | my ($self) = @_; |
|
|
377 | |
373 | my ($w, $h) = $self->get->size_request; |
378 | my ($w, $h) = $self->SUPER::size_request; |
374 | |
379 | |
375 | $h += $self->{txts}->[1]->{height}; |
380 | $h += $tex[1]->{height}; |
376 | $h += $self->{txts}->[4]->{height}; |
381 | $h += $tex[4]->{height}; |
377 | $w += $self->{txts}->[2]->{width}; |
382 | $w += $tex[2]->{width}; |
378 | $w += $self->{txts}->[3]->{width}; |
383 | $w += $tex[3]->{width}; |
379 | |
384 | |
380 | ($w, $h) |
385 | ($w, $h) |
381 | } |
386 | } |
382 | |
387 | |
383 | sub size_allocate { |
388 | sub size_allocate { |
384 | my ($self, $w, $h) = @_; |
389 | my ($self, $w, $h) = @_; |
385 | |
390 | |
386 | $self->w ($w); |
391 | $self->SUPER::size_allocate ($w, $h); |
387 | $self->h ($h); |
392 | |
388 | $h -= $self->{txts}->[1]->{height}; |
393 | $h -= $tex[1]->{height}; |
389 | $h -= $self->{txts}->[4]->{height}; |
394 | $h -= $tex[4]->{height}; |
390 | $w -= $self->{txts}->[2]->{width}; |
395 | $w -= $tex[2]->{width}; |
391 | $w -= $self->{txts}->[3]->{width}; |
396 | $w -= $tex[3]->{width}; |
392 | |
397 | |
393 | $h = $h < 0 ? 0 : $h; |
398 | $h = $h < 0 ? 0 : $h; |
394 | $w = $w < 0 ? 0 : $w; |
399 | $w = $w < 0 ? 0 : $w; |
395 | warn "CHILD:$w $h\n"; |
400 | |
396 | $self->get->size_allocate ($w, $h); |
401 | $self->child->size_allocate ($w, $h); |
397 | $self->get->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); |
402 | $self->child->move ($tex[3]->{width}, $tex[1]->{height}); |
398 | } |
403 | } |
399 | |
404 | |
400 | sub _draw { |
405 | sub _draw { |
401 | my ($self) = @_; |
406 | my ($self) = @_; |
402 | |
407 | |
403 | my ($w, $h) = ($self->w, $self->h); |
408 | my ($w, $h) = ($self->{w}, $self->{h}); |
404 | my ($cw, $ch) = ($self->get->w, $self->get->h); |
409 | my ($cw, $ch) = ($self->child->{w}, $self->child->{h}); |
405 | |
410 | |
406 | glEnable GL_BLEND; |
411 | glEnable GL_BLEND; |
407 | glEnable GL_TEXTURE_2D; |
412 | glEnable GL_TEXTURE_2D; |
408 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
413 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
409 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
414 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
410 | |
415 | |
411 | my $top = $self->{txts}->[1]; |
416 | my $top = $tex[1]; |
412 | glBindTexture GL_TEXTURE_2D, $top->{name}; |
417 | glBindTexture GL_TEXTURE_2D, $top->{name}; |
413 | |
418 | |
414 | glBegin GL_QUADS; |
419 | glBegin GL_QUADS; |
415 | glTexCoord 0, 0; glVertex 0 , 0; |
420 | glTexCoord 0, 0; glVertex 0 , 0; |
416 | glTexCoord 0, 1; glVertex 0 , $top->{height}; |
421 | glTexCoord 0, 1; glVertex 0 , $top->{height}; |
417 | glTexCoord 1, 1; glVertex $w , $top->{height}; |
422 | glTexCoord 1, 1; glVertex $w , $top->{height}; |
418 | glTexCoord 1, 0; glVertex $w , 0; |
423 | glTexCoord 1, 0; glVertex $w , 0; |
419 | glEnd; |
424 | glEnd; |
420 | |
425 | |
421 | my $left = $self->{txts}->[3]; |
426 | my $left = $tex[3]; |
422 | glBindTexture GL_TEXTURE_2D, $left->{name}; |
427 | glBindTexture GL_TEXTURE_2D, $left->{name}; |
423 | |
428 | |
424 | glBegin GL_QUADS; |
429 | glBegin GL_QUADS; |
425 | glTexCoord 0, 0; glVertex 0 , $top->{height}; |
430 | glTexCoord 0, 0; glVertex 0 , $top->{height}; |
426 | glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch; |
431 | glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch; |
427 | glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch; |
432 | glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch; |
428 | glTexCoord 1, 0; glVertex $left->{width}, $top->{height}; |
433 | glTexCoord 1, 0; glVertex $left->{width}, $top->{height}; |
429 | glEnd; |
434 | glEnd; |
430 | |
435 | |
431 | my $right = $self->{txts}->[2]; |
436 | my $right = $tex[2]; |
432 | glBindTexture GL_TEXTURE_2D, $right->{name}; |
437 | glBindTexture GL_TEXTURE_2D, $right->{name}; |
433 | |
438 | |
434 | glBegin GL_QUADS; |
439 | glBegin GL_QUADS; |
435 | glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height}; |
440 | glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height}; |
436 | glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch; |
441 | glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch; |
437 | glTexCoord 1, 1; glVertex $w , $top->{height} + $ch; |
442 | glTexCoord 1, 1; glVertex $w , $top->{height} + $ch; |
438 | glTexCoord 1, 0; glVertex $w , $top->{height}; |
443 | glTexCoord 1, 0; glVertex $w , $top->{height}; |
439 | glEnd; |
444 | glEnd; |
440 | |
445 | |
441 | my $bottom = $self->{txts}->[4]; |
446 | my $bottom = $tex[4]; |
442 | glBindTexture GL_TEXTURE_2D, $bottom->{name}; |
447 | glBindTexture GL_TEXTURE_2D, $bottom->{name}; |
443 | |
448 | |
444 | glBegin GL_QUADS; |
449 | glBegin GL_QUADS; |
445 | glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height}; |
450 | glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height}; |
446 | glTexCoord 0, 1; glVertex 0 , $h; |
451 | glTexCoord 0, 1; glVertex 0 , $h; |
447 | glTexCoord 1, 1; glVertex $w , $h; |
452 | glTexCoord 1, 1; glVertex $w , $h; |
448 | glTexCoord 1, 0; glVertex $w , $h - $bottom->{height}; |
453 | glTexCoord 1, 0; glVertex $w , $h - $bottom->{height}; |
449 | glEnd; |
454 | glEnd; |
450 | |
455 | |
451 | my $bg = $self->{txts}->[0]; |
456 | my $bg = $tex[0]; |
452 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
457 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
453 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
458 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
454 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; |
459 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; |
455 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; |
460 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; |
456 | |
461 | |
… | |
… | |
465 | glEnd; |
470 | glEnd; |
466 | |
471 | |
467 | glDisable GL_BLEND; |
472 | glDisable GL_BLEND; |
468 | glDisable GL_TEXTURE_2D; |
473 | glDisable GL_TEXTURE_2D; |
469 | |
474 | |
470 | $self->get->draw; |
475 | $self->child->draw; |
471 | |
476 | |
472 | } |
477 | } |
|
|
478 | |
|
|
479 | ############################################################################# |
473 | |
480 | |
474 | package Crossfire::Client::Widget::Table; |
481 | package Crossfire::Client::Widget::Table; |
475 | |
482 | |
476 | our @ISA = Crossfire::Client::Widget::Bin::; |
483 | our @ISA = Crossfire::Client::Widget::Bin::; |
477 | |
484 | |
… | |
… | |
554 | |
561 | |
555 | $y += $self->max_row_height ($yi); |
562 | $y += $self->max_row_height ($yi); |
556 | } |
563 | } |
557 | } |
564 | } |
558 | |
565 | |
|
|
566 | ############################################################################# |
|
|
567 | |
559 | package Crossfire::Client::Widget::VBox; |
568 | package Crossfire::Client::Widget::VBox; |
560 | |
569 | |
561 | our @ISA = Crossfire::Client::Widget::Container::; |
570 | our @ISA = Crossfire::Client::Widget::Container::; |
562 | |
571 | |
563 | use SDL::OpenGL; |
572 | use SDL::OpenGL; |
|
|
573 | |
|
|
574 | sub size_request { |
|
|
575 | my ($self) = @_; |
|
|
576 | |
|
|
577 | my @alloc = map [$_->size_request], @{$self->{children}}; |
|
|
578 | |
|
|
579 | ( |
|
|
580 | (List::Util::max map $_->[0], @alloc), |
|
|
581 | (List::Util::sum map $_->[1], @alloc), |
|
|
582 | ) |
|
|
583 | } |
564 | |
584 | |
565 | sub size_allocate { |
585 | sub size_allocate { |
566 | my ($self, $w, $h) = @_; |
586 | my ($self, $w, $h) = @_; |
567 | |
587 | |
568 | $self->w ($w); |
588 | $self->w ($w); |
… | |
… | |
601 | $y += $h; |
621 | $y += $h; |
602 | } |
622 | } |
603 | } |
623 | } |
604 | } |
624 | } |
605 | |
625 | |
606 | sub _draw { |
626 | ############################################################################# |
607 | my ($self) = @_; |
|
|
608 | |
|
|
609 | my ($x, $y); |
|
|
610 | for (@{$self->{children} || []}) { |
|
|
611 | $_->draw; |
|
|
612 | $y += $_->h; |
|
|
613 | } |
|
|
614 | } |
|
|
615 | |
627 | |
616 | package Crossfire::Client::Widget::Label; |
628 | package Crossfire::Client::Widget::Label; |
617 | |
629 | |
618 | our @ISA = Crossfire::Client::Widget::; |
630 | our @ISA = Crossfire::Client::Widget::; |
619 | |
631 | |
… | |
… | |
676 | |
688 | |
677 | glDisable GL_BLEND; |
689 | glDisable GL_BLEND; |
678 | glDisable GL_TEXTURE_2D; |
690 | glDisable GL_TEXTURE_2D; |
679 | } |
691 | } |
680 | |
692 | |
|
|
693 | ############################################################################# |
|
|
694 | |
681 | package Crossfire::Client::Widget::TextEntry; |
695 | package Crossfire::Client::Widget::TextEntry; |
682 | |
696 | |
683 | our @ISA = Crossfire::Client::Widget::Label::; |
697 | our @ISA = Crossfire::Client::Widget::Label::; |
684 | |
698 | |
685 | use SDL; |
699 | use SDL; |
… | |
… | |
702 | } elsif ($uni) { |
716 | } elsif ($uni) { |
703 | $text .= chr $uni; |
717 | $text .= chr $uni; |
704 | } |
718 | } |
705 | $self->set_text ($text); |
719 | $self->set_text ($text); |
706 | } |
720 | } |
|
|
721 | |
|
|
722 | ############################################################################# |
707 | |
723 | |
708 | package Crossfire::Client::Widget::MapWidget; |
724 | package Crossfire::Client::Widget::MapWidget; |
709 | |
725 | |
710 | use strict; |
726 | use strict; |
711 | |
727 | |
… | |
… | |
878 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
894 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
879 | $::CONN->send ("command run_stop"); |
895 | $::CONN->send ("command run_stop"); |
880 | } |
896 | } |
881 | } |
897 | } |
882 | |
898 | |
|
|
899 | ############################################################################# |
|
|
900 | |
883 | package Crossfire::Client::Widget::Animator; |
901 | package Crossfire::Client::Widget::Animator; |
884 | |
902 | |
885 | use SDL::OpenGL; |
903 | use SDL::OpenGL; |
886 | |
904 | |
887 | our @ISA = Crossfire::Client::Widget::Bin::; |
905 | our @ISA = Crossfire::Client::Widget::Bin::; |