Re: Event woes for items with irregular shapes
- From: Damon Chaplin <damonachaplin gmail com>
- To: Yavor Doganov <yavor gnu org>, goocanvas-list gnome org
- Subject: Re: Event woes for items with irregular shapes
- Date: Mon, 27 Aug 2018 07:54:17 +0100
On Mon, 2018-08-27 at 08:20 +0300, Yavor Doganov wrote:
Hi,
I'm trying to port an old game from GnomeCanvas to GooCanvas/GTK+ 3.
The main canvas consists of continents with countries, where each
country is a group containing image + ellipse for the capital.
Country groups are connected to the various event signals so that
when
the pointer moves across the border to a different country, the
enter-notify-event handler ought to display data about the country
where the pointer is.
Unfortunately, it doesn't happen in practice as countries have
irregular shapes and the new country starts to receive events only
when the pointer moves beyond the imaginary rect of the old country.
(Country images are rects with opaque territory and translucent area
beyond their borders.) I suppose this is somewhat hard to
understand,
so let me try to illustrate:
--------------,
|
` A |
` |
` |
` |
X ` |
` |
`--------
B |
|
`-----------
When pointer moves from country A to area X, the desired behavior is
to obtain country B. But still A is shown because area X, although
territory of country B, is still part of the rect that A occupies.
IOW, when the pointer is in area X, country A continues to receive
events.
This works flawlessly with GnomeCanvas where country groups are
connected to the "event" signal. I suppose that I made some mistake
but I can't figure it out, so I'd appreciate any kind of help.
I think it's a problem with GooCanvasImage. It uses a cairo_pattern_t
for the image and I couldn't see any way to check if the pixel the
mouse was on was translucent or not. So it currently just checks the
image rectangle.
One solution may be to create your own custom canvas item, similar to
GooCanvasImage, but keep the pixbuf around and use that to check the
pixel, using code similar to GnomeCanvas. (I probably should have done
that with GooCanvasImage.)
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]