Commit 054342c5 authored by Bruno Coudoin's avatar Bruno Coudoin

Now shapegame tooltip is a a transparent rectangle instead

	of a fixed button. The rectangle follow the tooltip size to
	avoid the text growing after the button effect.

svn path=/branches/gcomprixogoo/; revision=3690
parent c682a381
2009-01-19 Bruno coudoin <bruno.coudoin@free.fr>
Now shapegame tooltip is a a transparent rectangle instead
of a fixed button. The rectangle follow the tooltip size to
avoid the text growing after the button effect.
* boards/skins/gartoon/skin.svg:
* src/babymatch-activity/shapegame.c: (process_ok),
(shapegame_init_canvas), (item_event):
* src/imageid-activity/imageid.c: (imageid_create_item),
(highlight_selected):
2009-01-19 Bruno coudoin <bruno.coudoin@free.fr>
Now the target activity has a tooltip on each dart to let
......
This diff is collapsed.
......@@ -115,8 +115,6 @@ static GooCanvasItem *tooltip_bg_item;
/* The continue button */
static GooCanvasItem *continue_root_item;
static GooCanvasItem *continue_text_item;
static GooCanvasItem *continue_bg_item;
static void start_board (GcomprisBoard *agcomprisBoard);
static void pause_board (gboolean pause);
......@@ -451,9 +449,6 @@ static void process_ok()
gamewon = TRUE;
/* Show the tooltip to let the user continue the game */
g_object_set(continue_text_item,
"text", _("Continue"),
NULL);
g_object_set (continue_root_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
}
......@@ -510,7 +505,6 @@ static void shapegame_destroy_all_items()
static void shapegame_init_canvas(GooCanvasItem *parent)
{
GdkPixbuf *pixmap = NULL;
shape_root_item = goo_canvas_group_new (parent, NULL);
goo_canvas_item_translate(shape_root_item,
......@@ -525,25 +519,29 @@ static void shapegame_init_canvas(GooCanvasItem *parent)
goo_canvas_item_translate(tooltip_root_item, 10, BOARDHEIGHT-70);
pixmap = gc_skin_pixmap_load("button_large.png");
tooltip_bg_item = \
goo_canvas_image_new (tooltip_root_item,
pixmap,
0,
0,
NULL);
goo_canvas_rect_new (tooltip_root_item,
0,
0,
0,
0,
"stroke_color_rgba", 0xFFFFFFFFL,
"fill_color_rgba", 0x0000FF90L,
"line-width", (double) 2,
"radius-x", (double) 10,
"radius-y", (double) 10,
NULL);
tooltip_text_item = \
goo_canvas_text_new (tooltip_root_item,
"",
gdk_pixbuf_get_width(pixmap)/2,
24.0,
15,
15,
-1,
GTK_ANCHOR_CENTER,
GTK_ANCHOR_WEST,
"font", gc_skin_font_board_small,
"fill_color_rgba", gc_skin_color_text_button,
NULL);
gdk_pixbuf_unref(pixmap);
/* Hide the tooltip */
g_object_set (tooltip_root_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
......@@ -555,34 +553,18 @@ static void shapegame_init_canvas(GooCanvasItem *parent)
goo_canvas_item_translate(continue_root_item, 5, 5);
pixmap = gc_skin_pixmap_load("button_large.png");
continue_bg_item = \
goo_canvas_image_new (continue_root_item,
pixmap,
0,
0,
NULL);
continue_text_item = \
goo_canvas_text_new (continue_root_item,
"",
gdk_pixbuf_get_width(pixmap)/2,
24.0,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_small,
"fill_color_rgba", gc_skin_color_text_button,
NULL);
gdk_pixbuf_unref(pixmap);
continue_root_item = \
goo_canvas_svg_new (continue_root_item,
gc_skin_rsvg_get(),
"svg-id", "#OK",
NULL);
SET_ITEM_LOCATION(continue_root_item, 15, 15);
gc_item_focus_init(continue_root_item, NULL);
g_signal_connect(continue_root_item,
"button_press_event",
(GtkSignalFunc) item_event_ok,
"continue_click");
g_signal_connect(continue_text_item,
"button_press_event",
(GtkSignalFunc) item_event_ok,
"continue_click");
/* Hide the continue */
g_object_set (continue_root_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
......@@ -1100,6 +1082,15 @@ item_event(GooCanvasItem *item, GooCanvasItem *target,
"text", shape->tooltip,
NULL);
g_object_set (tooltip_root_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
/* Set the background */
GooCanvasBounds bounds;
goo_canvas_item_get_bounds (tooltip_text_item, &bounds);
g_object_set(tooltip_bg_item,
"width", bounds.x2 - bounds.x1 + 30,
"height", bounds.y2 - bounds.y1 + 15,
NULL);
}
break;
......
......@@ -288,7 +288,6 @@ imageid_create_item(GooCanvasItem *parent)
int x, y, xp, yp;
guint vertical_separation;
GdkPixbuf *pixmap = NULL;
GdkPixbuf *button_pixmap = NULL;
Board *board;
guint i;
......@@ -300,7 +299,6 @@ imageid_create_item(GooCanvasItem *parent)
goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
NULL);
button_pixmap = gc_skin_pixmap_load("button_large.png");
/* display the image */
board = g_list_nth_data(board_list, board_number);
g_assert(board != NULL);
......@@ -328,8 +326,10 @@ imageid_create_item(GooCanvasItem *parent)
vertical_separation = 10 + 60 / i;
guint button_pixmap_height = 48;
guint button_pixmap_width = 191;
yp = (BOARDHEIGHT -
i * gdk_pixbuf_get_height(button_pixmap)
i * button_pixmap_height
- 2 * vertical_separation)/2 - 20;
i = 0;
......@@ -338,11 +338,13 @@ imageid_create_item(GooCanvasItem *parent)
group = goo_canvas_group_new (boardRootItem,
NULL);
button = goo_canvas_image_new (group,
button_pixmap,
xp,
yp,
NULL);
button = goo_canvas_svg_new (group,
gc_skin_rsvg_get(),
"svg-id", "#BUTTON_TEXT",
NULL);
SET_ITEM_LOCATION(button,
xp,
yp);
g_object_set_data(G_OBJECT(group),
"button", button);
......@@ -353,8 +355,8 @@ imageid_create_item(GooCanvasItem *parent)
item = goo_canvas_text_new (group,
board->text[i],
xp + gdk_pixbuf_get_width(button_pixmap)/2 + 1.0,
yp + gdk_pixbuf_get_height(button_pixmap)/2 + 1.0,
xp + button_pixmap_width/2 + 1.0,
yp + button_pixmap_height/2 + 1.0,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_big,
......@@ -367,8 +369,8 @@ imageid_create_item(GooCanvasItem *parent)
item = goo_canvas_text_new (group,
board->text[i],
xp + gdk_pixbuf_get_width(button_pixmap)/2,
yp + gdk_pixbuf_get_height(button_pixmap)/2,
xp + button_pixmap_width/2,
yp + button_pixmap_height/2,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_big,
......@@ -379,13 +381,11 @@ imageid_create_item(GooCanvasItem *parent)
(GtkSignalFunc) item_event,
GINT_TO_POINTER(i));
yp += gdk_pixbuf_get_height(button_pixmap) + vertical_separation;
yp += button_pixmap_height + vertical_separation;
i++;
}
gdk_pixbuf_unref(button_pixmap);
}
/* ==================================== */
static void game_won()
......@@ -456,21 +456,19 @@ item_event (GooCanvasItem *item,
static void
highlight_selected(GooCanvasItem * button)
{
GdkPixbuf *button_pixmap_selected = NULL, *button_pixmap = NULL;
if (selected_button != NULL && selected_button != button)
{
button_pixmap = gc_skin_pixmap_load("button_large.png");
g_object_set(selected_button, "pixbuf", button_pixmap, NULL);
gdk_pixbuf_unref(button_pixmap);
g_object_set(selected_button,
"svg-id", "#BUTTON_TEXT",
NULL);
}
if (selected_button != button)
{
button_pixmap_selected = gc_skin_pixmap_load("button_large_selected.png");
g_object_set(button, "pixbuf", button_pixmap_selected, NULL);
g_object_set(button,
"svg-id", "#BUTTON_TEXT_SELECTED",
NULL);
selected_button = button;
gdk_pixbuf_unref(button_pixmap_selected);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment