Question on GnomeCanvasImage




Okay. First of all, thanx Frederico for your help. I actually figured out
the bug (after browsing the web for a LONG time) before I got your reply,
but thanx anyway.

Now, here are some code snippets on how I've implemented drawing the board
and updating it every time someone presses a button on the board.

board_image is a GdkImlibImage created by loading a PNG file. The PNG file
has transparancy in it. From fiddling around I noticed that board emits
an event signal only if I move my mouse over the non-transparent part of my
image - which is good. However, two problems:

	(a) After update_board is called and the image is rotated by 30
            degrees successfully, it seems that the "area" over which my
            mouse movement generates an event signal is no longer "the
            non-transparent part of the image".
        (b) After update_board is called 2 times, board doesn't generate
            an event signal anymore.

Have I done something wrong?

(oh BTW, I'm using the AA mode of GnomeCanvas because the other mode
does'nt display rotations correctly - is that a bug or not?).


void
update_board                    (GnomeCanvasItem        *board)
{
  double                transformation[6];

  art_affine_rotate(transformation, 30.0);
  gnome_canvas_item_affine_relative (board, transformation);
}

void
draw_board                      (GnomeCanvas            *canvas)
{

  ... STUFF ...

  board = gnome_canvas_item_new (gnome_canvas_root(canvas),
                                 GNOME_TYPE_CANVAS_IMAGE,
                                 "image", board_image,
                                 "x", -200.0, "y", -200.0,
                                 "width", (gdouble) board_image->rgb_width,
                                 "height", (gdouble) board_image->rgb_height,
                                 "anchor", GTK_ANCHOR_NW,
                                 NULL);

  gtk_signal_connect (GTK_OBJECT(board), "event",
                      GTK_SIGNAL_FUNC (on_board_event),
                      NULL);
}

gboolean
on_board_event                         (GnomeCanvasItem *object,
                                        GdkEventType    *event,
                                        gpointer         user_data)
{
  fprintf(stderr, "*%d", (int) *event);

  if (*event == GDK_BUTTON_PRESS) {
    update_board(object);
    return TRUE;
  }

  return FALSE;
}


|      LOBAN AMAAN RAHMAN  <-- anagram of -->   AHA! AN ABNORMAL MAN!      |
|   Snail: MSC #763, Caltech, Pasadena, CA 91126, USA. ** 1-626-395-1407   |
|     Wired: loban@earthling.net, loban@caltech.edu, http://i.am/loban     |
|        (Do 'finger loban@its' or my PGP public key and more info)        |



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