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.316 by root, Sun Jul 2 13:57:58 2006 UTC vs.
Revision 1.319 by root, Sun Jul 2 21:07:26 2006 UTC

423 my ($self) = @_; 423 my ($self) = @_;
424 424
425 return if $FOCUS == $self; 425 return if $FOCUS == $self;
426 return unless $self->{can_focus}; 426 return unless $self->{can_focus};
427 427
428 my $focus = $FOCUS; $FOCUS = $self; 428 $FOCUS = $self;
429 429
430 $focus->update if $focus; 430 $self->update;
431 $FOCUS->update;
432 431
433 0 432 0
434} 433}
435 434
436sub invoke_focus_out { 435sub invoke_focus_out {
437 my ($self) = @_; 436 my ($self) = @_;
438 437
439 return unless $FOCUS == $self; 438 return unless $FOCUS == $self;
440 439
441 my $focus = $FOCUS; undef $FOCUS; 440 undef $FOCUS;
442 441
443 $focus->update if $focus; #? 442 $self->update;
444 443
445 $::MAPWIDGET->grab_focus #d# focus mapwidget if no other widget has focus 444 $::MAPWIDGET->grab_focus #d# focus mapwidget if no other widget has focus
446 unless $FOCUS; 445 unless $FOCUS;
447 446
448 0 447 0
449} 448}
450 449
451sub grab_focus { 450sub grab_focus {
452 my ($self) = @_; 451 my ($self) = @_;
453 452
453 $FOCUS->emit ("focus_out") if $FOCUS;
454 $self->emit ("focus_in"); 454 $self->emit ("focus_in");
455} 455}
456 456
457sub invoke_mouse_motion { 1 } 457sub invoke_mouse_motion { 1 }
458sub invoke_button_up { 1 } 458sub invoke_button_up { 1 }
1096 1096
1097 if ($self->{has_close_button}) { 1097 if ($self->{has_close_button}) {
1098 $self->{close_button} = 1098 $self->{close_button} =
1099 new CFClient::UI::ImageButton 1099 new CFClient::UI::ImageButton
1100 path => 'x1_close.png', 1100 path => 'x1_close.png',
1101 on_activate => sub { $self->hide }; 1101 on_activate => sub { $self->emit ("delete") };
1102 1102
1103 $self->CFClient::UI::Container::add ($self->{close_button}); 1103 $self->CFClient::UI::Container::add ($self->{close_button});
1104 } 1104 }
1105 1105
1106 $self 1106 $self
1152 $self->child->configure ($border, $border, $w, $h); 1152 $self->child->configure ($border, $border, $w, $h);
1153 1153
1154 $self->{close_button}->configure ($self->{w} - $border, 0, $border, $border) 1154 $self->{close_button}->configure ($self->{w} - $border, 0, $border, $border)
1155 if $self->{close_button}; 1155 if $self->{close_button};
1156 1156
1157 1
1158}
1159
1160sub invoke_delete {
1161 my ($self) = @_;
1162
1163 $self->hide;
1164
1157 1 1165 1
1158} 1166}
1159 1167
1160sub invoke_button_down { 1168sub invoke_button_down {
1161 my ($self, $ev, $x, $y) = @_; 1169 my ($self, $ev, $x, $y) = @_;
2060 my ($self) = @_; 2068 my ($self) = @_;
2061 2069
2062 (6) x 2 2070 (6) x 2
2063} 2071}
2064 2072
2073sub toggle {
2074 my ($self) = @_;
2075
2076 $self->{state} = !$self->{state};
2077 $self->emit (changed => $self->{state});
2078 $self->update;
2079}
2080
2065sub invoke_button_down { 2081sub invoke_button_down {
2066 my ($self, $ev, $x, $y) = @_; 2082 my ($self, $ev, $x, $y) = @_;
2067 2083
2068 if ($x >= $self->{padding_x} && $x < $self->{w} - $self->{padding_x} 2084 if ($x >= $self->{padding_x} && $x < $self->{w} - $self->{padding_x}
2069 && $y >= $self->{padding_y} && $y < $self->{h} - $self->{padding_y}) { 2085 && $y >= $self->{padding_y} && $y < $self->{h} - $self->{padding_y}) {
2070 $self->{state} = !$self->{state}; 2086 $self->toggle;
2071 $self->emit (changed => $self->{state});
2072 } else { 2087 } else {
2073 return 0 2088 return 0
2074 } 2089 }
2075 2090
2076 1 2091 1
2247 my $ycut1 = max 0, min 1, $ycut; 2262 my $ycut1 = max 0, min 1, $ycut;
2248 my $ycut2 = max 0, min 1, $ycut - 1; 2263 my $ycut2 = max 0, min 1, $ycut - 1;
2249 2264
2250 my $h1 = $self->{h} * (1 - $ycut1); 2265 my $h1 = $self->{h} * (1 - $ycut1);
2251 my $h2 = $self->{h} * (1 - $ycut2); 2266 my $h2 = $self->{h} * (1 - $ycut2);
2267 my $h3 = $self->{h};
2268
2269 $_ = $_ * (284-4)/288 + 4/288 for ($h1, $h2, $h3);
2252 2270
2253 glEnable GL_BLEND; 2271 glEnable GL_BLEND;
2254 glBlendFuncSeparate GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 2272 glBlendFuncSeparate GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
2255 GL_ONE, GL_ONE_MINUS_SRC_ALPHA; 2273 GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
2256 glEnable GL_TEXTURE_2D; 2274 glEnable GL_TEXTURE_2D;
2275 2293
2276 if ($t3) { 2294 if ($t3) {
2277 glBindTexture GL_TEXTURE_2D, $t3->{name}; 2295 glBindTexture GL_TEXTURE_2D, $t3->{name};
2278 glBegin GL_QUADS; 2296 glBegin GL_QUADS;
2279 glTexCoord 0 , $t3->{t} * (1 - $ycut2); glVertex 0 , $h2; 2297 glTexCoord 0 , $t3->{t} * (1 - $ycut2); glVertex 0 , $h2;
2280 glTexCoord 0 , $t3->{t}; glVertex 0 , $self->{h}; 2298 glTexCoord 0 , $t3->{t}; glVertex 0 , $h3;
2281 glTexCoord $t3->{s}, $t3->{t}; glVertex $w, $self->{h}; 2299 glTexCoord $t3->{s}, $t3->{t}; glVertex $w, $h3;
2282 glTexCoord $t3->{s}, $t3->{t} * (1 - $ycut2); glVertex $w, $h2; 2300 glTexCoord $t3->{s}, $t3->{t} * (1 - $ycut2); glVertex $w, $h2;
2283 glEnd; 2301 glEnd;
2284 } 2302 }
2285 2303
2286 glDisable GL_BLEND; 2304 glDisable GL_BLEND;
3151 3169
3152 $self->{current} = $self->{children}[0] 3170 $self->{current} = $self->{children}[0]
3153 if @{ $self->{children} }; 3171 if @{ $self->{children} };
3154} 3172}
3155 3173
3174sub get_current_page {
3175 my ($self) = @_;
3176
3177 $self->{current}
3178}
3179
3156sub set_current_page { 3180sub set_current_page {
3157 my ($self, $page_or_widget) = @_; 3181 my ($self, $page_or_widget) = @_;
3158 3182
3159 my $widget = ref $page_or_widget 3183 my $widget = ref $page_or_widget
3160 ? $page_or_widget 3184 ? $page_or_widget
3224 tooltip => $tooltip, 3248 tooltip => $tooltip,
3225 on_activate => sub { $self->set_current_page ($widget) }, 3249 on_activate => sub { $self->set_current_page ($widget) },
3226 ); 3250 );
3227 3251
3228 $self->{multiplexer}->add ($widget); 3252 $self->{multiplexer}->add ($widget);
3253}
3254
3255sub get_current_page {
3256 my ($self) = @_;
3257
3258 $self->{multiplexer}->get_current_page
3229} 3259}
3230 3260
3231sub set_current_page { 3261sub set_current_page {
3232 my ($self, $page) = @_; 3262 my ($self, $page) = @_;
3233 3263
3438 3468
3439############################################################################# 3469#############################################################################
3440 3470
3441package CFClient::UI::Inventory; 3471package CFClient::UI::Inventory;
3442 3472
3443our @ISA = CFClient::UI::ScrolledWindow::; 3473our @ISA = CFClient::UI::Table::;
3444 3474
3445sub new { 3475sub new {
3446 my $class = shift; 3476 my $class = shift;
3447 3477
3448 my $self = $class->SUPER::new ( 3478 my $self = $class->SUPER::new (
3449 child => (new CFClient::UI::Table col_expand => [0, 1, 0]), 3479 col_expand => [0, 1, 0],
3450 @_, 3480 @_,
3451 ); 3481 );
3452 3482
3453 $self 3483 $self
3454} 3484}
3455 3485
3456sub set_items { 3486sub set_items {
3457 my ($self, $items) = @_; 3487 my ($self, $items) = @_;
3458 3488
3459 $self->{child}->clear; 3489 $self->clear;
3460 return unless $items; 3490 return unless $items;
3461 3491
3462 my @items = sort { 3492 my @items = sort {
3463 ($a->{type} <=> $b->{type}) 3493 ($a->{type} <=> $b->{type})
3464 or ($a->{name} cmp $b->{name}) 3494 or ($a->{name} cmp $b->{name})
3468 3498
3469 my $row = 0; 3499 my $row = 0;
3470 for my $item (@items) { 3500 for my $item (@items) {
3471 CFClient::Item::update_widgets $item; 3501 CFClient::Item::update_widgets $item;
3472 3502
3473 $self->{child}->add (0, $row, $item->{face_widget}); 3503 $self->add (0, $row, $item->{face_widget});
3474 $self->{child}->add (1, $row, $item->{desc_widget}); 3504 $self->add (1, $row, $item->{desc_widget});
3475 $self->{child}->add (2, $row, $item->{weight_widget}); 3505 $self->add (2, $row, $item->{weight_widget});
3476 3506
3477 $row++; 3507 $row++;
3478 } 3508 }
3479} 3509}
3480 3510

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines