Re: Mouse events on a Cairo Context

2013-07-03 Thread Borja Mon Serrano
Hi,

Thank you for your help, guys. Finally I tried with goocanvasmm and
everything works fine, as I wanted. There are some simple examples in the
libgoocanvasmm-2.0-doc package for Ubuntu, so I could deal with the problem
:) The most similar example there is "moving_shapes".

Thank you!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Mouse events on a Cairo Context

2013-07-01 Thread Dov Grobgeld
There is another solution that I have used extensively, which is to draw
the cairo commands twice. Once for the actual drawing, and once again in an
offline image (called label image), with the following differences:

   1. Use solid colors corresponding to "labels" of the different graphical
   components.
   2. Turn off anti-aliasing.

When the user clicks on the image, the x,y of the event is referenced in
the label image. The label is then used as a lookup to the component which
can be modified.

You can see an example of how to do this at
https://github.com/dov/dovtk-lasso . Note that there is a special gtk3
branch.

Regards,

Dov


On Mon, Jul 1, 2013 at 7:54 PM, Stefan Salewski  wrote:

> On Mon, 2013-07-01 at 17:42 +0200, Borja Mon Serrano wrote:
>
> >
> > The problem with (4) is drag&drop. I think it could be very difficult to
> > deal with it, so I'm going to try the third solution, with goocanvasmm.
> Do
> > you know any example of use of goocanvasmm?
> >
>
> Yes, drag&drop may be not very easy.
> And zooming and panning/scrolling for a plain (cairo) drawing area may
> be not really trivial, when you need to grab objects with the mouse.
> I did try it two years ago from Ruby -- not really difficult, but it
> takes some time to get the math right. Have not found time to clean it
> up yet. ( http://www.ssalewski.de/PetEd.html.en)
>
> Of course, if you do C++ and have not much experience in GTK already you
> may try
>
> https://qt-project.org/doc/qt-4.8/graphicsview.html
>
> I have never find time and motivation to test that.
>
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Mouse events on a Cairo Context

2013-07-01 Thread Stefan Salewski
On Mon, 2013-07-01 at 17:42 +0200, Borja Mon Serrano wrote:

> 
> The problem with (4) is drag&drop. I think it could be very difficult to
> deal with it, so I'm going to try the third solution, with goocanvasmm. Do
> you know any example of use of goocanvasmm?
> 

Yes, drag&drop may be not very easy.
And zooming and panning/scrolling for a plain (cairo) drawing area may
be not really trivial, when you need to grab objects with the mouse.
I did try it two years ago from Ruby -- not really difficult, but it
takes some time to get the math right. Have not found time to clean it
up yet. ( http://www.ssalewski.de/PetEd.html.en)

Of course, if you do C++ and have not much experience in GTK already you
may try

https://qt-project.org/doc/qt-4.8/graphicsview.html

I have never find time and motivation to test that.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Mouse events on a Cairo Context

2013-07-01 Thread Borja Mon Serrano
Hi Colomban

 This is probably the simplest solution, it's meant for this kind of things.
>
> 4 - Handle the events yourself:  listen to the
> button-press-event/button-release-event of your DrawingArea and do the
> math to know whether the click is on your circle or not.  Maybe Cairo
> has this kind of thing, like "is that point in that shape", not sure.
>

The problem with (4) is drag&drop. I think it could be very difficult to
deal with it, so I'm going to try the third solution, with goocanvasmm. Do
you know any example of use of goocanvasmm?

Thank you! :)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Mouse events on a Cairo Context

2013-06-30 Thread Colomban Wendling
Le 30/06/2013 21:10, Borja Mon Serrano a écrit :
> Hi all,
> 
> [...]
> 
> 1 - I think the best way is to create a signal to the cairomm context, but
> I didn't see anything to do that. Maybe the way would be to create a cairo
> surface or something like that.

I don't think Cairo has this kind of thing.  It's a library for drawing,
not interacting with the drawing.

> 2 - Every time I click to create a circle, I would have to create a gtk
> widget in which I can handle mouse events. The problem here is that I think
> it is impossible to put a widget on a DrawingArea, is it possible?

No you can't.  And no stock widget will give you a circular event area.

> 3 - Use goocanvasmm. The problem here is that goocanvasmm has a little
> documentation  and I think
> this is not the best solution, I prefer to use cairomm.

This is probably the simplest solution, it's meant for this kind of things.

4 - Handle the events yourself:  listen to the
button-press-event/button-release-event of your DrawingArea and do the
math to know whether the click is on your circle or not.  Maybe Cairo
has this kind of thing, like "is that point in that shape", not sure.


Regards,
Colomban
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Mouse events on a Cairo Context

2013-06-30 Thread Borja Mon Serrano
Hi all,

I'm developing an application with C++ and GTK3 but I'm stucked. I've
created a visual application with glade which has three columns and one of
them, the middle one, is a DrawingArea. In that DrawingArea I want to draw
some circles at the point I want to after pressing a button and have
different mouse events on that circles (like drag and drop, double click,
right click...). I've made the first thing (draw a circle after pressing a
button) following the official
documentation,
but the problem is that I don't know how to do the mouse events, but I
thought about it and I have some different solutions (I don't know if they
are the bests solutions or maybe there are better):

1 - I think the best way is to create a signal to the cairomm context, but
I didn't see anything to do that. Maybe the way would be to create a cairo
surface or something like that.

2 - Every time I click to create a circle, I would have to create a gtk
widget in which I can handle mouse events. The problem here is that I think
it is impossible to put a widget on a DrawingArea, is it possible?

3 - Use goocanvasmm. The problem here is that goocanvasmm has a little
documentation  and I think
this is not the best solution, I prefer to use cairomm.

This application was written in C using GTK2, and the circles were drawn
using gnomecanvas, adding signals in an easy way to each circle; and now
I'm moving this application to C++ and GTK3 to renew it.

I'm very new to GTK (and graphical interfaces in general), but I looked for
solutions for hours and I don't know what is the best way in order to
continue my work. I also looked for similar messages in this list, but I
didn't find it.

Although I think the best way is the first option, I tried to make the
second because I think it is the regular way. Anyway, if you know how to
deal with this problem, could you give me an example of how to do that?

Thank you for your help :)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list