Exemplo n.º 1
0
static void
update_tux(gint direction)
{
  gint rotation = 0;
  GooCanvasBounds bounds;
  gdouble scale;

  /* Our svg image of tux is faced south */
  switch(direction)
    {
    case EAST:
      rotation = -90;
      break;
    case WEST:
      rotation = 90;
      break;
    case NORTH:
      rotation = 180;
      break;
    case SOUTH:
      rotation = 0;
      break;
    }

  goo_canvas_item_set_transform(tuxitem, NULL);

  goo_canvas_item_get_bounds(tuxitem, &bounds);

  scale = (gdouble) cellsize / (bounds.x2 - bounds.x1);
  goo_canvas_item_scale(tuxitem, scale, scale);

  goo_canvas_item_rotate( tuxitem, rotation,
			  (bounds.x2-bounds.x1)/2,
			  (bounds.y2-bounds.y1)/2);


  // update the running shoes
  if(run_fast_possible && run_fast) {
	  goo_canvas_item_set_transform(tuxshoes, NULL);

	  scale = (gdouble) cellsize / (bounds.x2 - bounds.x1);
	  goo_canvas_item_scale(tuxshoes, scale, scale);

	  goo_canvas_item_rotate( tuxshoes, rotation,
				  (bounds.x2-bounds.x1)/2,
				  (bounds.y2-bounds.y1)/2);
  }
}
Exemplo n.º 2
0
static VALUE
rg_rotate(VALUE self, VALUE degrees, VALUE cx, VALUE cy)
{
    goo_canvas_item_rotate(SELF(self), NUM2DBL(degrees),
                           NUM2DBL(cx), NUM2DBL(cy));
    return self;
}
Exemplo n.º 3
0
static void
create_width_for_height_table (GooCanvasItem *root,
			       gdouble        x,
			       gdouble        y,
			       gdouble        width,
			       gdouble        height,
			       gdouble        rotation)
{
  GooCanvasItem *table, *item;
  gchar *text = "This is a long paragraph that will have to be split over a few lines so we can see if its allocated height changes when its allocated width is changed.";

  table = goo_canvas_table_new (root,
#if 1
				"width", width,
				"height", height,
#endif
                                NULL);
  goo_canvas_item_translate (table, x, y);
  goo_canvas_item_rotate (table, rotation, 0, 0);

  item = goo_canvas_rect_new (table, 0.0, 0.0, width - 2, 10.0,
			      "fill-color", "red",
			      NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 0,
					"column", 0,
					"x-shrink", TRUE,
					NULL);

#if 1
  item = goo_canvas_text_new (table, text, 0, 0, -1, GOO_CANVAS_ANCHOR_NW, NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 1,
					"column", 0,
					"x-expand", TRUE,
					"x-fill", TRUE,
					"x-shrink", TRUE,
					"y-expand", TRUE,
					"y-fill", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (item), "id", "Text Item");
  g_signal_connect (item, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);
#endif

  item = goo_canvas_rect_new (table, 0.0, 0.0, width - 2, 10.0,
			      "fill-color", "red",
			      NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 2,
					"column", 0,
					"x-shrink", TRUE,
					NULL);
}
Exemplo n.º 4
0
int
main ()
{
  GtkWidget *window, *scrolled_win, *canvas;
  GooCanvasItem *root, *rect_item, *text_item;

  /* Initialize GTK+. */
  gtk_init ();

  /* Create the window and widgets. */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
  gtk_widget_show (window);
  g_signal_connect (window, "delete_event", G_CALLBACK (on_delete_event),
		    NULL);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_container_add (GTK_CONTAINER (window), scrolled_win);

  canvas = goo_canvas_new ();
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  /* Add a few simple items. */
  rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
				   "line-width", 10.0,
				   "radius-x", 20.0,
				   "radius-y", 10.0,
				   "stroke-color", "yellow",
				   "fill-color", "red",
				   NULL);

  text_item = goo_canvas_text_new (root, "Hello World", 300, 300, -1,
				   GOO_CANVAS_ANCHOR_CENTER,
				   "font", "Sans 24",
				   NULL);
  goo_canvas_item_rotate (text_item, 45, 300, 300);

  /* Connect a signal handler for the rectangle item. */
  g_signal_connect (rect_item, "button_press_event",
		    G_CALLBACK (on_rect_button_press), NULL);

  /* Pass control to the GTK+ main event loop. */
  gtk_main ();

  return 0;
}
Exemplo n.º 5
0
/* =====================================================================
 *
 * =====================================================================*/
static gboolean
regleur_chasse_event(GooCanvasItem *item, GooCanvas *target,
		     GdkEventButton *event, gpointer data)
{
  GooCanvasBounds bounds;

  if(board_paused || !boardRootItem)
    return FALSE;

  goo_canvas_item_get_bounds(item, &bounds);

  gc_sound_play_ogg ("sounds/bleep.wav", NULL);
  regleur_chasse_open = !regleur_chasse_open;

  goo_canvas_item_rotate(item, 90.0,
			 bounds.x1 + (bounds.x2 - bounds.x1) / 2,
			 bounds.y1 + (bounds.y2 - bounds.y1) / 2);

  return FALSE;
}
Exemplo n.º 6
0
static GooCanvasItem*
create_table (GooCanvasItem *parent,
	      gint           row,
	      gint           column,
	      gint           embedding_level,
	      gdouble        x,
	      gdouble        y,
	      gdouble        rotation,
	      gdouble        scale,
	      gint           demo_item_type,
	      gboolean       show_grid_lines)
{
  GooCanvasItem *table;

  /* Add a few simple items. */
  table = goo_canvas_table_new (parent,
				"row-spacing", 4.0,
				"column-spacing", 4.0,
				NULL);

  if (show_grid_lines)
    g_object_set (table,
		  "horz-grid-line-width", 1.0f,
		  "vert-grid-line-width", 1.0f,
		  NULL);

  goo_canvas_item_translate (table, x, y);
#if 1
  goo_canvas_item_rotate (table, rotation, 0, 0);
#endif
#if 1
  goo_canvas_item_scale (table, scale, scale);
#endif

  if (row != -1)
    goo_canvas_item_set_child_properties (parent, table,
					  "row", row,
					  "column", column,
#if 1
					  "x-expand", TRUE,
					  "x-fill", TRUE,
#endif
#if 0
					  "y-expand", TRUE,
					  "y-fill", TRUE,
#endif
					  NULL);

  if (embedding_level)
    {
      gint level = embedding_level - 1;
      create_table (table, 0, 0, level, 50, 50, 0, 0.7, demo_item_type,
		    show_grid_lines);
      create_table (table, 0, 1, level, 50, 50, 45, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 0, 2, level, 50, 50, 90, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 1, 0, level, 50, 50, 135, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 1, 1, level, 50, 50, 180, 1.5, demo_item_type,
		    show_grid_lines);
      create_table (table, 1, 2, level, 50, 50, 225, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 2, 0, level, 50, 50, 270, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 2, 1, level, 50, 50, 315, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 2, 2, level, 50, 50, 360, 2.0, demo_item_type,
		    show_grid_lines);
    }
  else if (demo_item_type == DEMO_TEXT_ITEM_2)
    {
      create_demo_item (table, demo_item_type, 0, 0, 1, 1,
			"(0.0,0.0)\nleft\naligned",
			-1, 0, 0, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 1, 1, 1,
			"(0.5,0.0)\ncenter\naligned",
			-1, 0.5, 0, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 0, 2, 1, 1,
			"(1.0,0.0)\nright\naligned",
			-1, 1, 0, PANGO_ALIGN_RIGHT);

      /* The layout width shouldn't really make any difference in this test. */
      create_demo_item (table, demo_item_type, 1, 0, 1, 1,
			"(0.5,0.5)\ncenter\naligned",
			50, 0.5, 0.5, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 1, 1, 1, 1,
			"(0.0,1.0)\nright\naligned",
			100, 0, 1.0, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 1, 2, 1, 1,
			"(0.0,0.5)\nleft\naligned",
			200, 0, 0.5, PANGO_ALIGN_LEFT);

      create_demo_item (table, demo_item_type, 2, 0, 1, 1,
			"(1.0,1.0)\ncenter\naligned",
			-1, 1, 1, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 2, 1, 1, 1,
			"(1,0.5)\nright\naligned",
			-1, 1.0, 0.5, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 2, 2, 1, 1,
			"(0.0,0.0)\nleft\naligned",
			-1, 0, 0, PANGO_ALIGN_LEFT);
    }
  else if (demo_item_type == DEMO_TEXT_ITEM_3)
    {
      create_demo_item (table, demo_item_type, 0, 0, 1, 1,
			"width 50 align 0.0, 0.0 text left aligned",
			50, 0, 0, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 1, 1, 1,
			"width 100 align 0.5, 0.0 text center aligned",
			100, 0.5, 0, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 0, 2, 1, 1,
			"width 150 align 1.0, 0.0 text right aligned",
			150, 1, 0, PANGO_ALIGN_RIGHT);

      create_demo_item (table, demo_item_type, 1, 0, 1, 1,
			"width 50 align 0.5, 0.5 text center aligned",
			50, 0.5, 0.5, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 1, 1, 1, 1,
			"width 100 align 0.0, 1.0 text right aligned",
			100, 0, 1.0, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 1, 2, 1, 1,
			"width 200 align 0.0, 0.5 text left aligned",
			200, 0, 0.5, PANGO_ALIGN_LEFT);

      create_demo_item (table, demo_item_type, 2, 0, 1, 1,
			"width 50 align 1.0, 1.0 text center aligned",
			50, 1, 1, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 2, 1, 1, 1,
			"width 100 align 1, 0.5 text right aligned",
			100, 1.0, 0.5, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 2, 2, 1, 1,
			"width 50 align 0.0, 0.0 text left aligned",
			50, 0, 0, PANGO_ALIGN_LEFT);
    }
  else
    {
      create_demo_item (table, demo_item_type, 0, 0, 1, 1, "(0,0)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 1, 1, 1, "(1,0)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 2, 1, 1, "(2,0)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 1, 0, 1, 1, "(0,1)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 1, 1, 1, 1, "(1,1)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 1, 2, 1, 1, "(2,1)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 2, 0, 1, 1, "(0,2)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 2, 1, 1, 1, "(1,2)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 2, 2, 1, 1, "(2,2)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
    }

  return table;
}