summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gbeauchesne@splitted-desktop.com>2010-05-13 12:23:32 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2010-05-13 12:23:32 +0100
commitc135bb79bc576d219707d5290fcd8a74a764f07f (patch)
tree99f540e860f7e5d1df8e85ced1cccb5184b7ee5d
parent2c8760b78fabf496cfca2cd903d98c0b9cd7ac08 (diff)
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.
-rw-r--r--examples/video-player.c42
1 files 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
@@ -256,6 +256,28 @@ size_change (ClutterTexture *texture,
}
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,
VideoApp *app)
@@ -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");