Example #1
0
static void
i7_node_init(I7Node *self)
{
	I7_NODE_USE_PRIVATE;
	priv->id = g_strdup_printf("node-%p", self);
	self->gnode = g_node_new(self);
	self->tree_item = NULL;
	self->tree_points = goo_canvas_points_new(4);

	priv->blessed = FALSE;
	priv->match = I7_NODE_CANT_COMPARE;
	priv->transcript_diffs = NULL;
	priv->transcript_pango_string = NULL;
	priv->expected_diffs = NULL;
	priv->expected_pango_string = NULL;

	/* Create the cairo gradients */
	/* Label */
	priv->label_pattern = cairo_pattern_create_linear(0.0, 0.0, 0.0, 1.0);
	cairo_pattern_add_color_stop_rgba(priv->label_pattern, 1.0, 0.0, 0.33, 0.0, 0.3);
	cairo_pattern_add_color_stop_rgba(priv->label_pattern, 0.67, 0.73, 0.84, 0.73, 0.1);
	cairo_pattern_add_color_stop_rgba(priv->label_pattern, 0.0, 0.5, 0.85, 0.5, 0.0);
	/* Node, unplayed, without blessed transcript text: Tango Chameleon 3 */
	priv->node_pattern[NODE_UNPLAYED_UNBLESSED] = create_node_pattern(0.31, 0.60, 0.02);
	/* Node, unplayed, with blessed transcript text: Tango Chameleon 1 */
	priv->node_pattern[NODE_UNPLAYED_BLESSED] = create_node_pattern(0.54, 0.87, 0.2);
	/* Node, played, without blessed transcript text: Tango Butter 3 */
	priv->node_pattern[NODE_PLAYED_UNBLESSED] = create_node_pattern(0.77, 0.63, 0.0);
	/* Node, played, with blessed transcript text: Tango Butter 1 */
	priv->node_pattern[NODE_PLAYED_BLESSED] = create_node_pattern(0.99, 0.91, 0.31);

	/* Create the canvas items, though some of them can't be drawn yet */
	priv->command_shape_item = goo_canvas_path_model_new(GOO_CANVAS_ITEM_MODEL(self), "",
		"stroke-pattern", NULL,
		"fill-pattern", priv->node_pattern[NODE_UNPLAYED_UNBLESSED],
		NULL);
	priv->label_shape_item = goo_canvas_path_model_new(GOO_CANVAS_ITEM_MODEL(self), "",
		"stroke-pattern", NULL,
		"fill-pattern", priv->label_pattern,
		NULL);
	priv->command_item = goo_canvas_text_model_new(GOO_CANVAS_ITEM_MODEL(self), "", 0.0, 0.0, -1, GTK_ANCHOR_CENTER, NULL);
	priv->label_item = goo_canvas_text_model_new(GOO_CANVAS_ITEM_MODEL(self), "", 0.0, 0.0, -1, GTK_ANCHOR_CENTER, NULL);
	priv->badge_item = goo_canvas_path_model_new(GOO_CANVAS_ITEM_MODEL(self), "",
	  "fill-color", "red",
	  "line-width", 0,
	  "visibility", GOO_CANVAS_ITEM_HIDDEN,
	  NULL);
	g_object_set_data(G_OBJECT(priv->badge_item), "path-drawn", NULL);
	g_object_set_data(G_OBJECT(priv->badge_item), "node-part", GINT_TO_POINTER(I7_NODE_PART_DIFFERS_BADGE));
	/* Avoid drawing the differs badges unless they're actually needed, otherwise
	it really slows down the story startup */

	priv->x = 0.0;
	priv->command_width = -1.0;
	priv->command_height = -1.0;
	priv->label_width = -1.0;
	priv->label_height = -1.0;
}
Example #2
0
static GooCanvasItemModel*
create_model (GdkPixbuf *pixbuf)
{
  GooCanvasItemModel *root;
  GooCanvasItemModel *item;
  GooCanvasItemModel* child;

  root = goo_canvas_group_model_new (NULL, NULL);

  /* Test clipping of GooCanvasGroup: We put the rectangle and the ellipse into
   * a group with width=200 and height=200. */
  item = goo_canvas_group_model_new (root, "x", 50.0, "y", 350.0, "width", 200.0, "height", 200.0, NULL);
  /*goo_canvas_item_model_rotate(item, 45.0, 150.0, 450.0);*/

  child = goo_canvas_rect_model_new (item, 0.0, 0.0, 100, 100, "fill-color", "blue", NULL);
  g_object_set_data (G_OBJECT (child), "setup-dnd-signals", "TRUE");
  goo_canvas_item_model_rotate(child, 45.0, 50.0, 50.0);

  child = goo_canvas_ellipse_model_new (item, 150, 00, 50, 50, "fill-color", "red", NULL);
  g_object_set_data (G_OBJECT (child), "setup-dnd-signals", "TRUE");

  item = goo_canvas_polyline_model_new (root, FALSE, 5.0, 250.0, 350.0, 275.0, 400.0, 300.0, 350.0, 325.0, 400.0, 350.0, 350.0, "stroke-color", "cyan", "line-width", 5.0, NULL);
  g_object_set_data (G_OBJECT (item), "setup-dnd-signals", "TRUE");

  item = goo_canvas_path_model_new (root, "M20,500 C20,450 100,450 100,500", "stroke-color", "green", "line-width", 5.0, NULL);
  g_object_set_data (G_OBJECT (item), "setup-dnd-signals", "TRUE");

  item = goo_canvas_image_model_new (root, pixbuf, 150, 450, /*"fill-color", "yellow", */NULL);
  g_object_unref (pixbuf);
  g_object_set_data (G_OBJECT (item), "setup-dnd-signals", "TRUE");

  item = goo_canvas_text_model_new (root, "Hello, World!", 250, 450, -1, GOO_CANVAS_ANCHOR_NW, "fill-color", "magenta", "wrap", PANGO_WRAP_WORD_CHAR, NULL);
  g_object_set_data (G_OBJECT (item), "setup-dnd-signals", "TRUE");

  item = goo_canvas_table_model_new (root, "horz-grid-line-width", 2.0, "vert-grid-line-width", 2.0, "row-spacing", 2.0, "column-spacing", 2.0, NULL);
  goo_canvas_item_model_translate (item, 10.0, 10.0);
  g_object_set_data (G_OBJECT (item), "setup-dnd-signals", "TRUE");

  child = goo_canvas_rect_model_new (item, 10.0, 10.0, 50.0, 50.0, "fill-color", "blue", "x", 10.0, "y", 25.0, NULL);
  g_object_set_data (G_OBJECT (child), "setup-dnd-signals", "TRUE");
  goo_canvas_item_model_set_child_properties (item, child, "column", 0, "row", 0, "columns", 1, "rows", 1, NULL);
  /*goo_canvas_item_model_translate (child, 10.0, 10.0);*/

  child = goo_canvas_rect_model_new (item, 0.0, 0.0, 50.0, 50.0, "fill-color", "red", NULL);
  g_object_set_data (G_OBJECT (child), "setup-dnd-signals", "TRUE");
  goo_canvas_item_model_set_child_properties (item, child, "column", 1, "row", 0, "columns", 1, "rows", 1, NULL);

  child = goo_canvas_rect_model_new (item, 0.0, 0.0, 50.0, 50.0, "fill-color", "green", NULL);
  g_object_set_data (G_OBJECT (child), "setup-dnd-signals", "TRUE");
  goo_canvas_item_model_set_child_properties(item, child, "column", 0, "row", 1, "columns", 1, "rows", 1, NULL);

  child = goo_canvas_rect_model_new (item, 0.0, 0.0, 50.0, 50.0, "fill-color", "yellow", NULL);
  g_object_set_data (G_OBJECT (child), "setup-dnd-signals", "TRUE");
  goo_canvas_item_model_set_child_properties (item, child, "column", 1, "row", 1, "columns", 1, "rows", 1, NULL);

  return root;
}