gcompris r3660 - in branches/gcomprixogoo: . boards/skins/gartoon src/boards src/gcompris
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3660 - in branches/gcomprixogoo: . boards/skins/gartoon src/boards src/gcompris
- Date: Thu, 1 Jan 2009 18:06:05 +0000 (UTC)
Author: bcoudoin
Date: Thu Jan 1 18:06:05 2009
New Revision: 3660
URL: http://svn.gnome.org/viewvc/gcompris?rev=3660&view=rev
Log:
Added an API entry gc_set_background_by_id to ease
SVG integration.
Now the menu uses the svg data from the skin.svg file.
Modified:
branches/gcomprixogoo/ChangeLog
branches/gcomprixogoo/boards/skins/gartoon/skin.svg
branches/gcomprixogoo/src/boards/menu2.c
branches/gcomprixogoo/src/gcompris/bar.c
branches/gcomprixogoo/src/gcompris/gameutil.h
branches/gcomprixogoo/src/gcompris/gcompris.c
branches/gcomprixogoo/src/gcompris/gcompris.h
branches/gcomprixogoo/src/gcompris/skin.c
branches/gcomprixogoo/src/gcompris/skin.h
Modified: branches/gcomprixogoo/boards/skins/gartoon/skin.svg
==============================================================================
--- branches/gcomprixogoo/boards/skins/gartoon/skin.svg (original)
+++ branches/gcomprixogoo/boards/skins/gartoon/skin.svg Thu Jan 1 18:06:05 2009
@@ -825,14 +825,14 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7713475"
- inkscape:cx="475.27364"
+ inkscape:cx="371.55904"
inkscape:cy="214.7962"
inkscape:current-layer="layer1"
id="namedview6255"
inkscape:window-width="768"
- inkscape:window-height="713"
- inkscape:window-x="50"
- inkscape:window-y="6"
+ inkscape:window-height="726"
+ inkscape:window-x="361"
+ inkscape:window-y="25"
showguides="true"
inkscape:guide-bbox="true"
showgrid="false">
@@ -898,7 +898,7 @@
</g>
<g
id="BUTTON_VERTICAL"
- transform="matrix(0.8480242,0,0,1.0177439,-665.61044,-83.993068)">
+ transform="matrix(0.835729,0,0,1.0177439,-654.5275,-83.993068)">
<rect
transform="matrix(0,-1,1,0,0,0)"
ry="6.491662"
@@ -940,7 +940,7 @@
</g>
<g
id="BUTTON_HORIZONTAL"
- transform="translate(-116.4466,-83.539846)">
+ transform="matrix(1,0,0,0.857803,-116.4466,-70.99222)">
<rect
ry="14.636374"
y="89.449387"
Modified: branches/gcomprixogoo/src/boards/menu2.c
==============================================================================
--- branches/gcomprixogoo/src/boards/menu2.c (original)
+++ branches/gcomprixogoo/src/boards/menu2.c Thu Jan 1 18:06:05 2009
@@ -215,8 +215,9 @@
if(agcomprisBoard != NULL)
{
- gchar *img;
+ RsvgHandle *svg_handle;
+ printf("menu2 start\n");
gcomprisBoard=agcomprisBoard;
/* set initial values for this level */
@@ -228,10 +229,11 @@
menuitems = g_new(MenuItems, 1);
- img = gc_skin_image_get("gcompris-menu2bg.png");
- gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
- img);
- g_free(img);
+ svg_handle = gc_skin_rsvg_get();
+
+ gc_set_background_by_id (goo_canvas_get_root_item(gcomprisBoard->canvas),
+ svg_handle,
+ "#BACKGROUND");
boardRootItem = \
goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
@@ -240,6 +242,18 @@
g_object_set_data_full(G_OBJECT (boardRootItem),
"menuitems", menuitems, g_free);
+ goo_canvas_svg_new (boardRootItem,
+ svg_handle,
+ "svg-id", "#BUTTON_VERTICAL",
+ "pointer-events", GOO_CANVAS_EVENTS_NONE,
+ NULL);
+
+ goo_canvas_svg_new (boardRootItem,
+ svg_handle,
+ "svg-id", "#BUTTON_HORIZONTAL",
+ "pointer-events", GOO_CANVAS_EVENTS_NONE,
+ NULL);
+
create_info_area(boardRootItem, menuitems);
create_panel(boardRootItem);
Modified: branches/gcomprixogoo/src/gcompris/bar.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/bar.c (original)
+++ branches/gcomprixogoo/src/gcompris/bar.c Thu Jan 1 18:06:05 2009
@@ -28,18 +28,6 @@
#include "gcompris_config.h"
#include "about.h"
-// Reset the item at its 0,0 coordinate and then translate
-// it to x,y
-#define SET_ITEM_LOCATION(item, x, y) \
- { \
- GooCanvasBounds bounds; \
- goo_canvas_item_set_transform(item, NULL); \
- goo_canvas_item_get_bounds(item, &bounds); \
- goo_canvas_item_translate(item, \
- -1 * bounds.x1 + x, \
- -1 * bounds.y1 + y); \
- }
-
#define SOUNDLISTFILE PACKAGE
#define BAR_GAP 10 /* Value used to fill space above and under icons in the bar */
@@ -176,7 +164,7 @@
rootitem = goo_canvas_group_new (goo_canvas_get_root_item(theCanvas), NULL);
- svg_handle = gc_skin_rsvg_load("skin.svg");
+ svg_handle = gc_skin_rsvg_get();
bar_item = goo_canvas_svg_new (rootitem,
svg_handle,
"svg-id", "#BAR_BG",
@@ -185,12 +173,8 @@
SET_ITEM_LOCATION(bar_item, 0, 0);
goo_canvas_item_get_bounds(bar_item, &bounds);
- printf("height-BAR_GAP=%d\n", height-BAR_GAP);
zoom = (double)(height-BAR_GAP)/(bounds.y2 - bounds.y1);
- printf("bar width=%f\n", (bounds.x2 - bounds.x1));
- printf("bar height=%f\n", (bounds.y2 - bounds.y1));
buttony = (height-(bounds.y2 - bounds.y1)*zoom)/2 - 20;
- printf("zoom=%f buttony=%d\n", zoom, buttony);
/*
* The Order in which buttons are created represents
@@ -249,7 +233,7 @@
svg_handle,
GC_BAR_LEVEL,
"#LEVEL_UP");
- goo_canvas_item_translate(item, 45, 0);
+ goo_canvas_item_translate(item, 50, 0);
g_object_set (item,
"visibility", GOO_CANVAS_ITEM_VISIBLE,
NULL);
@@ -260,7 +244,7 @@
goo_canvas_text_new (rootitem_level,
"",
bounds.x1 - 10,
- (bounds.y2 - bounds.y1) / 2,
+ (bounds.y2 - bounds.y1) / 2 + 4,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_title_bold,
Modified: branches/gcomprixogoo/src/gcompris/gameutil.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gameutil.h (original)
+++ branches/gcomprixogoo/src/gcompris/gameutil.h Thu Jan 1 18:06:05 2009
@@ -39,6 +39,21 @@
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
+// This is especially usefull for SVG images that are loaded
+// by their Ids and that are not at the 0,0 coordinate in the
+// source file.
+// This reset the item at its 0,0 coordinate and then translate
+// it to x,y
+#define SET_ITEM_LOCATION(item, x, y) \
+ { \
+ GooCanvasBounds bounds; \
+ goo_canvas_item_set_transform(item, NULL); \
+ goo_canvas_item_get_bounds(item, &bounds); \
+ goo_canvas_item_translate(item, \
+ -1 * bounds.x1 + x, \
+ -1 * bounds.y1 + y); \
+ }
+
gchar *g_utf8_strndup(gchar*,gint);
gchar *reactivate_newline(char *str);
Modified: branches/gcomprixogoo/src/gcompris/gcompris.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gcompris.c (original)
+++ branches/gcomprixogoo/src/gcompris/gcompris.c Thu Jan 1 18:06:05 2009
@@ -44,8 +44,6 @@
#include "gcompris-nsbundle.h"
#endif
-#include <librsvg/rsvg.h>
-
/* get the default database name */
#define DEFAULT_DATABASE "gcompris_sqlite.db"
@@ -525,6 +523,22 @@
}
+void _clear_svg_background()
+{
+ if(backgroundsvgimg)
+ goo_canvas_item_remove(backgroundsvgimg);
+
+ backgroundsvgimg = NULL;
+}
+
+void _clear_pixmap_background()
+{
+ if(backgroundimg)
+ goo_canvas_item_remove(backgroundimg);
+
+ backgroundimg = NULL;
+}
+
void
gc_set_background(GooCanvasItem *parent, gchar *file)
{
@@ -542,14 +556,34 @@
}
else
{
- if(backgroundsvgimg)
- goo_canvas_item_remove(backgroundsvgimg);
-
- backgroundsvgimg = NULL;
+ _clear_svg_background();
_set_pixmap_background(parent, file);
}
}
+void
+gc_set_background_by_id(GooCanvasItem *parent, RsvgHandle *rsvg_handle,
+ gchar *id)
+{
+ g_assert(parent);
+ g_assert(rsvg_handle);
+
+ _clear_pixmap_background();
+
+ if(backgroundsvgimg)
+ g_object_set(backgroundsvgimg,
+ "svg-handle", rsvg_handle,
+ "svg-id", id,
+ NULL);
+ else
+ backgroundsvgimg = goo_canvas_svg_new (parent,
+ rsvg_handle,
+ "svg-id", id,
+ NULL);
+
+ goo_canvas_item_lower(backgroundsvgimg, NULL);
+}
+
/* Redraw the black background
*/
static gboolean
Modified: branches/gcomprixogoo/src/gcompris/gcompris.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gcompris.h (original)
+++ branches/gcomprixogoo/src/gcompris/gcompris.h Thu Jan 1 18:06:05 2009
@@ -62,6 +62,8 @@
#include "dmalloc.h"
#endif
+#include <librsvg/rsvg.h>
+
#define BOARDWIDTH 800
#define BOARDHEIGHT 520
#define BARHEIGHT 40
@@ -84,6 +86,9 @@
void gc_bar_start (GooCanvas *theCanvas);
void gc_set_background(GooCanvasItem *parent, gchar *file);
+void gc_set_background_by_id(GooCanvasItem *parent,
+ RsvgHandle *rsvg_handle,
+ gchar *id);
void gc_bar_set_level (GcomprisBoard *gcomprisBoard);
void gc_bar_set_repeat_icon (GdkPixbuf *pixmap);
Modified: branches/gcomprixogoo/src/gcompris/skin.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/skin.c (original)
+++ branches/gcomprixogoo/src/gcompris/skin.c Thu Jan 1 18:06:05 2009
@@ -102,6 +102,26 @@
}
/*
+ * Return the rsvg_handle of skin.svg from the current
+ * skin directory.
+ * If not found, try in the default skin directory
+ * If not found abort gcompris
+ */
+RsvgHandle *
+gc_skin_rsvg_get()
+{
+ /* Return value is cached, we don't support skin change on the fly */
+ static RsvgHandle *result_svg = NULL;
+
+ if (result_svg)
+ return result_svg;
+
+ result_svg = gc_skin_rsvg_load("skin.svg");
+
+ return (result_svg);
+}
+
+/*
* Load a pixmap from the current skin directory
* If not found, try in the default skin directory
* If not found abort gcompris
Modified: branches/gcomprixogoo/src/gcompris/skin.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/skin.h (original)
+++ branches/gcomprixogoo/src/gcompris/skin.h Thu Jan 1 18:06:05 2009
@@ -46,6 +46,7 @@
gchar *gc_skin_image_get(gchar *imagename);
GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile);
+RsvgHandle *gc_skin_rsvg_get();
RsvgHandle *gc_skin_rsvg_load(char *pixmapfile);
void gc_skin_load (gchar* skin);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]