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.240 by root, Fri May 26 18:28:23 2006 UTC vs.
Revision 1.242 by elmex, Sat May 27 20:00:40 2006 UTC

9use CFClient; 9use CFClient;
10use CFClient::Texture; 10use CFClient::Texture;
11 11
12our ($FOCUS, $HOVER, $GRAB); # various widgets 12our ($FOCUS, $HOVER, $GRAB); # various widgets
13 13
14our $LAYOUT;
14our $ROOT; 15our $ROOT;
15our $TOOLTIP; 16our $TOOLTIP;
16our $BUTTON_STATE; 17our $BUTTON_STATE;
17 18
18our %WIDGET; # all widgets, weak-referenced 19our %WIDGET; # all widgets, weak-referenced
20
21sub get_layout {
22 for (grep { $_->{name} } values %WIDGET) {
23 $LAYOUT->{$_->{name}} = {
24 x => $_->{x} / $::WIDTH,
25 y => $_->{y} / $::HEIGHT,
26 w => $_->{w} / $::WIDTH,
27 h => $_->{h} / $::HEIGHT
28 };
29 }
30
31 return $LAYOUT;
32}
33
34sub set_layout {
35 my ($layout) = @_;
36 $LAYOUT = $layout;
37}
19 38
20sub check_tooltip { 39sub check_tooltip {
21 if (!$GRAB) { 40 if (!$GRAB) {
22 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 41 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
23 if (length $widget->{tooltip}) { 42 if (length $widget->{tooltip}) {
194 } 213 }
195 } 214 }
196 215
197 Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self); 216 Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self);
198 217
218 if (my $layout = $CFClient::UI::LAYOUT->{$self->{name}}) {
219 $self->{user_x} = $layout->{x} * $::WIDTH;
220 $self->{user_y} = $layout->{y} * $::HEIGHT;
221 $self->{user_w} = ($layout->{w} != 0 ? $layout->{w} : 1) * $::WIDTH;
222 $self->{user_h} = ($layout->{h} != 0 ? $layout->{h} : 1) * $::HEIGHT;
223 }
224
199 $self 225 $self
200} 226}
201 227
202sub destroy { 228sub destroy {
203 my ($self) = @_; 229 my ($self) = @_;
229sub set_invisible { 255sub set_invisible {
230 my ($self) = @_; 256 my ($self) = @_;
231 257
232 # broken show/hide model 258 # broken show/hide model
233 259
260 delete $self->{root};
234 delete $self->{visible}; 261 delete $self->{visible};
235 262
236 undef $GRAB if $GRAB == $self; 263 undef $GRAB if $GRAB == $self;
237 undef $HOVER if $HOVER == $self; 264 undef $HOVER if $HOVER == $self;
238 265
460 my ($self, $parent) = @_; 487 my ($self, $parent) = @_;
461 488
462 Scalar::Util::weaken ($self->{parent} = $parent); 489 Scalar::Util::weaken ($self->{parent} = $parent);
463 490
464 $self->{root} = $parent->{root}; 491 $self->{root} = $parent->{root};
465 $self->{visible} = $parent->{visible}; 492 $self->{visible} = $parent->{visible} + 1;
466 493
467 # TODO: req_w _does_change after ->reconfigure 494 # TODO: req_w _does_change after ->reconfigure
468 $self->check_size 495 $self->check_size
469 unless exists $self->{req_w}; 496 unless exists $self->{req_w};
470 497
2964 2991
2965sub new { 2992sub new {
2966 my $class = shift; 2993 my $class = shift;
2967 2994
2968 $class->SUPER::new ( 2995 $class->SUPER::new (
2996 visible => 1,
2969 @_, 2997 @_,
2970 ) 2998 )
2971} 2999}
2972 3000
2973sub configure { 3001sub configure {
3031sub add { 3059sub add {
3032 my ($self, @children) = @_; 3060 my ($self, @children) = @_;
3033 3061
3034 for (my @widgets = @children; my $w = pop @widgets; ) { 3062 for (my @widgets = @children; my $w = pop @widgets; ) {
3035 push @widgets, $w->children; 3063 push @widgets, $w->children;
3036 $w->{root} = $self; 3064 $w->{root} = $self;
3037 $w->{visible} = 1; 3065 $w->{visible} = $self->{visible} + 1;
3038 } 3066 }
3039 3067
3040 for my $child (@children) { 3068 for my $child (@children) {
3041 $child->{is_toplevel} = 1; 3069 $child->{is_toplevel} = 1;
3042 3070

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines