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.65 by root, Tue Apr 11 14:04:27 2006 UTC vs.
Revision 1.67 by root, Tue Apr 11 14:36:59 2006 UTC

215 #$self->deactivate; 215 #$self->deactivate;
216} 216}
217 217
218############################################################################# 218#############################################################################
219 219
220package CFClient::Widget::Empty;
221
222our @ISA = CFClient::Widget::;
223
224sub size_request {
225 (0, 0)
226}
227
228sub draw { }
229
230#############################################################################
231
220package CFClient::Widget::Container; 232package CFClient::Widget::Container;
221 233
222our @ISA = CFClient::Widget::; 234our @ISA = CFClient::Widget::;
223 235
224sub new { 236sub new {
236 my ($self, $chld, $expand) = @_; 248 my ($self, $chld, $expand) = @_;
237 249
238 $chld->{expand} = $expand; 250 $chld->{expand} = $expand;
239 $chld->set_parent ($self); 251 $chld->set_parent ($self);
240 252
241 @{$self->{children}} = 253 $self->{children} = [
242 sort { $a->{z} <=> $b->{z} } 254 sort { $a->{z} <=> $b->{z} }
243 @{$self->{children}}, $chld; 255 @{$self->{children}}, $chld
256 ];
244 257
245 $self->size_allocate ($self->{w}, $self->{h}) 258 $self->size_allocate ($self->{w}, $self->{h})
246 if $self->{w}; #TODO: check for "realised state" 259 if $self->{w}; #TODO: check for "realised state"
247} 260}
248 261
279############################################################################# 292#############################################################################
280 293
281package CFClient::Widget::Bin; 294package CFClient::Widget::Bin;
282 295
283our @ISA = CFClient::Widget::Container::; 296our @ISA = CFClient::Widget::Container::;
297
298sub new {
299 my ($class, %arg) = @_;
300
301 my $child = (delete $arg{child}) || new CFClient::Widget::Empty::;
302
303 $class->SUPER::new (children => [$child], %arg)
304}
305
306sub add {
307 my ($self, $widget) = @_;
308
309 $self->{children} = [];
310
311 $self->SUPER::add ($widget);
312}
313
314sub remove {
315 my ($self, $widget) = @_;
316
317 $self->SUPER::remove ($widget);
318
319 $self->{children} = [new CFClient::Widget::Empty]
320 unless @{$self->{children}};
321}
284 322
285sub child { $_[0]->{children}[0] } 323sub child { $_[0]->{children}[0] }
286 324
287sub size_request { 325sub size_request {
288 $_[0]{children}[0]->size_request if $_[0]{children}[0]; 326 $_[0]{children}[0]->size_request if $_[0]{children}[0];
438 $w -= $tex[3]->{width}; 476 $w -= $tex[3]->{width};
439 477
440 $h = $h < 0 ? 0 : $h; 478 $h = $h < 0 ? 0 : $h;
441 $w = $w < 0 ? 0 : $w; 479 $w = $w < 0 ? 0 : $w;
442 480
481 my $child = $self->child;
482
443 $self->child->size_allocate ($w, $h); 483 $child->size_allocate ($w, $h);
444 $self->child->move ($tex[3]->{width}, $tex[1]->{height}); 484 $child->move ($tex[3]->{width}, $tex[1]->{height});
445} 485}
446 486
447sub _draw { 487sub _draw {
448 my ($self) = @_; 488 my ($self) = @_;
449 489

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines