From 446d1862e1502d307dd9b9a76aa51d786001dfb5 Mon Sep 17 00:00:00 2001 From: merlin Date: Mon, 26 Nov 2007 08:48:22 +0000 Subject: traitement de la propriete visible du comportement --- src/MTools/Comp/MReconizer.pm | 61 +++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 25 deletions(-) (limited to 'src/MTools') diff --git a/src/MTools/Comp/MReconizer.pm b/src/MTools/Comp/MReconizer.pm index f30ec20..bb59bae 100644 --- a/src/MTools/Comp/MReconizer.pm +++ b/src/MTools/Comp/MReconizer.pm @@ -52,12 +52,13 @@ sub new { bless $self, $class; $button = 1 if ! defined $button; - + $self -> recordEvent ('RELEASED'); $self -> recordEvent ('RECONIZED'); $self -> recordEvent ('START_GESTURE_RECO'); $self -> recordProperty ('animation_duration', 0.5); $self -> recordProperty ('color', 'blue'); $self -> recordProperty ('callback', undef); + $self -> recordProperty ('-visible', 1); $self -> mconfigure (%options); binding ($src, "", [\&__pressed, $self, Ev('x'), Ev('y')]); @@ -79,9 +80,9 @@ sub new { $self -> {__fleche} = $zinc -> add ('curve', minstance($dessin), [[0,0],[0,0]], -linecolor => 'blue', -linewidth => 2, - -priority => 10, - -visible => 1, - -sensitive => 0, + -priority => 10, + -visible => 1, + -sensitive => 0, ); $self -> {__anim__disparition} = new MTools::Anim::MOpacity ( @@ -108,39 +109,49 @@ sub __clear () { sub __pressed { my ($self, $x, $y) = @_; - raise($self -> {__dessin}); - ($x, $y) = $zinc -> transform('device', minstance ($self -> {__dessin}), [$x, $y]); - if (defined $self -> {__dessin}) - { - push (@{$self -> {__points}}, [$x, $y]); + if ($self -> mget ('-visible')) { + raise ($self -> {__dessin}); + ($x, $y) = $zinc -> transform ('device', minstance ($self -> {__dessin}), [$x, $y]); + if (defined $self -> {__dessin}) + { + push (@{$self -> {__points}}, [$x, $y]); + } + $self -> notify ('START_GESTURE_RECO', $x, $y); } - $self -> notify ('START_GESTURE_RECO', $x, $y); } sub __moved { my ($self, $x, $y) = @_; - ($x, $y) = $zinc -> transform('device', minstance ($self -> {__dessin}), [$x, $y]); - push (@{$self -> {trace}},$x,$y); + if ($self -> mget ('-visible')) { + ($x, $y) = $zinc -> transform('device', minstance ($self -> {__dessin}), [$x, $y]); + push (@{$self -> {trace}},$x,$y); - if (defined $self -> {__dessin}) - { - push (@{$self -> {__points}}, [$x, $y]); - my @pts = @{$self -> {__points}}; - $zinc -> coords ($self -> {__fleche}, 0, \@pts); + if (defined $self -> {__dessin}) + { + push (@{$self -> {__points}}, [$x, $y]); + my @pts = @{$self -> {__points}}; + $zinc -> coords ($self -> {__fleche}, 0, \@pts); + } } } sub __released { my ($self, $x, $y) = @_; - - my ($gesture,$explanation) = AnalyzeGesture(@{$self -> {trace}}); - $self -> {trace} = (); - $self -> notify ('RECONIZED', $gesture, $explanation); - - if (defined $self -> {__dessin}) - { - $self -> {__anim__disparition} -> start (); + + if ($self -> mget ('-visible')) { + my ($gesture, $explanation) = AnalyzeGesture (@{$self -> {trace}}); + $self -> {trace} = (); + $self -> notify ('RECONIZED', $gesture, $explanation); + if (defined $self -> {__dessin}) + { + $self -> {__anim__disparition} -> start (); + } + } + else { + $self -> notify ('RELEASED', $x, $y); + $self -> __clear (); } + } sub getpoints { my ($self) = @_; -- cgit v1.1