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.57 by root, Mon Apr 10 22:53:49 2006 UTC vs.
Revision 1.58 by root, Tue Apr 11 12:21:29 2006 UTC

34 $GRAB->update if $GRAB; 34 $GRAB->update if $GRAB;
35 } 35 }
36 36
37 $BUTTON_STATE |= 1 << ($ev->button - 1); 37 $BUTTON_STATE |= 1 << ($ev->button - 1);
38 38
39 $GRAB->button_down ($ev) if $GRAB; 39 $GRAB->button_down ($ev, $GRAB->translate ($x, $y)) if $GRAB;
40} 40}
41 41
42sub feed_sdl_button_up_event { 42sub feed_sdl_button_up_event {
43 my ($ev) = @_; 43 my ($ev) = @_;
44 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 44 my ($x, $y) = ($ev->motion_x, $ev->motion_y);
45 45
46 my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y); 46 my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y);
47 47
48 $BUTTON_STATE &= ~(1 << ($ev->button - 1)); 48 $BUTTON_STATE &= ~(1 << ($ev->button - 1));
49
50 $GRAB->button_down ($ev, $GRAB->translate ($x, $y)) if $GRAB;
49 51
50 if (!$BUTTON_STATE) { 52 if (!$BUTTON_STATE) {
51 my $grab = $GRAB; undef $GRAB; 53 my $grab = $GRAB; undef $GRAB;
52 $grab->update if $grab; 54 $grab->update if $grab;
53 $GRAB->update if $GRAB; 55 $GRAB->update if $GRAB;
65 67
66 $hover->update if $hover; 68 $hover->update if $hover;
67 $HOVER->update if $HOVER; 69 $HOVER->update if $HOVER;
68 } 70 }
69 71
70 $HOVER->mouse_motion ($ev) if $HOVER; 72 $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER;
71} 73}
72 74
73sub new { 75sub new {
74 my $class = shift; 76 my $class = shift;
75 77
95sub size_allocate { 97sub size_allocate {
96 my ($self, $w, $h) = @_; 98 my ($self, $w, $h) = @_;
97 99
98 $self->{w} = $w; 100 $self->{w} = $w;
99 $self->{h} = $h; 101 $self->{h} = $h;
102}
103
104# translate global koordinates to local coordinate system
105sub translate {
106 my ($self, $x, $y) = @_;
107
108 $self->{parent}->translate ($x - $self->{x}, $y - $self->{y});
100} 109}
101 110
102sub focus_in { 111sub focus_in {
103 my ($self) = @_; 112 my ($self) = @_;
104 113
708 717
709 if ($sym == SDLK_BACKSPACE) { 718 if ($sym == SDLK_BACKSPACE) {
710 substr $text, -1, 1, ''; 719 substr $text, -1, 1, '';
711 } elsif ($uni) { 720 } elsif ($uni) {
712 $text .= chr $uni; 721 $text .= chr $uni;
713 print "$uni <$text>\n";#d#
714 } 722 }
715 723
716 $self->set_text ($text); 724 $self->set_text ($text);
717} 725}
718 726
719sub button_down { 727sub button_down {
720 my ($self, $ev) = @_; 728 my ($self, $ev) = @_;
721 729
722 $self->focus_in; 730 $self->focus_in;
731}
732
733sub mouse_motion {
734 my ($self, $ev, $x, $y) = @_;
735 printf "M %d,%d %d,%d\n", $ev->motion_x, $ev->motion_y, $x, $y;#d#
723} 736}
724 737
725sub _draw { 738sub _draw {
726 my ($self) = @_; 739 my ($self) = @_;
727 740
923} 936}
924 937
925sub animate { 938sub animate {
926 my ($self, $interval) = @_; 939 my ($self, $interval) = @_;
927 940
928 printf "%5.2f\n", 1 / $interval if $interval;#d#
929
930 $self->{time} -= $interval * $self->{speed}; 941 $self->{time} -= $interval * $self->{speed};
931 if ($self->{time} <= 0) { 942 if ($self->{time} <= 0) {
932 $self->{time} = 0; 943 $self->{time} = 0;
933 ::animation_stop $self; 944 ::animation_stop $self;
934 } 945 }
965 976
966 $_->size_allocate ($_->size_request) 977 $_->size_allocate ($_->size_request)
967 for @{$self->{children}}; 978 for @{$self->{children}};
968} 979}
969 980
981sub translate {
982 my ($self, $x, $y) = @_;
983
984 ($x, $y)
985}
986
970sub update { 987sub update {
971 my ($self) = @_; 988 my ($self) = @_;
972 989
973 $self->size_allocate ($self->size_request); 990 $self->size_allocate ($self->size_request);
974 ::refresh (); 991 ::refresh ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines