From bd873b641bcd5221eb3f3f27dcf920a82c2e113b Mon Sep 17 00:00:00 2001 From: etienne Date: Mon, 18 Mar 2002 13:29:33 +0000 Subject: Modif interaction pour visualiser un item (appui maintenu sur bouton correspondant) Mini maj doc. --- Perl/Zinc/Debug.pm | 65 +++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) (limited to 'Perl') diff --git a/Perl/Zinc/Debug.pm b/Perl/Zinc/Debug.pm index 937653c..52e7cc2 100644 --- a/Perl/Zinc/Debug.pm +++ b/Perl/Zinc/Debug.pm @@ -27,6 +27,7 @@ my ($text_id, $rectangle_id); my ($x0, $y0); my $zinc; + sub finditems { $zinc = shift; # options @@ -204,9 +205,9 @@ sub showgroupattributes { my ($option, $value) = (@$elem)[0,4]; $fm->Label(-text => $option, -relief => 'ridge') ->grid(-row => $r, -col => 1, -ipady => 10, -ipadx => 5, -sticky => 'nswe'); - if ($option eq '-tags') { + if ($option and $option eq '-tags') { $value = join("\n", @$value); - } elsif ($option eq '-clip' and $value > 0) { + } elsif ($option and $option eq '-clip' and $value > 0) { $value .= " (". $zinc->type($value) .")"; } $fm->Label(-text => $value, -relief => 'ridge') @@ -236,14 +237,16 @@ sub showgroupcontent { -command => sub {$tl->destroy})->pack; } -# highlight an item (by hiding other found items) +# highlight an item (by cloning it and hiding other found items) +# why cloning? because we can't simply make visible an item which +# belongs to an invisible group. sub highlightitem { - my ($zinc, $item) = @_; + my ($btn, $zinc, $item) = @_; return if $showitemflag; $showitemflag = 1; - my @visibility; - my @itemstohide; + my @itemstohide = (); + my @visibility = (); for ($zinc->find('overlap', $zinc->coords($rectangle_id))) { push (@itemstohide, $_) unless $_ == $rectangle_id or $_ == $text_id; } @@ -256,39 +259,22 @@ sub highlightitem { $zinc->chggroup($clone, 1); $zinc->coords($clone, [$zinc->transform(scalar $zinc->group($item), 1, [@coords])]); $zinc->raise($clone); + $btn->bind('', [\&undohighlightitem, $zinc, $clone, + \@itemstohide, \@visibility]); - $zinc->after(500, sub { - for (my $i=0; $i < @itemstohide; $i++) { - $zinc->itemconfigure($itemstohide[$i], -visible => $visibility[$i]); - } - $zinc->remove($clone); - $showitemflag = 0; - }); } -# highlight an item (by hiding other found items) -# here, item's option -visible is set to 1 and others items are -# hidden; but, if item belongs to a invisible group, we can't -# see it! -sub highlightitem_old { - my ($zinc, $item, $items) = @_; - return if $showitemflag; - $showitemflag = 1; - my @visibility; - for (@$items) { - push(@visibility, scalar $zinc->itemcget($_, -visible)); - $zinc->itemconfigure($_, -visible => 0); +sub undohighlightitem { + my ($btn, $zinc, $clone, $itemstohide, $visibility) = @_; + $btn->bind('ReleaseButton', ''); + for (my $i=0; $i < @$itemstohide; $i++) { + $zinc->itemconfigure($itemstohide->[$i], -visible => $visibility->[$i]); } - $zinc->itemconfigure($item, -visible => 1); - - $zinc->after(500, sub { - for (my $i=0; $i < @$items; $i++) { - $zinc->itemconfigure($items->[$i], -visible => $visibility[$i]); - } - $showitemflag = 0; - }); + $zinc->remove($clone); + $showitemflag = 0; } + # display complete help screen sub showhelp { my ($w, $ekb, $okb) = @_; @@ -347,10 +333,11 @@ sub showattributes { &showbanner($fm, $i++); for my $item (@$items) { # id - $fm->Button(-text => $item, - -foreground => 'red', - -command => [\&highlightitem, $zinc, $item]) - ->grid(-row => $i, -col => 1, -sticky => 'nswe', -ipadx => 5); + my $idbtn = + $fm->Button(-text => $item, + -foreground => 'red' + )->grid(-row => $i, -col => 1, -sticky => 'nswe', -ipadx => 5); + $idbtn->bind('<1>', [\&highlightitem, $zinc, $item]); # type my $type = $zinc->type($item); if ($type eq 'group') { @@ -526,7 +513,9 @@ ZincDebug - a perl module for analysing a Zinc application. ZincDebug provides an interface to help developers to debug or analyse Zinc applications. -With B function, you are able to scan all items which are enclosed in a rectangular area you have first drawn, or all items which overlap it. Result is a Tk table which presents details (options, coordinates, ...) about found items; you can also highlight a particular item, even if it's not visible. +With B function, you are able to scan all items which are enclosed in a rectangular area you have first drawn by drag & drop, or all items which overlap it. Result is a Tk table which presents details (options, coordinates, ...) about found items; you can also highlight a particular item, even if it's not visible, by clicking on its corresponding button in the table. + +Press Escape key in the main window of the application to have some help about available input sequences. =head1 FUNCTIONS -- cgit v1.1