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.467 by root, Wed Sep 3 06:07:39 2008 UTC vs.
Revision 1.472 by root, Wed Dec 24 04:09:27 2008 UTC

286sub set_visible { 286sub set_visible {
287 my ($self) = @_; 287 my ($self) = @_;
288 288
289 return if $self->{visible}; 289 return if $self->{visible};
290 290
291 $self->{parent} && $self->{parent}{root}#d#
292 or return ::clienterror ("set_visible called without parent ($self->{parent}) or root\n" => 1);
293
291 $self->{root} = $self->{parent}{root}; 294 $self->{root} = $self->{parent}{root};
292 $self->{visible} = $self->{parent}{visible} + 1; 295 $self->{visible} = $self->{parent}{visible} + 1;
293 296
294 $self->emit (visibility_change => 1); 297 $self->emit (visibility_change => 1);
295 298
296 $self->realloc if !exists $self->{req_w}; 299 $self->realloc if !exists $self->{req_w};
297 300
298 $_->set_visible for $self->children; 301 $_->set_visible for $self->visible_children;
299} 302}
300 303
301sub set_invisible { 304sub set_invisible {
302 my ($self) = @_; 305 my ($self) = @_;
303 306
1256 fontsize => ($arg{border} || 0.8) * 0.75; 1259 fontsize => ($arg{border} || 0.8) * 0.75;
1257 } 1260 }
1258 1261
1259 my $self = $class->SUPER::new ( 1262 my $self = $class->SUPER::new (
1260 # label => "", 1263 # label => "",
1261 fg => [0.6, 0.3, 0.1], 1264 fg => undef,
1262 border => 0.8, 1265 border => 0.8,
1263 style => 'single', 1266 style => 'single',
1264 %arg, 1267 %arg,
1265 ); 1268 );
1266 1269
1319 my $border = $self->border; 1322 my $border = $self->border;
1320 my ($w, $h) = ($self->{w}, $self->{h}); 1323 my ($w, $h) = ($self->{w}, $self->{h});
1321 1324
1322 $child->draw; 1325 $child->draw;
1323 1326
1324 glColor @{$self->{fg}}; 1327 glColor @{$self->{fg} || $DC::THEME{fancyframe}};
1325 glBegin GL_LINE_STRIP; 1328 glBegin GL_LINE_STRIP;
1326 glVertex $border * 1.5 , $border * 0.5 + 0.5; 1329 glVertex $border * 1.5 , $border * 0.5 + 0.5;
1327 glVertex $border * 0.5 + 0.5, $border * 0.5 + 0.5; 1330 glVertex $border * 0.5 + 0.5, $border * 0.5 + 0.5;
1328 glVertex $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; 1331 glVertex $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5;
1329 glVertex $w - $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; 1332 glVertex $w - $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5;
1361 my ($class, %arg) = @_; 1364 my ($class, %arg) = @_;
1362 1365
1363 my $self = $class->SUPER::new ( 1366 my $self = $class->SUPER::new (
1364 bg => [1, 1, 1, 1], 1367 bg => [1, 1, 1, 1],
1365 border_bg => [1, 1, 1, 1], 1368 border_bg => [1, 1, 1, 1],
1366 border => 1, 1369 border => 0.8,
1367 can_events => 1, 1370 can_events => 1,
1368 min_w => 64, 1371 min_w => 64,
1369 min_h => 32, 1372 min_h => 32,
1370 %arg, 1373 %arg,
1371 ); 1374 );
2090 my $class = shift; 2093 my $class = shift;
2091 2094
2092 $class->SUPER::new ( 2095 $class->SUPER::new (
2093 fg => [1, 1, 1], 2096 fg => [1, 1, 1],
2094 bg => [0, 0, 0, 0.2], 2097 bg => [0, 0, 0, 0.2],
2095 outline => [0.6, 0.3, 0.1], 2098 outline => undef,
2096 active_bg => [0, 0, 1, .2], 2099 active_bg => [0, 0, 1, .2],
2097 active_fg => [1, 1, 1], 2100 active_fg => [1, 1, 1],
2098 active_outline => [1, 1, 0], 2101 active_outline => [1, 1, 0],
2099 can_hover => 1, 2102 can_hover => 1,
2100 can_focus => 1, 2103 can_focus => 1,
2273 glColor @{$self->{active_outline}}; 2276 glColor @{$self->{active_outline}};
2274 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; 2277 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5;
2275 glLineWidth 1; 2278 glLineWidth 1;
2276 2279
2277 } else { 2280 } else {
2278 glColor @{$self->{outline}}; 2281 glColor @{$self->{outline} || $DC::THEME{entry_outline}};
2279 glBegin GL_LINE_STRIP; 2282 glBegin GL_LINE_STRIP;
2280 glVertex .5, $self->{h} * .5; 2283 glVertex .5, $self->{h} * .5;
2281 glVertex .5, $self->{h} - 2.5; 2284 glVertex .5, $self->{h} - 2.5;
2282 glVertex $self->{w} - .5, $self->{h} - 2.5; 2285 glVertex $self->{w} - .5, $self->{h} - 2.5;
2283 glVertex $self->{w} - .5, $self->{h} * .5; 2286 glVertex $self->{w} - .5, $self->{h} * .5;
3620 3623
3621 $tip =~ s/^\n+//; 3624 $tip =~ s/^\n+//;
3622 $tip =~ s/\n+$//; 3625 $tip =~ s/\n+$//;
3623 3626
3624 $self->add (new DC::UI::Label 3627 $self->add (new DC::UI::Label
3628 fg => $DC::THEME{tooltip_fg},
3625 markup => $tip, 3629 markup => $tip,
3626 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 3630 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
3627 align => 0, 3631 align => 0,
3628 fontsize => 0.8, 3632 fontsize => 0.8,
3629 style => 1, # FLAG_INVERSE 3633 style => $DC::THEME{tooltip_style}, # FLAG_INVERSE
3630 ellipsise => 0, 3634 ellipsise => 0,
3631 font => ($widget->{tooltip_font} || $::FONT_PROP), 3635 font => ($widget->{tooltip_font} || $::FONT_PROP),
3632 ); 3636 );
3633} 3637}
3634 3638
3671sub _draw { 3675sub _draw {
3672 my ($self) = @_; 3676 my ($self) = @_;
3673 3677
3674 my ($w, $h) = @$self{qw(w h)}; 3678 my ($w, $h) = @$self{qw(w h)};
3675 3679
3676 glColor 1, 0.8, 0.4; 3680 glColor @{ $DC::THEME{tooltip_bg} };
3677 glRect 0, 0, $w, $h; 3681 glRect 0, 0, $w, $h;
3678 3682
3679 glColor 0, 0, 0; 3683 glColor @{ $DC::THEME{tooltip_border} };
3680 glRect_lineloop .5, .5, $w + .5, $h + .5; 3684 glRect_lineloop .5, .5, $w + .5, $h + .5;
3681 3685
3682 glTranslate 2, 2; 3686 glTranslate 2, 2;
3683 3687
3684 $self->SUPER::_draw; 3688 $self->SUPER::_draw;
3932 3936
3933 my $self = $class->SUPER::new ( 3937 my $self = $class->SUPER::new (
3934 @_, 3938 @_,
3935 ); 3939 );
3936 3940
3937 $self->{current} = $self->{children}[0] 3941 $self->set_current_page (0);
3938 if @{ $self->{children} };
3939 3942
3940 $self 3943 $self
3941} 3944}
3942 3945
3943sub add { 3946sub add {
3944 my ($self, @widgets) = @_; 3947 my ($self, @widgets) = @_;
3945 3948
3946 $self->SUPER::add (@widgets); 3949 $self->SUPER::add (@widgets);
3947 3950
3948 $self->{current} = $self->{children}[0] 3951 $self->set_current_page (0)
3949 if @{ $self->{children} }; 3952 if @widgets == @{ $self->{children} };
3950} 3953}
3951 3954
3952sub get_current_page { 3955sub get_current_page {
3953 my ($self) = @_; 3956 my ($self) = @_;
3954 3957
3960 3963
3961 my $widget = ref $page_or_widget 3964 my $widget = ref $page_or_widget
3962 ? $page_or_widget 3965 ? $page_or_widget
3963 : $self->{children}[$page_or_widget]; 3966 : $self->{children}[$page_or_widget];
3964 3967
3968 $self->{current}->set_invisible if $self->{current} && $self->{visible};
3969
3965 $self->{current} = $widget; 3970 if (($self->{current} = $widget)) {
3971 $self->{current}->set_visible if $self->{current} && $self->{visible};
3966 $self->{current}->configure (0, 0, $self->{w}, $self->{h}); 3972 $self->{current}->configure (0, 0, $self->{w}, $self->{h});
3967 3973
3968 $self->emit (page_changed => $self->{current}); 3974 $self->emit (page_changed => $self->{current});
3975 }
3969 3976
3970 $self->realloc; 3977 $self->realloc;
3971} 3978}
3972 3979
3973sub visible_children { 3980sub visible_children {
3974 $_[0]{current} 3981 $_[0]{current} || ()
3975} 3982}
3976 3983
3977sub size_request { 3984sub size_request {
3978 my ($self) = @_; 3985 my ($self) = @_;
3979 3986
3987 $self->{current}
3980 $self->{current}->size_request 3988 ? $self->{current}->size_request
3989 : (0, 0)
3981} 3990}
3982 3991
3983sub invoke_size_allocate { 3992sub invoke_size_allocate {
3984 my ($self, $w, $h) = @_; 3993 my ($self, $w, $h) = @_;
3985 3994
3986 $self->{current}->configure (0, 0, $w, $h); 3995 $self->{current}->configure (0, 0, $w, $h)
3996 if $self->{current};
3987 3997
3988 1 3998 1
3989} 3999}
3990 4000
3991sub _draw { 4001sub _draw {
3992 my ($self) = @_; 4002 my ($self) = @_;
3993 4003
3994 $self->{current}->draw; 4004 $self->{current}->draw
4005 if $self->{current};
3995} 4006}
3996 4007
3997############################################################################# 4008#############################################################################
3998 4009
3999package DC::UI::Notebook; 4010package DC::UI::Notebook;
4209 $self 4220 $self
4210} 4221}
4211 4222
4212sub reorder { 4223sub reorder {
4213 my ($self) = @_; 4224 my ($self) = @_;
4214 my $NOW = Time::HiRes::time; 4225 my $NOW = EV::time;
4215 4226
4216 # freeze display when hovering over any label 4227 # freeze display when hovering over any label
4217 return if $DC::UI::TOOLTIP->{owner} 4228 return if $DC::UI::TOOLTIP->{owner}
4218 && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, 4229 && grep $DC::UI::TOOLTIP->{owner} == $_->{label},
4219 values %{ $self->{item} }; 4230 values %{ $self->{item} };
4269 $label->{fg}[3] = $item->{fg}[3] || 1; 4280 $label->{fg}[3] = $item->{fg}[3] || 1;
4270 } 4281 }
4271 4282
4272 push @widgets, $label; 4283 push @widgets, $label;
4273 } 4284 }
4285
4286 my $hash = join ",", @widgets;
4287 return if $hash eq $self->{last_widget_hash};
4288 $self->{last_widget_hash} = $hash;
4274 4289
4275 $self->clear; 4290 $self->clear;
4276 $self->SUPER::add (reverse @widgets); 4291 $self->SUPER::add (reverse @widgets);
4277} 4292}
4278 4293

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines