From c135bb79bc576d219707d5290fcd8a74a764f07f Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 13 May 2010 12:23:32 +0100 Subject: player: Center controls on "fullscreen" event Under certain circumstances, the controls can be oversized wrt. the actual display size because the panel size was determined with older (smaller) stage size. Anyway, this patch resizes controls to fit the new stage size, on "fullscreen" event. --- examples/video-player.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/examples/video-player.c b/examples/video-player.c index ea3f4fd..0bf53fb 100644 --- a/examples/video-player.c +++ b/examples/video-player.c @@ -255,6 +255,28 @@ size_change (ClutterTexture *texture, clutter_actor_set_size (CLUTTER_ACTOR (texture), new_width, new_height); } +static void +center_controls (VideoApp *app, ClutterActor *controls) +{ + gfloat x, y, stage_width, stage_height; + + clutter_actor_get_size (app->stage, &stage_width, &stage_height); + + x = (stage_width - clutter_actor_get_width (controls)) / 2; + y = stage_height - (stage_height / 3); + + g_print ("setting x = %.2f, y = %.2f, width = %.2f\n", + x, y, clutter_actor_get_width (controls)); + + clutter_actor_set_position (controls, x, y); +} + +static void +on_fullscreen (ClutterStage *stage, VideoApp *app) +{ + center_controls (app, app->control); +} + static void tick (GObject *object, GParamSpec *pspec, @@ -276,7 +298,6 @@ main (int argc, char *argv[]) ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 }; ClutterColor control_color1 = { 73, 74, 77, 0xee }; ClutterColor control_color2 = { 0xcc, 0xcc, 0xcc, 0xff }; - gfloat x,y; clutter_gst_init (&argc, &argv); @@ -297,6 +318,11 @@ main (int argc, char *argv[]) if (app->vtexture == NULL) g_error("failed to create vtexture"); + g_signal_connect (stage, + "fullscreen", + G_CALLBACK (on_fullscreen), + app); + /* Dont let the underlying pixbuf dictate size */ g_object_set (G_OBJECT(app->vtexture), "sync-size", FALSE, NULL); @@ -365,19 +391,7 @@ main (int argc, char *argv[]) g_print ("start\n"); - { - gfloat stage_width, stage_height; - - clutter_actor_get_size (stage, &stage_width, &stage_height); - - x = (stage_width - clutter_actor_get_width (app->control)) / 2; - y = stage_height - (stage_height / 3); - } - - g_print ("setting x = %.2f, y = %.2f, width = %.2f\n", - x, y, clutter_actor_get_width (app->control)); - - clutter_actor_set_position (app->control, x, y); + center_controls (app, app->control); g_print ("stop\n"); -- cgit v1.2.1