[sugar] Zoomable tracking protocol for non-windowed Cairo based objects.
Don Hopkins
dhopkins
Thu Feb 22 17:16:58 EST 2007
On the topic of tracking with non-windowed cairo objects, and zoomable
interfaces:
Here is a design document describing the ScriptX Tracking Service that I
developed at Kaielda, to solve some of these problems inherent with
efficiently delivering events to graphical (non-windowed) objects,
through a series of transformations (and offscreen buffers).
It might be handy with zoomable interfaces, because it has a handshake
protocol (that begins with TrackStart) that walks down the object tree,
allowing each view to modify a transformation matrix each step, and then
when it hits the leaf view that actually wants to receive the events, it
caches the complete transformation, so it can transform event
coordinates directly through that, and delegates tracking events
(TrackDown/Move/Up, etc) directly to the leaf view, without walking down
the view tree and transforming coordinates each step of the way every
time the mouse moves.
It also lets the views delegate tracking to offscreen views (to
implement caching, double buffering, and multiple synchronized views of
the same object), or even directly to the model itself, which can
implement the tracking interface, so (for example) when you drag the
model in one view, all the other views of the model update. (Woo hoo! A
classic MVC cargo cult sacrament!)
And it's easy to use! (Sensible defaults, and some cool services like
grid snapping, vertical and horizontal motion constraints, confining to
a box, hover notification, which you can enable if you like, but ignore
if you don't need them. Because it passes a dictionary with
configuration parameters during the TrackStart handshake, it's easy to
add new features to the tracking service without breaking existing code.)
I think it would be pretty easy to translate it to Python, thanks to its
support of multiple inheritance (which ScriptX used a lot, like they
were going out of style).
ScriptX Tracking Service Documentation:
http://www.art.net/~hopkins/Don/lang/scriptx/tracking.html
ScriptX Tracking Service Source Code:
http://www.art.net/~hopkins/Don/lang/scriptx/tracking.sx
-Don
ScriptX Tracking Service
By Don Hopkins, Kaleida Labs
Introduction
This is the documentation for the ScriptX Tracking Service. The Tracking
Service is a set of classes for tracking mouse clicks and movements. It
includes the TrackService class, a controller that manages interests and
handles low level input events, and the Tracker class, a mixin that
participates in the high level tracking protocol with the tracking
service. It also provides the CachedPresenter class, that draws an
offscreen group of presenters into a bitmap cache, which dramatically
improves compositor performance.
This tracking service offers several advantages over the lower level
DragController built into ScriptX. It's designed to be very easy to use,
so many of the common types of mouse tracking can be coded with a
minimum effort. It has some fancy features, but it provides sensible
defaults and a clean interface so it's not complicated, and the features
don't get in your way if you don't need them.
Some of its important features include delegation of tracking to objects
other than the one originally clicked on, and transformation of event
coordinates through an arbitrary TwoDMatrix. These features made it easy
to implement a cached offscreen group, that draws quickly from a bitmap
cache, but passes tracking through to offscreen presenters. (That was
not easy to do with the DragController, since it provides no way to
track input events on offscreen presenters.)
The Tracking Service is used by the DreamScape demo.
[More info at http://www.art.net/~hopkins/Don/lang/scriptx/tracking.html
and sources at http://www.art.net/~hopkins/Don/lang/scriptx/tracking.sx ]
More information about the Sugar-devel
mailing list