… | |
… | |
986 | } |
986 | } |
987 | |
987 | |
988 | sub set_offset { |
988 | sub set_offset { |
989 | my ($self, $x, $y) = @_; |
989 | my ($self, $x, $y) = @_; |
990 | |
990 | |
991 | $self->{view_x} = max 0, min $self->child->{w} - $self->{w}, int $x; |
991 | my $x = max 0, min $self->child->{w} - $self->{w}, int $x; |
992 | $self->{view_y} = max 0, min $self->child->{h} - $self->{h}, int $y; |
992 | my $y = max 0, min $self->child->{h} - $self->{h}, int $y; |
993 | |
993 | |
994 | $self->emit (changed => $self->{view_x}, $self->{view_y}); |
994 | if ($x != $self->{view_x} or $y != $self->{view_y}) { |
|
|
995 | $self->{view_x} = $x; |
|
|
996 | $self->{view_y} = $y; |
|
|
997 | |
|
|
998 | $self->emit (changed => $x, $y); |
995 | $self->update; |
999 | $self->update; |
|
|
1000 | } |
996 | } |
1001 | } |
997 | |
1002 | |
998 | # hmm, this does not work for topleft of $self... but we should not ask for that |
1003 | # hmm, this does not work for topleft of $self... but we should not ask for that |
999 | sub coord2local { |
1004 | sub coord2local { |
1000 | my ($self, $x, $y) = @_; |
1005 | my ($self, $x, $y) = @_; |
… | |
… | |
1080 | expand => 1, |
1085 | expand => 1, |
1081 | scroll_x => $self->{scroll_x}, |
1086 | scroll_x => $self->{scroll_x}, |
1082 | scroll_y => $self->{scroll_y}, |
1087 | scroll_y => $self->{scroll_y}, |
1083 | on_changed => sub { |
1088 | on_changed => sub { |
1084 | my ($vp, $x, $y) = @_; |
1089 | my ($vp, $x, $y) = @_; |
|
|
1090 | |
1085 | $vp->{parent}{hslider}->set_value ($x); |
1091 | $vp->{parent}{hslider}->set_value ($x); |
1086 | $vp->{parent}{vslider}->set_value ($y); |
1092 | $vp->{parent}{vslider}->set_value ($y); |
1087 | |
1093 | |
1088 | 0 |
1094 | 0 |
1089 | }, |
1095 | }, |
… | |
… | |
2375 | |
2381 | |
2376 | use CFPlus::OpenGL; |
2382 | use CFPlus::OpenGL; |
2377 | |
2383 | |
2378 | my @tex = |
2384 | my @tex = |
2379 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2385 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2380 | qw(b1_button_active.png); |
2386 | qw(b1_button_inactive.png b1_button_active.png); |
2381 | |
2387 | |
2382 | sub new { |
2388 | sub new { |
2383 | my $class = shift; |
2389 | my $class = shift; |
2384 | |
2390 | |
2385 | $class->SUPER::new ( |
2391 | $class->SUPER::new ( |
2386 | padding_x => 4, |
2392 | padding_x => 4, |
2387 | padding_y => 4, |
2393 | padding_y => 4, |
2388 | fg => [1, 1, 1], |
2394 | fg => [1.0, 1.0, 1.0], |
2389 | active_fg => [0, 0, 1], |
2395 | active_fg => [0.8, 0.8, 0.8], |
2390 | can_hover => 1, |
2396 | can_hover => 1, |
2391 | align => 0, |
2397 | align => 0, |
2392 | valign => 0, |
2398 | valign => 0, |
2393 | can_events => 1, |
2399 | can_events => 1, |
2394 | @_ |
2400 | @_ |
… | |
… | |
2412 | |
2418 | |
2413 | glEnable GL_TEXTURE_2D; |
2419 | glEnable GL_TEXTURE_2D; |
2414 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2420 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2415 | glColor 0, 0, 0, 1; |
2421 | glColor 0, 0, 0, 1; |
2416 | |
2422 | |
|
|
2423 | my $tex = $tex[$GRAB == $self]; |
2417 | $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2424 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2418 | |
2425 | |
2419 | glDisable GL_TEXTURE_2D; |
2426 | glDisable GL_TEXTURE_2D; |
2420 | |
2427 | |
2421 | $self->SUPER::_draw; |
2428 | $self->SUPER::_draw; |
2422 | } |
2429 | } |
… | |
… | |
3487 | ); |
3494 | ); |
3488 | |
3495 | |
3489 | if ($self->{anim} && $self->{animspeed}) { |
3496 | if ($self->{anim} && $self->{animspeed}) { |
3490 | CFPlus::weaken (my $widget = $self); |
3497 | CFPlus::weaken (my $widget = $self); |
3491 | |
3498 | |
|
|
3499 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
|
|
3500 | $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed}; |
3492 | $self->{timer} = Event->timer ( |
3501 | $self->{timer} = Event->timer ( |
3493 | at => $self->{animspeed} * int $::NOW / $self->{animspeed}, |
|
|
3494 | hard => 1, |
3502 | parked => 1, |
3495 | interval => $self->{animspeed}, |
|
|
3496 | cb => sub { |
3503 | cb => sub { |
3497 | return unless $::CONN; |
3504 | return unless $::CONN && $widget; |
3498 | |
3505 | |
3499 | ++$widget->{frame}; |
3506 | ++$widget->{frame}; |
3500 | $self->update_face; |
3507 | $widget->update_face; |
3501 | $self->update; |
3508 | $widget->update; |
|
|
3509 | |
|
|
3510 | $widget->update_timer; |
3502 | }, |
3511 | }, |
3503 | ); |
3512 | ); |
3504 | |
3513 | |
3505 | $self->update_face; |
3514 | $self->update_face; |
|
|
3515 | $self->update_timer; |
3506 | } |
3516 | } |
3507 | |
3517 | |
3508 | $self |
3518 | $self |
|
|
3519 | } |
|
|
3520 | |
|
|
3521 | sub update_timer { |
|
|
3522 | my ($self) = @_; |
|
|
3523 | |
|
|
3524 | return unless $self->{timer}; |
|
|
3525 | |
|
|
3526 | if ($self->{visible}) { |
|
|
3527 | $self->{timer}->at ( |
|
|
3528 | $self->{anim_start} |
|
|
3529 | + $self->{animspeed} |
|
|
3530 | * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed} |
|
|
3531 | ); |
|
|
3532 | $self->{timer}->start; |
|
|
3533 | } else { |
|
|
3534 | $self->{timer}->stop; |
|
|
3535 | } |
3509 | } |
3536 | } |
3510 | |
3537 | |
3511 | sub update_face { |
3538 | sub update_face { |
3512 | my ($self) = @_; |
3539 | my ($self) = @_; |
3513 | |
3540 | |
… | |
… | |
3545 | return unless $self->{visible}; |
3572 | return unless $self->{visible}; |
3546 | |
3573 | |
3547 | $self->SUPER::update; |
3574 | $self->SUPER::update; |
3548 | } |
3575 | } |
3549 | |
3576 | |
|
|
3577 | sub invoke_visibility_change { |
|
|
3578 | my ($self) = @_; |
|
|
3579 | |
|
|
3580 | $self->update_timer; |
|
|
3581 | |
|
|
3582 | 0 |
|
|
3583 | } |
|
|
3584 | |
3550 | sub _draw { |
3585 | sub _draw { |
3551 | my ($self) = @_; |
3586 | my ($self) = @_; |
3552 | |
3587 | |
3553 | return unless $::CONN; |
3588 | return unless $::CONN; |
3554 | |
3589 | |
… | |
… | |
3569 | } |
3604 | } |
3570 | |
3605 | |
3571 | sub destroy { |
3606 | sub destroy { |
3572 | my ($self) = @_; |
3607 | my ($self) = @_; |
3573 | |
3608 | |
3574 | $self->{timer}->cancel |
3609 | (delete $self->{timer})->cancel |
3575 | if $self->{timer}; |
3610 | if $self->{timer}; |
3576 | |
3611 | |
3577 | $self->SUPER::destroy; |
3612 | $self->SUPER::destroy; |
3578 | } |
3613 | } |
3579 | |
3614 | |
… | |
… | |
4223 | while ($self->{post_alloc_hook}) { |
4258 | while ($self->{post_alloc_hook}) { |
4224 | $_->() |
4259 | $_->() |
4225 | for values %{delete $self->{post_alloc_hook}}; |
4260 | for values %{delete $self->{post_alloc_hook}}; |
4226 | } |
4261 | } |
4227 | |
4262 | |
4228 | |
|
|
4229 | glViewport 0, 0, $::WIDTH, $::HEIGHT; |
4263 | glViewport 0, 0, $::WIDTH, $::HEIGHT; |
4230 | glClearColor +($::CFG->{fow_intensity}) x 3, 1; |
4264 | glClearColor +($::CFG->{fow_intensity}) x 3, 1; |
4231 | glClear GL_COLOR_BUFFER_BIT; |
4265 | glClear GL_COLOR_BUFFER_BIT; |
4232 | |
4266 | |
4233 | glMatrixMode GL_PROJECTION; |
4267 | glMatrixMode GL_PROJECTION; |