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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines