Re: Presentation & Question
- From: Lauris Kaplinski <lauris ximian com>
- To: Lucas Di Pentima <ldipenti ciudad com ar>
- Cc: GNOME Development List <gnome-devel-list gnome org>
- Subject: Re: Presentation & Question
- Date: 10 Mar 2002 16:30:15 +0200
Hello!
I think you should drop the idea on relying on gnome-canvas event
routing to catch palnets, but instead write your own. Let me explain:
You have some tolevel structure (let it be StarMap), that referes to
all planets and ships. There are methods:
map_find_closest_planet (map, x, y)
map_find_closest_ship (map, x, y)
And separate objects (rects?) marking selected planet and ship and
highlited planet and ship.
Now you have to capture all events on canvas, regardless of whether
they are happening on planet, ship or empty place. To do that you
can either install handler of widget event, or alternately use
infinite transparent background item (the same one can do some
background painting as well, if you need it).
Now, for each mouse movement, you'll find closest planet and ship,
and show highlight marker on these. If user clicks
mousebutton, you just mark given object as actually selected, and
move selection marker to it.
Thus you will avoid moving both mouse cursor and canvas, that
can disturb users. Plus you can relatively easily implement
autoscroll (just doing some timeout-based magic on border area).
Plus users will have immediate feedback, which object will become
selected, if they will press button.
Best wishes,
Lauris Kaplinski
On Sat, 2002-03-09 at 04:19, Lucas Di Pentima wrote:
> Answering myself :-) I've found in Havoc Pennington's book this piece:
>
> ------------------------------------------------------------
> Can I move the mouse pointer myself?
>
> There is an Xlib routine called XWarpPointer() that does this, but GDK
> does not wrap it. It is almost certainly a bad idea to use this feature
> (in fact it is intended for window managers only); you might consider
> writing to one of the GTK+ or Gnome mailing lists to ask for another way
> to achieve whatever you are trying to achieve. However, you can always
> use Xlib routines (such as XWarpPointer()) by including gdk/gdkx.h and
> gdk/gdkprivate.h, then manipulating the private parts of the GDK data
> structures. If that sounds unsavory, it probably should.
> ------------------------------------------------------------
>
> It doesn't sound healthy to use XWarpPointer(), anyone with other idea?
> If only I could move the GnomeCanvas to where the mouse pointer is, it
> could be a solution.
>
> El vie, 08-03-2002 a las 19:51, Lucas Di Pentima escribió:
> > Hi people!
> >
> > I'm starting to learn GNOME development so I started to write a client
> > of VGA Planets strategy game (anyone knows it?).
> > This client will be heavily based on GnomeCanvas, because the main
> > display will be a starchart where the user can click on planets, ships,
> > and make marks with messages on it, and so on.
> >
> > Already I have working a very basic starchart with planets and ships,
> > when the user clicks on a planet, appear data on a sidebar describing
> > the planet.
> >
> > Now I'm stuck in some issue that although it seems not too important,
> > this feature will make the client more usable.
> >
> > Well, let me explain it: in the GnomeCanvas I have CanvasItems being the
> > planets (as ellipses), when a user click with the mouse on the canvas,
> > the mouse pointer have to go to the nearest planet and select it, so
> > that the user wouldn't have to "aim" to that little circle called planet
> > :-). The idea is doing the same with ships, so button1 is for planets,
> > and button3 for ships.
> >
> > Can anyone give me a tip where to read to do this?
> >
> > Thanks in advance.
> >
> > --
> > Lucas Di Pentima - Santa Fe - Argentina
> > GnuPG Public Key: http://www.lunix.com.ar/clave-publica-lucas.gpg
> > ICQ UIN: 6782045
>
> --
> Lucas Di Pentima - Santa Fe - Argentina
> GnuPG Public Key: http://www.lunix.com.ar/clave-publica-lucas.gpg
> ICQ UIN: 6782045
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]