Here's a prototype/proof-of-concept for an ordinary screen.

I've written it in Perl/Tk and tested on Cygwin and Windows XP. It's basically a Text widget with lots of content. Moving the mouse around at (what I consider to be) normal speed does nothing; swiping the mouse horizontally, vertically or diagonally will scroll the window in the same direction.

You may need to tweak a few numbers:

Here's the code:

#!perl use strict; use warnings; use Time::HiRes qw{gettimeofday tv_interval}; use Tk; use constant { MAX_TIME_VARIATION => 0.01, X_MIN_DISTANCE_VARIATION => 25, Y_MIN_DISTANCE_VARIATION => 18, X_UNIT_SCROLL => 4, Y_UNIT_SCROLL => 3, }; my $mw = MainWindow->new(-title => 'Mouse Gesture Test'); $mw->geometry('1200x900+50+50'); my $w_text = $mw->Scrolled('Text', -scrollbars => 'osoe', -wrap => 'none', )->pack(-fill => 'both', -expand => 1); my ($xpos, $ypos); my $t0 = [gettimeofday]; $w_text->bind('<Motion>', [\&mouse_gesture, Ev('x'), Ev('y')]); populate_text_widget($w_text); $mw->Button(-text => q{Exit}, -command => sub { exit })->pack(); MainLoop; sub mouse_gesture { my ($w, $x, $y) = @_; # Once-off initialisation if (! defined $xpos) { $xpos = $x; $ypos = $y; return; } my $t1 = [gettimeofday]; if (tv_interval($t0, $t1) > MAX_TIME_VARIATION) { $t0 = $t1; $xpos = $x; $ypos = $y; } else { if (abs(abs($xpos) - abs($x)) > X_MIN_DISTANCE_VARIATION) { $t0 = $t1; for (1 .. X_UNIT_SCROLL) { $w->xviewScroll($xpos < $x ? 1 : -1, q{units}); } $xpos = $x; } if (abs(abs($ypos) - abs($y)) > Y_MIN_DISTANCE_VARIATION) { $t0 = $t1; for (1 .. Y_UNIT_SCROLL) { $w->yviewScroll($ypos < $y ? 1 : -1, q{units}); } $ypos = $y; } } return; } sub populate_text_widget { my $w = shift; my $long_string = ''; for ('a' .. 'z') { $long_string .= $_ x 20; } for (1 .. 500) { $w->insert('end', "This is line $_. It's really long ... $long_string\n" ); } }

Enjoy!

-- Ken


In reply to Re: iPad bells and whistles by kcott
in thread iPad bells and whistles by Steve_BZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.