Re: Event woes for items with irregular shapes



On Tue, 28 Aug 2018 19:47:00 +0300,
Damon Chaplin wrote:
On Mon, 2018-08-27 at 12:26 +0300, Yavor Doganov wrote:
Thank you very much, this works perfectly.  I just changed a bit
goo_canvas_image_is_item_at and added the pixbuf as member of the
image data struct so that I have easy access to it.

Wow. You did that quick! I think you're a better coder than me!

No way; I'm not a programmer at all and I lack fundamental knowledge
in this area.

Unfortunately I don't really spend much time on GooCanvas any more, so
the chances of a fix are quite low.

I see.  I prepared a patch but hesitated to send it, because I felt
it's clumsy and inefficient to carry both the cairo_pattern_t and the
GdkPixbuf -- that's basically the same image data in two different
formats.

Then it occurred to me that the pattern can be used to achieve the
same thing, so attached is a minimalistic patch against the
goocanvas-2.0 branch that certainly doesn't break the ABI.  You can
test it easily with the generic-position-demo where the icon is
particularly suitable for the task.  Currently, you can drag the icon
by grabbing it at the translucent area of the image, which is awkward
at best.  And also incorrect if you have in mind the scenario I
described in the first message.

The only advantage of my initial approach is that I made the "pixbuf"
property read-write.  But I'm not sure how useful would it be in
practice; probably not much.

Please note that GnomeCanvas uses "< 128" rather than "== 0" for the
translucency test.  I deliberately chose to use the latter because I
think it's more user-friendly: many images contain pixels with alpha <
128 in their visible area so it would be impossible to grab the item
if pointer happens to be at a pixel that is more translucent than
opaque.

Also note that if you care about portability to old (pre-C99) systems,
the patch needs to be extended with configure checks for stdint.h and
uint32_t, and have alternative branches if any of those are missing.
I'd be happy to do that if you say so.

I think the new GTK has broken GooCanvas quite a bit too, so it may
not have too much of a future.

Do you mean GTK+ 4 or the development/unstable release (3.23.x)?  I
havent't tried either, but that is unfortunate.

Attachment: goocanvasimage-opacity.patch
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]