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.323 by root, Wed Jul 5 03:01:01 2006 UTC vs.
Revision 1.328 by root, Sat Jul 22 13:43:05 2006 UTC

82} 82}
83 83
84sub feed_sdl_button_down_event { 84sub feed_sdl_button_down_event {
85 my ($ev) = @_; 85 my ($ev) = @_;
86 my ($x, $y) = ($ev->{x}, $ev->{y}); 86 my ($x, $y) = ($ev->{x}, $ev->{y});
87
88 warn "button down $ev->{button}\n";#d#
87 89
88 if (!$BUTTON_STATE) { 90 if (!$BUTTON_STATE) {
89 my $widget = $ROOT->find_widget ($x, $y); 91 my $widget = $ROOT->find_widget ($x, $y);
90 92
91 $GRAB = $widget; 93 $GRAB = $widget;
452 454
453 $FOCUS->emit ("focus_out") if $FOCUS; 455 $FOCUS->emit ("focus_out") if $FOCUS;
454 $self->emit ("focus_in"); 456 $self->emit ("focus_in");
455} 457}
456 458
457sub invoke_mouse_motion { 1 } 459sub invoke_mouse_motion { 0 }
458sub invoke_button_up { 1 } 460sub invoke_button_up { 0 }
459sub invoke_key_down { 1 } 461sub invoke_key_down { 0 }
460sub invoke_key_up { 1 } 462sub invoke_key_up { 0 }
461 463
462sub invoke_button_down { 464sub invoke_button_down {
463 my ($self, $ev, $x, $y) = @_; 465 my ($self, $ev, $x, $y) = @_;
464 466
465 $self->grab_focus; 467 $self->grab_focus;
466 468
469 warn "button down $ev->{button} $x $y\n";#d#
470
467 1 471 0
468} 472}
469 473
470sub connect { 474sub connect {
471 my ($self, $signal, $cb) = @_; 475 my ($self, $signal, $cb) = @_;
472 476
587} 591}
588 592
589sub DESTROY { 593sub DESTROY {
590 my ($self) = @_; 594 my ($self) = @_;
591 595
596 return if CFClient::in_destruct;
597
592 delete $WIDGET{$self+0}; 598 delete $WIDGET{$self+0};
593 599
594 eval { $self->destroy }; 600 eval { $self->destroy };
595 warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; 601 warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/;
596} 602}
994 my ($self, $widget) = @_; 1000 my ($self, $widget) = @_;
995 1001
996 $self->{vp}->add ($self->{child} = $widget); 1002 $self->{vp}->add ($self->{child} = $widget);
997} 1003}
998 1004
1005sub invoke_button_down {
1006 my ($self, $ev) = @_;
1007
1008 warn "button down $ev->{button}\n";#d#
1009
1010 0
1011}
1012
999sub update_slider { 1013sub update_slider {
1000 my ($self) = @_; 1014 my ($self) = @_;
1001 1015
1002 $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $self->{vp}->child->{h}, $self->{vp}{h}, 1]); 1016 $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $self->{vp}->child->{h}, $self->{vp}{h}, 1]);
1003} 1017}
1080 my $self = $class->SUPER::new ( 1094 my $self = $class->SUPER::new (
1081 bg => [1, 1, 1, 1], 1095 bg => [1, 1, 1, 1],
1082 border_bg => [1, 1, 1, 1], 1096 border_bg => [1, 1, 1, 1],
1083 border => 0.6, 1097 border => 0.6,
1084 can_events => 1, 1098 can_events => 1,
1085 min_w => 16, 1099 min_w => 64,
1086 min_h => 16, 1100 min_h => 32,
1087 %arg, 1101 %arg,
1088 ); 1102 );
1089 1103
1090 $self->{title_widget} = new CFClient::UI::Label 1104 $self->{title_widget} = new CFClient::UI::Label
1091 align => 0, 1105 align => 0,
1826 1840
1827 my $idx = $self->{layout}->xy_to_index ($x, $y); 1841 my $idx = $self->{layout}->xy_to_index ($x, $y);
1828 1842
1829 # byte-index to char-index 1843 # byte-index to char-index
1830 my $text = $self->{text}; 1844 my $text = $self->{text};
1831 utf8::encode $text; 1845 utf8::encode $text; $text = substr $text, 0, $idx; utf8::decode $text;
1832 $self->{cursor} = length substr $text, 0, $idx; 1846 $self->{cursor} = length $text;
1833 1847
1834 $self->_set_text ($self->{text}); 1848 $self->_set_text ($self->{text});
1835 $self->update; 1849 $self->update;
1836 1850
1837 1 1851 1
2116 my $self = $class->SUPER::new ( 2130 my $self = $class->SUPER::new (
2117 can_events => 0, 2131 can_events => 0,
2118 @_, 2132 @_,
2119 ); 2133 );
2120 2134
2121 $self->{path} 2135 $self->{path} || $self->{tex}
2122 or Carp::croak "required attribute 'path' not set"; 2136 or Carp::croak "'path' or 'tex' attributes required";
2123 2137
2124 $self->{tex} = $texture_cache{$self->{path}} ||= 2138 $self->{tex} ||= $texture_cache{$self->{path}} ||=
2125 new_from_file CFClient::Texture CFClient::find_rcfile $self->{path}, mipmap => 1; 2139 new_from_file CFClient::Texture CFClient::find_rcfile $self->{path}, mipmap => 1;
2126 2140
2127 Scalar::Util::weaken $texture_cache{$self->{path}}; 2141 Scalar::Util::weaken $texture_cache{$self->{path}};
2128 2142
2129 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; 2143 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h};
3814 my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; 3828 my ($w, $h) = @$widget{qw(alloc_w alloc_h)};
3815 3829
3816 $w = 0 if $w < 0; 3830 $w = 0 if $w < 0;
3817 $h = 0 if $h < 0; 3831 $h = 0 if $h < 0;
3818 3832
3833 $w = max $widget->{min_w}, $w;
3834 $h = max $widget->{min_h}, $h;
3835
3836 $w = min $widget->{max_w}, $w if exists $widget->{max_w};
3837 $h = min $widget->{max_h}, $h if exists $widget->{max_h};
3838
3819 $w = int $w + 0.5; 3839 $w = int $w + 0.5;
3820 $h = int $h + 0.5; 3840 $h = int $h + 0.5;
3821 3841
3822 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { 3842 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) {
3823 $widget->{old_w} = $widget->{w}; 3843 $widget->{old_w} = $widget->{w};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines