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.150 by elmex, Sun Apr 23 00:08:29 2006 UTC vs.
Revision 1.151 by root, Sun Apr 23 00:57:39 2006 UTC

8use CFClient; 8use CFClient;
9 9
10our ($FOCUS, $HOVER, $GRAB); # various widgets 10our ($FOCUS, $HOVER, $GRAB); # various widgets
11 11
12our $ROOT; 12our $ROOT;
13our $TOOLTIP;
13our $BUTTON_STATE; 14our $BUTTON_STATE;
15
16sub check_tooltip {
17 if (!$GRAB) {
18 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
19 if (exists $widget->{tooltip}) {
20
21 if ($TOOLTIP->{owner} != $widget) {
22 $TOOLTIP->{owner} = $widget;
23 $TOOLTIP->set_text ($widget->{tooltip});
24 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0));
25 $TOOLTIP->show;
26 }
27
28 return;
29 }
30 }
31 }
32
33 $TOOLTIP->hide;
34 delete $TOOLTIP->{owner};
35}
14 36
15# class methods for events 37# class methods for events
16sub feed_sdl_key_down_event { 38sub feed_sdl_key_down_event {
17 $FOCUS->key_down ($_[0]) if $FOCUS; 39 $FOCUS->key_down ($_[0]) if $FOCUS;
18} 40}
28 if (!$BUTTON_STATE) { 50 if (!$BUTTON_STATE) {
29 my $widget = $ROOT->find_widget ($x, $y); 51 my $widget = $ROOT->find_widget ($x, $y);
30 52
31 $GRAB = $widget; 53 $GRAB = $widget;
32 $GRAB->update if $GRAB; 54 $GRAB->update if $GRAB;
55
56 check_tooltip;
33 } 57 }
34 58
35 $BUTTON_STATE |= 1 << ($ev->{button} - 1); 59 $BUTTON_STATE |= 1 << ($ev->{button} - 1);
36 60
37 $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; 61 $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB;
49 73
50 if (!$BUTTON_STATE) { 74 if (!$BUTTON_STATE) {
51 my $grab = $GRAB; undef $GRAB; 75 my $grab = $GRAB; undef $GRAB;
52 $grab->update if $grab; 76 $grab->update if $grab;
53 $GRAB->update if $GRAB; 77 $GRAB->update if $GRAB;
78
79 check_tooltip;
54 } 80 }
55} 81}
56 82
57sub feed_sdl_motion_event { 83sub feed_sdl_motion_event {
58 my ($ev) = @_; 84 my ($ev) = @_;
63 if ($widget != $HOVER) { 89 if ($widget != $HOVER) {
64 my $hover = $HOVER; $HOVER = $widget; 90 my $hover = $HOVER; $HOVER = $widget;
65 91
66 $hover->update if $hover && $hover->{can_hover}; 92 $hover->update if $hover && $hover->{can_hover};
67 $HOVER->update if $HOVER && $HOVER->{can_hover}; 93 $HOVER->update if $HOVER && $HOVER->{can_hover};
94
95 check_tooltip;
68 } 96 }
69 97
70 $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER; 98 $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER;
71} 99}
72 100
433 delete $child->{parent}; 461 delete $child->{parent};
434 462
435 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; 463 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ];
436 464
437 $self->check_size; 465 $self->check_size;
466 $self->update;
438} 467}
439 468
440sub find_widget { 469sub find_widget {
441 my ($self, $x, $y) = @_; 470 my ($self, $x, $y) = @_;
442 471
1685package CFClient::UI::Gauge; 1714package CFClient::UI::Gauge;
1686 1715
1687our @ISA = CFClient::UI::VBox::; 1716our @ISA = CFClient::UI::VBox::;
1688 1717
1689sub new { 1718sub new {
1690 my ($class, %arg) = shift; 1719 my ($class, %arg) = @_;
1691 1720
1692 my $self = $class->SUPER::new ( 1721 my $self = $class->SUPER::new (
1693 @_, 1722 tooltip => $arg{type},
1723 %arg,
1694 ); 1724 );
1695 1725
1696 $self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"; 1726 $self->add ($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});
1699 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); 1727 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1);
1700 $self->add ($self->{max}); 1728 $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999");
1701 1729
1702 $self 1730 $self
1703}
1704
1705sub size_request {
1706 my ($self) = @_;
1707 (($self->{max}->size_request)[0], 0)
1708} 1731}
1709 1732
1710sub set_fontsize { 1733sub set_fontsize {
1711 my ($self, $fsize) = @_; 1734 my ($self, $fsize) = @_;
1712 1735
2190############################################################################# 2213#############################################################################
2191 2214
2192package CFClient::UI; 2215package CFClient::UI;
2193 2216
2194$ROOT = new CFClient::UI::Root; 2217$ROOT = new CFClient::UI::Root;
2218$TOOLTIP = new CFClient::UI::Label fontsize => 0.8, can_events => 0;
2195 2219
21961 22201
2197 2221

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines