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.42 by root, Sun Apr 9 22:00:58 2006 UTC vs.
Revision 1.46 by root, Sun Apr 9 22:21:02 2006 UTC

162 162
163 @{$self->{children}} = 163 @{$self->{children}} =
164 sort { $a->{z} <=> $b->{z} } 164 sort { $a->{z} <=> $b->{z} }
165 @{$self->{children}}, $chld; 165 @{$self->{children}}, $chld;
166 166
167 $self->size_allocate ($self->{w}, $self->{h}); 167 $self->size_allocate ($self->{w}, $self->{h})
168 if $self->{w}; #TODO: check for "realised state"
168} 169}
169 170
170sub remove { 171sub remove {
171 my ($self, $widget) = @_; 172 my ($self, $widget) = @_;
172 173
176} 177}
177 178
178sub find_widget { 179sub find_widget {
179 my ($self, $x, $y) = @_; 180 my ($self, $x, $y) = @_;
180 181
182 $x -= $self->{x};
183 $y -= $self->{y};
184
181 my $res; 185 my $res;
182 186
183 for (@{ $self->{children} }) { 187 for (reverse @{ $self->{children} }) {
184 $res = $_->find_widget ($x, $y) 188 $res = $_->find_widget ($x, $y)
185 and return $res; 189 and return $res;
186 } 190 }
187 191
188 () 192 $self->SUPER::find_widget ($x + $self->{x}, $y + $self->{y})
189}
190
191sub size_request {
192 my ($self) = @_;
193
194 my ($hs, $ws) = (0, 0);
195 for (@{$self->{children} || []}) {
196 my ($w, $h) = $_->size_request;
197 $hs += $h;
198 if ($ws < $w) { $ws = $w }
199 }
200
201 return ($ws, $hs);
202} 193}
203 194
204sub _draw { 195sub _draw {
205 my ($self) = @_; 196 my ($self) = @_;
206 197
395 $w -= $tex[2]->{width}; 386 $w -= $tex[2]->{width};
396 $w -= $tex[3]->{width}; 387 $w -= $tex[3]->{width};
397 388
398 $h = $h < 0 ? 0 : $h; 389 $h = $h < 0 ? 0 : $h;
399 $w = $w < 0 ? 0 : $w; 390 $w = $w < 0 ? 0 : $w;
400 warn "CHILD:$w $h\n"; 391
401 $self->child->size_allocate ($w, $h); 392 $self->child->size_allocate ($w, $h);
402 $self->child->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); 393 $self->child->move ($tex[3]->{width}, $tex[1]->{height});
403} 394}
404 395
405sub _draw { 396sub _draw {
406 my ($self) = @_; 397 my ($self) = @_;
407 398
408 my ($w, $h) = ($self->w, $self->h); 399 my ($w, $h) = ($self->{w}, $self->{h});
409 my ($cw, $ch) = ($self->child->w, $self->child->h); 400 my ($cw, $ch) = ($self->child->{w}, $self->child->{h});
410 401
411 glEnable GL_BLEND; 402 glEnable GL_BLEND;
412 glEnable GL_TEXTURE_2D; 403 glEnable GL_TEXTURE_2D;
413 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 404 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
414 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 405 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
568package Crossfire::Client::Widget::VBox; 559package Crossfire::Client::Widget::VBox;
569 560
570our @ISA = Crossfire::Client::Widget::Container::; 561our @ISA = Crossfire::Client::Widget::Container::;
571 562
572use SDL::OpenGL; 563use SDL::OpenGL;
564
565sub size_request {
566 my ($self) = @_;
567
568 my @alloc = map [$_->size_request], @{$self->{children}};
569
570 (
571 (List::Util::max map $_->[0], @alloc),
572 (List::Util::sum map $_->[1], @alloc),
573 )
574}
573 575
574sub size_allocate { 576sub size_allocate {
575 my ($self, $w, $h) = @_; 577 my ($self, $w, $h) = @_;
576 578
577 $self->w ($w); 579 $self->w ($w);
607 } else { 609 } else {
608 my ($cw, $h) = $_->size_request; 610 my ($cw, $h) = $_->size_request;
609 $_->size_allocate ($w, $h); 611 $_->size_allocate ($w, $h);
610 $y += $h; 612 $y += $h;
611 } 613 }
612 }
613}
614
615sub _draw {
616 my ($self) = @_;
617
618 my ($x, $y);
619 for (@{$self->{children} || []}) {
620 $_->draw;
621 $y += $_->h;
622 } 614 }
623} 615}
624 616
625############################################################################# 617#############################################################################
626 618

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines