11 thoughts on “Yet about custom widgets with Cairo”

  1. I don’t understand why you’re blogging this? This is basic math, hook up the motion notify event and start doing the comparisons.

    Like your last post, get a polar distance from the centre and calculate if that is larger than the radius, with this its a simple rectangular comparison.

  2. @Davyd:

    If I use cairo_in_fill I only can test the total filled area. I’d like to test if click happens in the top-left, top-right, bottom-left or bottom-right paths.


    I’m doing it because I’m not a expert in gtk+ / cairo / programming.

  3. Well, you’ve got a couple of options.

    You could set it up as 4 different paths and test these individually (hint, rather than recreating the path each time, it may be easier to save them and test against the saved versions).

    Instead of testing whether or not you’re inside a path using Cairo, you could do the calculation by hand using some practical geometry (aka. by steam).

    Or finally, depending on how much further work you’re going to need to do, you could use Goocanvas to create several canvas objects (it’s pretty easy to create a Goocanvas object directly from a path). Canvas objects can have signals connected to them, like button-press-event, enter-notify-event, etc. If you’re having to interact with, change properties of, or move lots of items within your custom widget, GooCanvas may be the way to go (it’s possible to subclass a GooCanvas into an opaque widget if you wish).

  4. brunobol, you don’t have to be an expert in cairo or gtk, its basic math!

    planet.gnome.org isn’t really the right place to be asking these kinds of questions, if you’re having that much trouble figuring out how this kind of thing is done you should probably start by taking a few steps back and learning programming with mathematics, and comparisons (oh and get graph paper, graph paper rocks almost as much as cairo)

    Ask in the IRC channels around or if you like email me directly, I’d gladly help you with these kinds of simple problems, especially if you send me the code :)

  5. Karl: People are free to post on their blog whatever they want. Yes, it gets syndicated by p.g.o. However, that is the intentention of p.g.o. (showing their whole feed). Brunobol is learning Cairo and sharing that with the world. IMO all good.. there is even the possibility that it will help others.

  6. Olav, I’m not saying its a bad thing to post about learning something, I’m saying two questions in two days both of which could be answered on IRC or a mailing list faster. There’s nothing wrong with Bruno posting this to pgo, but in his own interests finding answers through other places would be faster.

  7. Karl: I like blogs like this, and I always read the suggestions given. Not because I don’t know how I could do it, but because I find it very interesting to see how other people would solve it. Personally I find this more interesting then somebodies last meal or holiday pictures.

    but that is my €0,0129

  8. Qball: I find them interesting too and again, less holiday snaps etc… The comment wasn’t about censorship it was about speeding up Bruno’s access to help.

    Maybe I was a little hasty in what I said.

  9. @Jonh:

    Yeah. But… I’m creating the widget first, I’ll paint the right colors after coding. Thanks!

    @Davyd and Karl:

    Thanks again… sometimes I forget to use math. :( It simplifies everything!!!

Comments are closed.

Leave a Reply

Your email address will not be published. Required fields are marked *