Events, tools and pointer devices

Boudewijn Rempt boud at valdyas.org
Thu Oct 12 22:50:08 CEST 2006


I'm working to make flake work with tablets, so I can port Krita to KoTool. 
However, it's complex thing, so I'm sharing my thoughts with you lot:

There can be any number of pointer devices of the following types:

mouse
pen (tip end of pen)
cursor (puck)
eraser (broad end of pen)

pen, cursor and eraser can be of different device types:

puck
stylus
airbrush
4Dmouse
rotation stylus

Of each type of device, more than one can be used: distinguished by a unique 
id.

The tool manager needs to map between all known devices (mouse, tablet uid's) 
and all tools, so the user can use the pan tool with the mouse and the paint 
tool with the stylus. Additionally, if the user has more than one stylus (for 
instance) they want to have a thick red screening brush for one stylus and a 
thin black over brush for the other stylus. Therefore, for every discovered 
unique device, we need the complete set of tools:

map ( class KoInputDevice(pointertype, tabletdevice, uid) : vector(tools) ) -- 
this is complexer than the old KisInputDevice which only distinguished 
between pointertype.

Only one device can have the current pointer: the difficulty is in determining 
which device the user has in their hand. (Krita gets it wrong sometimes). 
This can be done with the TabletEnterProximity and TabletLeaveProximity 
events. These are delivered to QApplication, not the widget, but we need to 
be notified of ourselves them anyway.

The toolmanager therefore needs to somehow determine which KoInputDevice 
instance the user is actually using (and to give an example from real life: I 
work with the stylus in my left hand and the mouse in my right. The stylus is 
set to brush and eraser, the mouse to pan). Timers will probably feature 
largely in this scheme because the user will often remove the pen far enough 
from the tablet for a proximity leave event to occur, while still having the 
stylus in their hand. We really should be able to stop Qt from simulating 
mouse events that originate with the tablet!

Krita uses X11 directly to get its events because plain Qt3 didn't give us 
enough events. We are not certain whether Qt4 will do, but we are going to 
try. Qt4's tablet event is much improved in any case -- it gives us nearly 
everything, even support for 4d mice and rotation styluses.

The whole application window receives events from the current input device. We 
shouldn't change the current tool if the pointer is over a different widget 
than the canvas; this is a hard problem to solve reliably.

Whenever a tablet event arrives on the canvas, pressure and other 
characteristics should be changed according to the users "fist" or preferrer 
pressure curve. Do we do this in every canvas, or is their an easy way to 
make this generic for all of KOffice? Remember that we don't have a shared 
canvas implementation.

Any pointer event should then be passed onto the tool. Difficult decision: 
should we make a generic pointer event that includes all tablet information, 
or add a QTabletEvent handler to KoTool.h? Krita does the first, making life 
easier for tool implementors, but QTabletEvent is so rich, we may want to 
deliver it as-is.

What have I forgotten? What shall we do?
-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20061012/d5126c24/attachment-0001.pgp 


More information about the kimageshop mailing list