[Cairo] mouse pointer and cairo

Bill Spitzak spitzak at d2.com
Mon Oct 13 17:46:56 PDT 2003

On Monday 13 October 2003 04:43 pm, Thomas Hunger wrote:
> > 1. Make the "number" reliably hold a void* pointer, not just an integer.
> Would this need a new backend?

I don't think so. What I am trying to avoid is that in OpenGL you typically 
have to make an array of pointers to all the objects so you can easily turn 
their index numbers back into objects. If the index numbers were guaranteed 
to be large enough to hold a void* this would not be needed.

> > 2. Return how opaque the object is. Programs can use this to decide if
> > the user was clicking through an almost-transparent window on the
> > foreground object. More importantly, transparent areas of images and
> > letters can return but the program can skip them if it wants.
> I did not think about it before, but exact text-selection seems important
> to me. The only way to do it geometrically correct would be decomposition?

This could be used to detect what letter you clicked on, if the text-drawing 
library would send a different object number for each letter. If not then 
this can only be used to detect if you clicked on an entire string.

> > 3. Somehow return a distance value. This should be the distance between
> > the center of the pixel from the nearest line or vertex (squared to avoid
> > the need for sqrt). Make it negative if the pixel is inside the a filled
> > shape.
> Why is the distance important? Either one selects a shape, or one does not.
> A certain  unexactness could be introduced by a larger "hit area".

This is needed for points and lines, in case two objects are inside the hit 
area, to try to get a better guess which one the user hit.

An alternative I just thought of: the caller can keep reducing the hit area 
and trying again until only one object remains.

                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com

More information about the cairo mailing list