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.149 by root, Sat Apr 22 23:11:32 2006 UTC vs.
Revision 1.150 by elmex, Sun Apr 23 00:08:29 2006 UTC

96 96
97 my $self = bless { 97 my $self = bless {
98 x => 0, 98 x => 0,
99 y => 0, 99 y => 0,
100 z => 0, 100 z => 0,
101 can_events => 1,
101 @_ 102 @_
102 }, $class; 103 }, $class;
103 104
104 for (keys %$self) { 105 for (keys %$self) {
105 if (/^connect_(.*)$/) { 106 if (/^connect_(.*)$/) {
278} 279}
279 280
280sub find_widget { 281sub find_widget {
281 my ($self, $x, $y) = @_; 282 my ($self, $x, $y) = @_;
282 283
284 return () unless $self->{can_events};
285
283 return $self 286 return $self
284 if $x >= $self->{x} && $x < $self->{x} + $self->{w} 287 if $x >= $self->{x} && $x < $self->{x} + $self->{w}
285 && $y >= $self->{y} && $y < $self->{y} + $self->{h}; 288 && $y >= $self->{y} && $y < $self->{y} + $self->{h};
286 289
287 () 290 ()
379 382
380package CFClient::UI::Empty; 383package CFClient::UI::Empty;
381 384
382our @ISA = CFClient::UI::Base::; 385our @ISA = CFClient::UI::Base::;
383 386
387sub new {
388 my ($class, %arg) = @_;
389 $class->SUPER::new (can_events => 0, %arg);
390}
391
384sub size_request { 392sub size_request {
385 (0, 0) 393 (0, 0)
386} 394}
387 395
388sub draw { } 396sub draw { }
396sub new { 404sub new {
397 my ($class, %arg) = @_; 405 my ($class, %arg) = @_;
398 406
399 my $children = delete $arg{children} || []; 407 my $children = delete $arg{children} || [];
400 408
401 my $self = $class->SUPER::new (children => [], %arg); 409 my $self = $class->SUPER::new (children => [], can_events => 0, %arg);
402 $self->add ($_) for @$children; 410 $self->add ($_) for @$children;
403 411
404 $self 412 $self
405} 413}
406 414
660 668
661 my $self = $class->SUPER::new ( 669 my $self = $class->SUPER::new (
662 bg => [1, 1, 1, 1], 670 bg => [1, 1, 1, 1],
663 border_bg => [1, 1, 1, 1], 671 border_bg => [1, 1, 1, 1],
664 border => 0.8, 672 border => 0.8,
673 can_events => 1,
665 @_ 674 @_
666 ); 675 );
667 676
668 $self->{title} &&= new CFClient::UI::Label 677 $self->{title} &&= new CFClient::UI::Label
669 align => 0, 678 align => 0,
1062 text => "", 1071 text => "",
1063 align => -1, 1072 align => -1,
1064 valign => -1, 1073 valign => -1,
1065 padding => 2, 1074 padding => 2,
1066 layout => new CFClient::Layout, 1075 layout => new CFClient::Layout,
1076 can_events => 0,
1067 %arg 1077 %arg
1068 ); 1078 );
1069 1079
1070 if (exists $self->{template}) { 1080 if (exists $self->{template}) {
1071 my $layout = new CFClient::Layout; 1081 my $layout = new CFClient::Layout;
1196 active_bg => [1, 1, 1, 0.5], 1206 active_bg => [1, 1, 1, 0.5],
1197 active_fg => [0, 0, 0], 1207 active_fg => [0, 0, 0],
1198 can_hover => 1, 1208 can_hover => 1,
1199 can_focus => 1, 1209 can_focus => 1,
1200 valign => 0, 1210 valign => 0,
1211 can_events => 1,
1201 @_ 1212 @_
1202 ) 1213 )
1203} 1214}
1204 1215
1205sub _set_text { 1216sub _set_text {
1390 bg => [1, 1, 1, 0.2], 1401 bg => [1, 1, 1, 0.2],
1391 active_fg => [0, 0, 1], 1402 active_fg => [0, 0, 1],
1392 can_hover => 1, 1403 can_hover => 1,
1393 align => 0, 1404 align => 0,
1394 valign => 0, 1405 valign => 0,
1406 can_events => 1,
1395 @_ 1407 @_
1396 ) 1408 )
1397} 1409}
1398 1410
1399sub button_up { 1411sub button_up {
1504our %loaded_images; 1516our %loaded_images;
1505 1517
1506sub new { 1518sub new {
1507 my $class = shift; 1519 my $class = shift;
1508 1520
1509 my $self = $class->SUPER::new (@_); 1521 my $self = $class->SUPER::new (can_events => 0, @_);
1510 1522
1511 $self->{image} or confess "Image has 'image' not set. This is a fatal error!"; 1523 $self->{image} or confess "Image has 'image' not set. This is a fatal error!";
1512 1524
1513 $loaded_images{$self->{image}} ||= 1525 $loaded_images{$self->{image}} ||=
1514 new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; 1526 new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1;
1679 1691
1680 my $self = $class->SUPER::new ( 1692 my $self = $class->SUPER::new (
1681 @_, 1693 @_,
1682 ); 1694 );
1683 1695
1684 $self->add ($self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); 1696 $self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999";
1697 $self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999";
1698 $self->add ($self->{value});
1685 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); 1699 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1);
1686 $self->add ($self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); 1700 $self->add ($self->{max});
1687 1701
1688 $self 1702 $self
1703}
1704
1705sub size_request {
1706 my ($self) = @_;
1707 (($self->{max}->size_request)[0], 0)
1689} 1708}
1690 1709
1691sub set_fontsize { 1710sub set_fontsize {
1692 my ($self, $fsize) = @_; 1711 my ($self, $fsize) = @_;
1693 1712
2057 my $class = shift; 2076 my $class = shift;
2058 2077
2059 my $self = $class->SUPER::new ( 2078 my $self = $class->SUPER::new (
2060 state => 0, 2079 state => 0,
2061 connect_activate => \&toggle_flopper, 2080 connect_activate => \&toggle_flopper,
2081 can_events => 1,
2062 @_ 2082 @_
2063 ); 2083 );
2064 2084
2065 if ($self->{state}) { 2085 if ($self->{state}) {
2066 $self->{state} = 0; 2086 $self->{state} = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines