Veli Ogla Sungutay <[email protected]> wrote:

> The Clutter cookbook shows how to create a non rectangular shaped
> actor.  (Ex. A star shape).  Let's say that we have the star shape as
> a cairo context, and we would like to display this cairo context as an
> Actor *which does not accept mouse events outside its path*.
> 
> For this purpose I think we need to define the Cogl path.

For actors that are subclassing ClutterTexture (which includes
ClutterCairoTexture) this is actually much simpler. Instead of trying to
paint the path in the pick method we can just paint the texture in a
special mode so that it paints the pick color where the texture is
opaque and paints nothing where the texture is semi-transparent.
ClutterTexture already has a property to implement this so to make it
work you only need to add this single line to your code:

 clutter_texture_set_pick_with_alpha (CLUTTER_TEXTURE (cairo_texture), TRUE);

However if for some reason you did want to get the Cogl path out of a
Cairo path, it shouldn't be too tricky even though there is no builtin
function to do it. If you look at the source code¹ for the
clutter_path_add_cairo_path function you can see how to extract the
nodes from a Cairo path. You could copy this function and just replace
all of the clutter_path_add_* calls with cogl_path_* calls.

Regards,
- Neil

¹ http://ho.io/nzq3
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to