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.325 by root, Thu Jul 13 01:29:17 2006 UTC vs.
Revision 1.329 by root, Sun Jul 23 02:44:06 2006 UTC

452 452
453 $FOCUS->emit ("focus_out") if $FOCUS; 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 { 0 }
458sub invoke_button_up { 1 } 458sub invoke_button_up { 0 }
459sub invoke_key_down { 1 } 459sub invoke_key_down { 0 }
460sub invoke_key_up { 1 } 460sub invoke_key_up { 0 }
461 461
462sub invoke_button_down { 462sub invoke_button_down {
463 my ($self, $ev, $x, $y) = @_; 463 my ($self, $ev, $x, $y) = @_;
464 464
465 $self->grab_focus; 465 $self->grab_focus;
466 466
467 1 467 0
468} 468}
469 469
470sub connect { 470sub connect {
471 my ($self, $signal, $cb) = @_; 471 my ($self, $signal, $cb) = @_;
472 472
473 push @{ $self->{signal_cb}{$signal} }, $cb; 473 push @{ $self->{signal_cb}{$signal} }, $cb;
474} 474}
475 475
476sub emit { 476sub emit {
477 my ($self, $signal, @args) = @_; 477 my ($self, $signal, @args) = @_;
478
479 #warn +(caller(1))[3] . "emit $signal on $self (parent $self->{parent})\n";#d#
478 480
479 #d##TODO# stop propagating at first true, do not use sum 481 #d##TODO# stop propagating at first true, do not use sum
480 (List::Util::sum map $_->($self, @args), @{$self->{signal_cb}{$signal} || []}) # before 482 (List::Util::sum map $_->($self, @args), @{$self->{signal_cb}{$signal} || []}) # before
481 || ($self->can ("invoke_$signal") || sub { 1 })->($self, @args) # closure 483 || ($self->can ("invoke_$signal") || sub { 1 })->($self, @args) # closure
482 || ($self->{parent} && $self->{parent}->emit ($signal, @args)) # parent 484 || ($self->{parent} && $self->{parent}->emit ($signal, @args)) # parent
996 my ($self, $widget) = @_; 998 my ($self, $widget) = @_;
997 999
998 $self->{vp}->add ($self->{child} = $widget); 1000 $self->{vp}->add ($self->{child} = $widget);
999} 1001}
1000 1002
1003sub invoke_button_up {
1004 my ($self, $ev) = @_;
1005
1006 warn "button up $ev->{button}\n";#d#
1007
1008 0
1009}
1010
1001sub update_slider { 1011sub update_slider {
1002 my ($self) = @_; 1012 my ($self) = @_;
1003 1013
1004 $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $self->{vp}->child->{h}, $self->{vp}{h}, 1]); 1014 $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $self->{vp}->child->{h}, $self->{vp}{h}, 1]);
1005} 1015}
1082 my $self = $class->SUPER::new ( 1092 my $self = $class->SUPER::new (
1083 bg => [1, 1, 1, 1], 1093 bg => [1, 1, 1, 1],
1084 border_bg => [1, 1, 1, 1], 1094 border_bg => [1, 1, 1, 1],
1085 border => 0.6, 1095 border => 0.6,
1086 can_events => 1, 1096 can_events => 1,
1087 min_w => 16, 1097 min_w => 64,
1088 min_h => 16, 1098 min_h => 32,
1089 %arg, 1099 %arg,
1090 ); 1100 );
1091 1101
1092 $self->{title_widget} = new CFClient::UI::Label 1102 $self->{title_widget} = new CFClient::UI::Label
1093 align => 0, 1103 align => 0,
2118 my $self = $class->SUPER::new ( 2128 my $self = $class->SUPER::new (
2119 can_events => 0, 2129 can_events => 0,
2120 @_, 2130 @_,
2121 ); 2131 );
2122 2132
2123 $self->{path} 2133 $self->{path} || $self->{tex}
2124 or Carp::croak "required attribute 'path' not set"; 2134 or Carp::croak "'path' or 'tex' attributes required";
2125 2135
2126 $self->{tex} = $texture_cache{$self->{path}} ||= 2136 $self->{tex} ||= $texture_cache{$self->{path}} ||=
2127 new_from_file CFClient::Texture CFClient::find_rcfile $self->{path}, mipmap => 1; 2137 new_from_file CFClient::Texture CFClient::find_rcfile $self->{path}, mipmap => 1;
2128 2138
2129 Scalar::Util::weaken $texture_cache{$self->{path}}; 2139 Scalar::Util::weaken $texture_cache{$self->{path}};
2130 2140
2131 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; 2141 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h};
3816 my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; 3826 my ($w, $h) = @$widget{qw(alloc_w alloc_h)};
3817 3827
3818 $w = 0 if $w < 0; 3828 $w = 0 if $w < 0;
3819 $h = 0 if $h < 0; 3829 $h = 0 if $h < 0;
3820 3830
3831 $w = max $widget->{min_w}, $w;
3832 $h = max $widget->{min_h}, $h;
3833
3834 $w = min $widget->{max_w}, $w if exists $widget->{max_w};
3835 $h = min $widget->{max_h}, $h if exists $widget->{max_h};
3836
3821 $w = int $w + 0.5; 3837 $w = int $w + 0.5;
3822 $h = int $h + 0.5; 3838 $h = int $h + 0.5;
3823 3839
3824 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { 3840 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) {
3825 $widget->{old_w} = $widget->{w}; 3841 $widget->{old_w} = $widget->{w};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines