Commit 119419bd authored by Bruno Coudoin's avatar Bruno Coudoin

implemented a movable bar

svn path=/branches/gcomprixogoo/; revision=3258
parent c2bac7c3
......@@ -48,6 +48,8 @@ static gboolean item_event_bar (GooCanvasItem *item,
gchar *data);
static void bar_reset_sound_id (void);
static void setup_item_signals (GooCanvasItem *item, gchar* name);
static void _bar_down();
static void _bar_up();
static gint current_level = -1;
static gint current_flags = -1;
......@@ -60,6 +62,7 @@ static GooCanvasItem *help_item = NULL;
static GooCanvasItem *repeat_item = NULL;
static GooCanvasItem *config_item = NULL;
static GooCanvasItem *about_item = NULL;
static GooCanvasItem *rootitem = NULL;
static gint sound_play_id = 0;
......@@ -79,7 +82,6 @@ void gc_bar_start (GooCanvas *theCanvas)
{
GcomprisProperties *properties = gc_prop_get();
GdkPixbuf *pixmap = NULL;
GooCanvasItem *rootitem;
gint16 width, height;
double zoom;
......@@ -89,13 +91,15 @@ void gc_bar_start (GooCanvas *theCanvas)
bar_reset_sound_id();
rootitem = goo_canvas_group_new (goo_canvas_get_root_item(theCanvas), NULL);
goo_canvas_item_translate(rootitem, 0, BOARDHEIGHT - BARHEIGHT);
pixmap = gc_skin_pixmap_load("bar_bg.jpg");
pixmap = gc_skin_pixmap_load("bar_bg.png");
bar_item = goo_canvas_image_new (rootitem,
pixmap,
0,
0,
NULL);
setup_item_signals(bar_item, "bar");
gdk_pixbuf_unref(pixmap);
// EXIT
......@@ -231,7 +235,10 @@ void gc_bar_start (GooCanvas *theCanvas)
g_object_set (about_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);}
NULL);
_bar_down();
}
void gc_bar_set_level(GcomprisBoard *gcomprisBoard)
......@@ -378,6 +385,35 @@ gc_bar_set (const GComprisBarFlags flags)
}
static void
_bar_down()
{
goo_canvas_item_animate(rootitem,
0,
BOARDHEIGHT - 20,
1,
0,
TRUE,
1000,
80,
GOO_CANVAS_ANIMATE_FREEZE);
}
static void
_bar_up()
{
goo_canvas_item_raise(rootitem, NULL);
goo_canvas_item_animate(rootitem,
0,
BOARDHEIGHT - BARHEIGHT,
1,
0,
TRUE,
700,
80,
GOO_CANVAS_ANIMATE_FREEZE);
}
/* Hide all icons in the control bar
* or retore the icons to the previous value
*/
......@@ -385,11 +421,7 @@ void
gc_bar_hide (gboolean hide)
{
/* Non yet initialized : Something Wrong */
if(level_item==NULL)
{
g_message("in bar_set_level, level_item uninitialized : should not happen\n");
return;
}
g_assert(level_item);
if(hide)
{
......@@ -411,12 +443,14 @@ gc_bar_hide (gboolean hide)
"visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
g_object_set(about_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
}
else
{
g_object_set(home_item,
"visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
gc_bar_set(current_flags);
}
}
......@@ -487,6 +521,7 @@ on_enter_notify (GooCanvasItem *item,
{
bar_reset_sound_id();
sound_play_id = g_timeout_add (1000, (GtkFunction) bar_play_sound, data);
_bar_up();
return FALSE;
}
......@@ -497,6 +532,7 @@ on_leave_notify (GooCanvasItem *item,
char *data)
{
bar_reset_sound_id();
_bar_down();
return FALSE;
}
......@@ -624,5 +660,6 @@ setup_item_signals (GooCanvasItem *item, gchar* name)
(GtkSignalFunc) item_event_bar,
name);
gc_item_focus_init(item, NULL);
if(strcmp(name, "bar"))
gc_item_focus_init(item, NULL);
}
......@@ -250,7 +250,12 @@ void gc_item_focus_init(GooCanvasItem *source_item,
target_item = source_item;
goo_canvas_item_get_bounds(target_item, &bounds);
goo_canvas_convert_to_item_space(goo_canvas_item_get_canvas(target_item),
goo_canvas_item_get_parent(target_item),
&bounds.x1, &bounds.y1);
goo_canvas_convert_to_item_space(goo_canvas_item_get_canvas(target_item),
goo_canvas_item_get_parent(target_item),
&bounds.x2, &bounds.y2);
highlight_item = g_object_get_data (G_OBJECT(target_item),
"highlight_item");
......
......@@ -58,7 +58,6 @@ static gchar *lock_file;
static GtkWidget *window;
static GtkWidget *canvas;
static GtkWidget *canvas_bar;
static GtkWidget *fixed;
static GtkWidget *drawing_area;
gchar * exec_prefix = NULL;
......@@ -280,9 +279,9 @@ _gc_configure_event_callback (GtkWidget *widget,
&screen_width,
&screen_height);
yratio=screen_height/(float)(BOARDHEIGHT+BARHEIGHT);
yratio=screen_height/(float)(BOARDHEIGHT);
xratio=screen_width/(float)BOARDWIDTH;
zoom_factor=MIN(xratio, yratio);
zoom_factor = MIN(xratio, yratio);
g_message("The screen_width=%f screen_height=%f ratio=%f\n",
(double)screen_width, (double)screen_height, zoom_factor);
......@@ -290,15 +289,7 @@ _gc_configure_event_callback (GtkWidget *widget,
goo_canvas_set_scale (GOO_CANVAS(canvas), zoom_factor);
gtk_fixed_move(GTK_FIXED(fixed), canvas,
(screen_width-BOARDWIDTH*zoom_factor)/2,
(screen_height-(BOARDHEIGHT+BARHEIGHT)*zoom_factor)/2);
gtk_widget_set_usize (GTK_WIDGET(canvas_bar),
BOARDWIDTH*zoom_factor, BARHEIGHT*zoom_factor);
goo_canvas_set_scale (GOO_CANVAS(canvas_bar), zoom_factor);
gtk_fixed_move(GTK_FIXED(fixed), canvas_bar,
(screen_width-BOARDWIDTH*zoom_factor)/2,
(screen_height-(BOARDHEIGHT+BARHEIGHT)*zoom_factor)/2
+ BOARDHEIGHT*zoom_factor);
(screen_height-BOARDHEIGHT*zoom_factor)/2);
_expose_background_callback (drawing_area, NULL, NULL);
......@@ -616,7 +607,7 @@ static void
init_background()
{
drawing_area = gtk_drawing_area_new ();
gtk_widget_set_size_request (drawing_area, BOARDWIDTH, BOARDHEIGHT+BARHEIGHT);
gtk_widget_set_size_request (drawing_area, BOARDWIDTH, BOARDHEIGHT);
g_signal_connect (G_OBJECT (drawing_area), "expose_event",
G_CALLBACK (_expose_background_callback), NULL);
/* Create a vertical box in which I put first the play board area, then the button bar */
......@@ -625,11 +616,9 @@ init_background()
gtk_fixed_put (GTK_FIXED(fixed), GTK_WIDGET(drawing_area), 0, 0);
gtk_fixed_put (GTK_FIXED(fixed), GTK_WIDGET(canvas), 0, 0);
gtk_fixed_put (GTK_FIXED(fixed), GTK_WIDGET(canvas_bar), 0, BOARDHEIGHT);
gtk_widget_show (GTK_WIDGET(fixed));
gtk_widget_show (GTK_WIDGET(canvas));
gtk_widget_show (GTK_WIDGET(canvas_bar));
gtk_widget_set_usize (GTK_WIDGET(canvas), BOARDWIDTH, BOARDHEIGHT);
goo_canvas_set_bounds (GOO_CANVAS(canvas),
......@@ -637,11 +626,6 @@ init_background()
BOARDWIDTH,
BOARDHEIGHT);
gtk_widget_set_usize (canvas_bar, BOARDWIDTH, BARHEIGHT);
goo_canvas_set_bounds (GOO_CANVAS(canvas_bar),
0, 0,
BOARDWIDTH,
BARHEIGHT);
}
static void setup_window ()
......@@ -691,8 +675,8 @@ static void setup_window ()
hints.min_height = 144;
hints.width_inc = 1;
hints.height_inc = 1;
hints.min_aspect = (float)BOARDWIDTH/(BOARDHEIGHT+BARHEIGHT);
hints. max_aspect = (float)BOARDWIDTH/(BOARDHEIGHT+BARHEIGHT);
hints.min_aspect = (float)BOARDWIDTH/BOARDHEIGHT;
hints. max_aspect = (float)BOARDWIDTH/BOARDHEIGHT;
gtk_window_set_geometry_hints (GTK_WINDOW (window),
NULL,
&hints,
......@@ -727,9 +711,7 @@ static void setup_window ()
// Set the cursor
gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR);
/* For non anti alias canvas */
canvas = goo_canvas_new();
canvas_bar = goo_canvas_new();
g_object_set (G_OBJECT(goo_canvas_get_root_item(GOO_CANVAS(canvas))),
"can-focus", TRUE,
......@@ -741,9 +723,6 @@ static void setup_window ()
g_signal_connect_after (canvas,
"key_press_event",
GTK_SIGNAL_FUNC (board_widget_key_press_callback), 0);
g_signal_connect_after (canvas_bar,
"key_press_event",
GTK_SIGNAL_FUNC (board_widget_key_press_callback), 0);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
gtk_widget_grab_focus (canvas);
......@@ -799,7 +778,7 @@ static void setup_window ()
}
/* Run the bar */
gc_bar_start(GOO_CANVAS(canvas_bar));
gc_bar_start(GOO_CANVAS(canvas));
init_background();
......
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