-
Notifications
You must be signed in to change notification settings - Fork 84
Overview
Gestouch is a very basic framework that helps you to detect gestures when you develop NUI (Natural User Interface).
Last versions of Flash Player and AIR have built-in touch and multitouch support, but the gestures support is quite poor: only small set of gestures are supported, they depend on OS, they are not customizable, only one can be processed at the same time and, finally, you are forced to use either raw TouchEvents, or gestures (@see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/Multitouch.html#inputMode).
This framework is aimed to simplify the process of detecting raw TouchEvents and processing them into a specific gesture(s). There are several built-in common gestures, but you are welcome write your own.
Features:
- Doesn’t require any additional software (uses runtimes build-in touch support);
- Doesn’t break your DisplayList architecture (doesn’t require any wrappers, so could be easily used for Flex development);
- Basically allows you to write multi-user interfaces;
- Extendable. You can write your own application-specific gestures;
- Open-source and easy to use.
When I recently had a project that required a bit of multitouch input, I checked around web and found no simple solutions. I have found basically two projects: GestureWorks and TUIO. I hope they won’t fell hurt for my evaluation. First one provides no code (closed) and they charge for something, also I didn’t like architecture as developer has to wrap all objects into some TouchSprite. Second one looks like a serious old project, more about protocol, passing data from touch-sensors to software. There are some flash clients (libraries) here and I tried their official one — but it simply didn’t worked out for me… And well, I don’t see much point in focusing on some protocols since Flash Platform supports touch/multitouch now.
So I decided to write something quickly. That can be easily ported, that doesn’t break your application architecture, that is simple, powerful enough and extendable.
Right now framework is in a very early stage, packages structure probably is not final, though I think API is fine enough. I’m looking forward for any comments and contribution.
Thanks to Eero “pimpelsang” Koplimets for initial review and criticism, without him it would be more messy and tricky to use =)
Main actors are the Gestures. Gesture is basically a detector of the gesture motion, it processes raw touch events and forms a gesture event out of it. I believe similar things are GestureDetector on Android and GestureRecognizers on iOS. Important to note that Gesture is not supposed to change UI anyhow, it simply tracks the touch points over specific target.
Gesture is created for a certain target(:InteractiveObject) and after that target will dispatch gesture events, just like with native Flash gestures. Gestures are GC-friendly as soon as you remove them via using dispose() method or another way of removing. They are are also cancellable (in case you want to stop some once another gesture tracked).
Gesture goals:
- Track touch points that gesture interested in
- Fire event (via target.dispatchEvent(…)) when series of touch events forms a gesture motion.
Gesture NON-goals: - Update UI (eg: move object on drag, rotate it, scale, highlight, etc…)
There’s a hidden guy GesturesManager — it keeps all the gestures, tracks all the mouse/touch events, updates TouchPoints’ properties (positions, offsets, velocities, etc…) and populates gestures with those TouchPoints. Yes, GesturesManager is basically a singleton, all know singletons smell, but it works just fine in this situation. Yes, you can extend GesturesManager and have your own implementation (@see examples in Usage). But you don’t work with GesturesManager directly, it’s an internal workhorse.
TouchPoints is basically a Value Object. It extends Point and stores some extra properties like offsets, velocities, etc…
Build is powered by Ant. Make your own build.properties out of build.template.properties by copying and renaming. Fix several path properties. Once you run build it will create versioned SWC file and generate documentaion (ASDoc). Both in bin folder.
Examples come with a separate project, check that one for more info.
See Usage for more information.