--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/10 22:53:49 1.57 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 12:21:29 1.58 @@ -36,7 +36,7 @@ $BUTTON_STATE |= 1 << ($ev->button - 1); - $GRAB->button_down ($ev) if $GRAB; + $GRAB->button_down ($ev, $GRAB->translate ($x, $y)) if $GRAB; } sub feed_sdl_button_up_event { @@ -47,6 +47,8 @@ $BUTTON_STATE &= ~(1 << ($ev->button - 1)); + $GRAB->button_down ($ev, $GRAB->translate ($x, $y)) if $GRAB; + if (!$BUTTON_STATE) { my $grab = $GRAB; undef $GRAB; $grab->update if $grab; @@ -67,7 +69,7 @@ $HOVER->update if $HOVER; } - $HOVER->mouse_motion ($ev) if $HOVER; + $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; } sub new { @@ -99,6 +101,13 @@ $self->{h} = $h; } +# translate global koordinates to local coordinate system +sub translate { + my ($self, $x, $y) = @_; + + $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); +} + sub focus_in { my ($self) = @_; @@ -710,7 +719,6 @@ substr $text, -1, 1, ''; } elsif ($uni) { $text .= chr $uni; - print "$uni <$text>\n";#d# } $self->set_text ($text); @@ -722,6 +730,11 @@ $self->focus_in; } +sub mouse_motion { + my ($self, $ev, $x, $y) = @_; + printf "M %d,%d %d,%d\n", $ev->motion_x, $ev->motion_y, $x, $y;#d# +} + sub _draw { my ($self) = @_; @@ -925,8 +938,6 @@ sub animate { my ($self, $interval) = @_; - printf "%5.2f\n", 1 / $interval if $interval;#d# - $self->{time} -= $interval * $self->{speed}; if ($self->{time} <= 0) { $self->{time} = 0; @@ -967,6 +978,12 @@ for @{$self->{children}}; } +sub translate { + my ($self, $x, $y) = @_; + + ($x, $y) +} + sub update { my ($self) = @_;