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.43 by root, Sun Apr 9 22:12:11 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
184 $res = $_->find_widget ($x, $y) 185 $res = $_->find_widget ($x, $y)
185 and return $res; 186 and return $res;
186 } 187 }
187 188
188 () 189 ()
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} 190}
203 191
204sub _draw { 192sub _draw {
205 my ($self) = @_; 193 my ($self) = @_;
206 194
395 $w -= $tex[2]->{width}; 383 $w -= $tex[2]->{width};
396 $w -= $tex[3]->{width}; 384 $w -= $tex[3]->{width};
397 385
398 $h = $h < 0 ? 0 : $h; 386 $h = $h < 0 ? 0 : $h;
399 $w = $w < 0 ? 0 : $w; 387 $w = $w < 0 ? 0 : $w;
400 warn "CHILD:$w $h\n"; 388
401 $self->child->size_allocate ($w, $h); 389 $self->child->size_allocate ($w, $h);
402 $self->child->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); 390 $self->child->move ($tex[3]->{width}, $tex[1]->{height});
403} 391}
404 392
405sub _draw { 393sub _draw {
406 my ($self) = @_; 394 my ($self) = @_;
407 395
408 my ($w, $h) = ($self->w, $self->h); 396 my ($w, $h) = ($self->{w}, $self->{h});
409 my ($cw, $ch) = ($self->child->w, $self->child->h); 397 my ($cw, $ch) = ($self->child->{w}, $self->child->{h});
410 398
411 glEnable GL_BLEND; 399 glEnable GL_BLEND;
412 glEnable GL_TEXTURE_2D; 400 glEnable GL_TEXTURE_2D;
413 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 401 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
414 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 402 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
568package Crossfire::Client::Widget::VBox; 556package Crossfire::Client::Widget::VBox;
569 557
570our @ISA = Crossfire::Client::Widget::Container::; 558our @ISA = Crossfire::Client::Widget::Container::;
571 559
572use SDL::OpenGL; 560use SDL::OpenGL;
561
562sub size_request {
563 my ($self) = @_;
564
565 my @alloc = map [$_->size_request], @{$self->{children}};
566
567 (
568 (List::Util::max map $_->[0], @alloc),
569 (List::Util::sum map $_->[1], @alloc),
570 )
571}
573 572
574sub size_allocate { 573sub size_allocate {
575 my ($self, $w, $h) = @_; 574 my ($self, $w, $h) = @_;
576 575
577 $self->w ($w); 576 $self->w ($w);
607 } else { 606 } else {
608 my ($cw, $h) = $_->size_request; 607 my ($cw, $h) = $_->size_request;
609 $_->size_allocate ($w, $h); 608 $_->size_allocate ($w, $h);
610 $y += $h; 609 $y += $h;
611 } 610 }
612 }
613}
614
615sub _draw {
616 my ($self) = @_;
617
618 my ($x, $y);
619 for (@{$self->{children} || []}) {
620 $_->draw;
621 $y += $_->h;
622 } 611 }
623} 612}
624 613
625############################################################################# 614#############################################################################
626 615

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines