Merge branch '1.0-integration'
authorEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 5 Jun 2009 13:17:16 +0000 (14:17 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 5 Jun 2009 13:17:16 +0000 (14:17 +0100)
* 1.0-integration:
  [gtk-clutter-test] Update for the clutter timeline changes
  [examples] Use different sized stages
  Updates for 1.0 API changes in Clutter
  Update for Clutter 1.0 API changes

Conflicts:
examples/gtk-clutter-multistage.c

clutter-gtk/gtk-clutter-embed.c
clutter-gtk/gtk-clutter-viewport.c
examples/gtk-clutter-events.c
examples/gtk-clutter-multistage.c
examples/gtk-clutter-test.c
examples/gtk-clutter-viewport.c

index 8bfec86..94269e0 100644 (file)
@@ -153,9 +153,6 @@ gtk_clutter_embed_realize (GtkWidget *widget)
   GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv; 
   GdkWindowAttr attributes;
   int attributes_mask;
-  
-  /* we must realize the stage to get it ready for embedding */
-  clutter_actor_realize (priv->stage);
 
 #ifdef HAVE_CLUTTER_GTK_X11
   {
@@ -165,6 +162,12 @@ gtk_clutter_embed_realize (GtkWidget *widget)
 
     /* We need to use the colormap from the Clutter visual */
     xvinfo = clutter_x11_get_stage_visual (CLUTTER_STAGE (priv->stage));
+    if (xvinfo == None)
+      {
+        g_critical ("Unable to retrieve the XVisualInfo from Clutter");
+        return;
+      }
+
     visual = gdk_x11_screen_lookup_visual (gtk_widget_get_screen (widget),
                                            xvinfo->visualid);
     colormap = gdk_colormap_new (visual, FALSE);
@@ -214,15 +217,25 @@ gtk_clutter_embed_realize (GtkWidget *widget)
                                   GDK_WINDOW_HWND (widget->window));
 #endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
 
+  clutter_actor_realize (priv->stage);
+
   if (GTK_WIDGET_VISIBLE (widget))
     clutter_actor_show (priv->stage);
 
-  clutter_actor_queue_redraw (CLUTTER_ACTOR (priv->stage));
-
   gtk_clutter_embed_send_configure (GTK_CLUTTER_EMBED (widget));
 }
 
 static void
+gtk_clutter_embed_unrealize (GtkWidget *widget)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  clutter_actor_hide (priv->stage);
+
+  GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->unrealize (widget);
+}
+
+static void
 gtk_clutter_embed_size_allocate (GtkWidget     *widget,
                                  GtkAllocation *allocation)
 {
@@ -361,17 +374,47 @@ gtk_clutter_embed_map_event (GtkWidget     *widget,
                              GdkEventAny *event)
 {
   GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+  GtkWidgetClass *parent_class;
+  gboolean res = FALSE;
 
-  /* The backend wont get the XEvent as we go strait to do_event().
-   * So we have to make sure we set the event here.
-  */
-  CLUTTER_ACTOR_SET_FLAGS (priv->stage, CLUTTER_ACTOR_MAPPED);
+  parent_class = GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class);
+  if (parent_class->map_event)
+    res = parent_class->map_event (widget, event);
 
-  return FALSE;
+  clutter_actor_map (priv->stage);
+
+  return res;
+}
+
+static gboolean
+gtk_clutter_embed_unmap_event (GtkWidget   *widget,
+                               GdkEventAny *event)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+  GtkWidgetClass *parent_class;
+  gboolean res = FALSE;
+
+  parent_class = GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class);
+  if (parent_class->unmap_event)
+    res = parent_class->unmap_event (widget, event);
+
+  clutter_actor_unmap (priv->stage);
+
+  return res;
+}
+
+static void
+gtk_clutter_embed_unmap (GtkWidget *widget)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  clutter_actor_unmap (priv->stage);
+
+  GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->unmap (widget);
 }
 
 static gboolean
-gtk_clutter_embed_focus_in (GtkWidget *widget,
+gtk_clutter_embed_focus_in (GtkWidget     *widget,
                             GdkEventFocus *event)
 {
   GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
@@ -480,8 +523,10 @@ gtk_clutter_embed_class_init (GtkClutterEmbedClass *klass)
   widget_class->style_set = gtk_clutter_embed_style_set;
   widget_class->size_allocate = gtk_clutter_embed_size_allocate;
   widget_class->realize = gtk_clutter_embed_realize;
+  widget_class->unrealize = gtk_clutter_embed_unrealize;
   widget_class->show = gtk_clutter_embed_show;
   widget_class->hide = gtk_clutter_embed_hide;
+  widget_class->unmap = gtk_clutter_embed_unmap;
   widget_class->expose_event = gtk_clutter_embed_expose_event;
   widget_class->button_press_event = gtk_clutter_embed_button_event;
   widget_class->button_release_event = gtk_clutter_embed_button_event;
@@ -490,6 +535,7 @@ gtk_clutter_embed_class_init (GtkClutterEmbedClass *klass)
   widget_class->motion_notify_event = gtk_clutter_embed_motion_notify_event;
   widget_class->expose_event = gtk_clutter_embed_expose_event;
   widget_class->map_event = gtk_clutter_embed_map_event;
+  widget_class->unmap_event = gtk_clutter_embed_unmap_event;
   widget_class->focus_in_event = gtk_clutter_embed_focus_in;
   widget_class->focus_out_event = gtk_clutter_embed_focus_out;
   widget_class->scroll_event = gtk_clutter_embed_scroll_event;
@@ -503,6 +549,7 @@ gtk_clutter_embed_init (GtkClutterEmbed *embed)
   embed->priv = priv = GTK_CLUTTER_EMBED_GET_PRIVATE (embed);
 
   GTK_WIDGET_SET_FLAGS (embed, GTK_CAN_FOCUS);
+  GTK_WIDGET_UNSET_FLAGS (embed, GTK_NO_WINDOW);
 
   /* disable double-buffering: it's automatically provided
    * by OpenGL
index 4adcae4..c46f29f 100644 (file)
@@ -147,10 +147,10 @@ viewport_adjustment_value_changed (GtkAdjustment      *adjustment,
     {
       GtkAdjustment *h_adjust = priv->h_adjustment;
       GtkAdjustment *v_adjust = priv->v_adjustment;
-      ClutterUnit new_x, new_y;
+      gfloat new_x, new_y;
 
-      new_x = CLUTTER_UNITS_FROM_FLOAT (gtk_adjustment_get_value (h_adjust));
-      new_y = CLUTTER_UNITS_FROM_FLOAT (gtk_adjustment_get_value (v_adjust));
+      new_x = gtk_adjustment_get_value (h_adjust);
+      new_y = gtk_adjustment_get_value (v_adjust);
 
       /* change the origin and queue a relayout */
       if (new_x != priv->origin.x || new_y != priv->origin.y)
@@ -184,7 +184,7 @@ viewport_reclamp_adjustment (GtkAdjustment *adjustment)
 
 static gboolean
 viewport_set_hadjustment_values (GtkClutterViewport *viewport,
-                                 guint               width)
+                                 gfloat              width)
 {
   GtkClutterViewportPrivate *priv = viewport->priv;
   GtkAdjustment *h_adjust = priv->h_adjustment;
@@ -196,15 +196,13 @@ viewport_set_hadjustment_values (GtkClutterViewport *viewport,
 
   if (priv->child && CLUTTER_ACTOR_IS_VISIBLE (priv->child))
     {
-      ClutterUnit natural_width;
+      gfloat natural_width;
 
       clutter_actor_get_preferred_size (priv->child,
                                         NULL, NULL,
                                         &natural_width, NULL);
 
-      gtk_adjustment_set_upper (h_adjust,
-                                MAX (CLUTTER_UNITS_TO_DEVICE (natural_width),
-                                     width));
+      gtk_adjustment_set_upper (h_adjust, MAX (natural_width, width));
     }
   else
     gtk_adjustment_set_upper (h_adjust, width);
@@ -214,7 +212,7 @@ viewport_set_hadjustment_values (GtkClutterViewport *viewport,
 
 static gboolean
 viewport_set_vadjustment_values (GtkClutterViewport *viewport,
-                                 guint               height)
+                                 gfloat              height)
 {
   GtkClutterViewportPrivate *priv = viewport->priv;
   GtkAdjustment *v_adjust = priv->v_adjustment;
@@ -228,15 +226,13 @@ viewport_set_vadjustment_values (GtkClutterViewport *viewport,
 
   if (priv->child && CLUTTER_ACTOR_IS_VISIBLE (priv->child))
     {
-      ClutterUnit natural_height;
+      gfloat natural_height;
 
       clutter_actor_get_preferred_size (priv->child,
                                         NULL, NULL,
                                         NULL, &natural_height);
 
-      gtk_adjustment_set_upper (v_adjust,
-                                MAX (CLUTTER_UNITS_TO_DEVICE (natural_height),
-                                     height));
+      gtk_adjustment_set_upper (v_adjust, MAX (natural_height, height));
     }
   else
     gtk_adjustment_set_upper (v_adjust, height);
@@ -272,7 +268,7 @@ connect_adjustment (GtkClutterViewport *viewport,
   GtkClutterViewportPrivate *priv = viewport->priv;
   GtkAdjustment **adj_p;
   gboolean value_changed = FALSE;
-  guint width, height;
+  gfloat width, height;
 
   adj_p = (orientation == GTK_ORIENTATION_HORIZONTAL) ? &priv->h_adjustment
                                                       : &priv->v_adjustment;
@@ -447,9 +443,9 @@ gtk_clutter_viewport_dispose (GObject *gobject)
 
 static void
 gtk_clutter_viewport_get_preferred_width (ClutterActor *actor,
-                                          ClutterUnit   for_height,
-                                          ClutterUnit  *min_width_p,
-                                          ClutterUnit  *natural_width_p)
+                                          gfloat        for_height,
+                                          gfloat       *min_width_p,
+                                          gfloat       *natural_width_p)
 {
   GtkClutterViewportPrivate *priv = GTK_CLUTTER_VIEWPORT (actor)->priv;
 
@@ -473,9 +469,9 @@ gtk_clutter_viewport_get_preferred_width (ClutterActor *actor,
 
 static void
 gtk_clutter_viewport_get_preferred_height (ClutterActor *actor,
-                                           ClutterUnit   for_width,
-                                           ClutterUnit  *min_height_p,
-                                           ClutterUnit  *natural_height_p)
+                                           gfloat        for_width,
+                                           gfloat       *min_height_p,
+                                           gfloat       *natural_height_p)
 {
   GtkClutterViewportPrivate *priv = GTK_CLUTTER_VIEWPORT (actor)->priv;
 
@@ -498,21 +494,21 @@ gtk_clutter_viewport_get_preferred_height (ClutterActor *actor,
 }
 
 static void
-gtk_clutter_viewport_allocate (ClutterActor          *actor,
-                               const ClutterActorBox *box,
-                               gboolean               origin_changed)
+gtk_clutter_viewport_allocate (ClutterActor           *actor,
+                               const ClutterActorBox  *box,
+                               ClutterAllocationFlags  flags)
 {
   GtkClutterViewport *viewport = GTK_CLUTTER_VIEWPORT (actor);
   GtkClutterViewportPrivate *priv = viewport->priv;
   ClutterActorClass *parent_class;
   gboolean h_adjustment_value_changed, v_adjustment_value_changed;
-  guint width, height;
+  gfloat width, height;
 
   parent_class = CLUTTER_ACTOR_CLASS (gtk_clutter_viewport_parent_class);
-  parent_class->allocate (actor, box, origin_changed);
+  parent_class->allocate (actor, box, flags);
 
-  width  = CLUTTER_UNITS_TO_DEVICE (box->x2 - box->x1);
-  height = CLUTTER_UNITS_TO_DEVICE (box->y2 - box->y1);
+  width  = box->x2 - box->x1;
+  height = box->y2 - box->y1;
 
   h_adjustment_value_changed =
     viewport_set_hadjustment_values (viewport, width);
@@ -522,7 +518,7 @@ gtk_clutter_viewport_allocate (ClutterActor          *actor,
   if (priv->child && CLUTTER_ACTOR_IS_VISIBLE (priv->child))
     {
       ClutterActorBox child_allocation = { 0, };
-      ClutterUnit alloc_width, alloc_height;
+      gfloat alloc_width, alloc_height;
 
       /* a viewport is a boundless actor which can contain a child
        * without constraints; hence, we give any child exactly the
@@ -533,12 +529,12 @@ gtk_clutter_viewport_allocate (ClutterActor          *actor,
                                         NULL, NULL,
                                         &alloc_width, &alloc_height);
 
-      child_allocation.x1 = clutter_actor_get_xu (priv->child);
-      child_allocation.y1 = clutter_actor_get_yu (priv->child);
+      child_allocation.x1 = clutter_actor_get_x (priv->child);
+      child_allocation.y1 = clutter_actor_get_y (priv->child);
       child_allocation.x2 = child_allocation.x1 + alloc_width;
       child_allocation.y2 = child_allocation.y1 + alloc_height;
 
-      clutter_actor_allocate (priv->child, &child_allocation, origin_changed);
+      clutter_actor_allocate (priv->child, &child_allocation, flags);
     }
 
   gtk_adjustment_changed (priv->h_adjustment);
@@ -561,9 +557,9 @@ gtk_clutter_viewport_paint (ClutterActor *actor)
   /* translate the paint environment by the same amount
    * defined by the origin value
    */
-  cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->origin.x) * -1,
-                  CLUTTER_UNITS_TO_FLOAT (priv->origin.y) * -1,
-                  CLUTTER_UNITS_TO_FLOAT (priv->origin.z) * -1);
+  cogl_translate (priv->origin.x * -1,
+                  priv->origin.y * -1,
+                  priv->origin.z * -1);
 
   /* the child will be painted in the new frame of reference */
   if (priv->child && CLUTTER_ACTOR_IS_VISIBLE (priv->child))
@@ -689,11 +685,11 @@ gtk_clutter_viewport_get_origin (GtkClutterViewport *viewport,
   priv = viewport->priv;
 
   if (x)
-    *x = CLUTTER_UNITS_TO_FLOAT (priv->origin.x);
+    *x = priv->origin.x;
 
   if (y)
-    *y = CLUTTER_UNITS_TO_FLOAT (priv->origin.y);
+    *y = priv->origin.y;
 
   if (z)
-    *z = CLUTTER_UNITS_TO_FLOAT (priv->origin.z);
+    *z = priv->origin.z;
 }
index 9673aeb..0396f86 100644 (file)
@@ -74,11 +74,11 @@ on_stage_capture (ClutterActor *actor,
 {
   if (event->type == CLUTTER_BUTTON_RELEASE)
     {
-      gint x, y;
+      gfloat x, y;
 
       clutter_event_get_coords (event, &x, &y);
 
-      g_print ("Event captured at (%d, %d)\n", x, y);
+      g_print ("Event captured at (%.2f, %.2f)\n", x, y);
     }
 
   return FALSE;
@@ -102,7 +102,7 @@ main (gint argc, gchar **argv)
   GtkWidget     *widget, *vbox, *hbox, *button, *label, *box;
   ClutterActor  *actor;
   GdkPixbuf     *pixbuf = NULL;
-  guint          width, height;
+  gfloat         width, height;
   ClutterColor   stage_color = {255, 255, 255, 255};
   ClutterColor   text_color = {0, 0, 0, 255};
 
index db8f1be..ef4623a 100644 (file)
@@ -4,14 +4,14 @@
 #include <clutter-gtk/clutter-gtk.h>
 
 static void
-on_stage2_allocation (GObject      *gobject,
-                      GParamSpec   *pspec,
-                      ClutterActor *texture)
+on_stage2_allocation_changed (ClutterActor           *stage_2,
+                              const ClutterActorBox  *allocation,
+                              ClutterAllocationFlags  flags,
+                              ClutterActor           *texture_2)
 {
-  gint width = clutter_actor_get_width (CLUTTER_ACTOR (gobject));
-  gint height = clutter_actor_get_height (CLUTTER_ACTOR (gobject));
-
-  clutter_actor_set_position (texture, width / 2, height / 2);
+  clutter_actor_set_position (texture_2,
+                              (allocation->x2 - allocation->x1) / 2,
+                              (allocation->y2 - allocation->y1) / 2);
 }
 
 int
@@ -62,12 +62,12 @@ main (int argc, char *argv[])
   clutter_actor_set_position (tex2, 160, 60);
   clutter_stage_add (stage2, tex2);
 
-  g_signal_connect (stage2, "notify::allocation",
-                    G_CALLBACK (on_stage2_allocation),
-                    tex2);
-
   gtk_container_add (GTK_CONTAINER (vbox), clutter2);
 
+  g_signal_connect (stage2, "allocation-changed",
+                    G_CALLBACK (on_stage2_allocation_changed),
+                    tex2);
+
   gtk_widget_show_all (window);
   clutter_actor_show_all (stage1); 
   clutter_actor_show_all (stage2); 
index 5b7f025..83e7c2d 100644 (file)
@@ -30,11 +30,11 @@ input_cb (ClutterStage *stage,
   if (event->type == CLUTTER_BUTTON_PRESS)
     {
       ClutterActor *a;
-      gint x, y;
+      gfloat x, y;
 
       clutter_event_get_coords (event, &x, &y);
 
-      a = clutter_stage_get_actor_at_pos (stage, x, y);
+      a = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y);
       if (a && (CLUTTER_IS_TEXTURE (a) || CLUTTER_IS_CLONE (a)))
        clutter_actor_hide (a);
     }
@@ -54,11 +54,12 @@ input_cb (ClutterStage *stage,
 /* Timeline handler */
 void
 frame_cb (ClutterTimeline *timeline, 
-         gint             frame_num, 
+         gint             msecs,
          gpointer         data)
 {
   SuperOH        *oh = (SuperOH *)data;
   gint            i;
+  guint           rotation = clutter_timeline_get_progress (timeline) * 360.0f;
 
 #if TRAILS
   oh->bgpixb = clutter_stage_snapshot (CLUTTER_STAGE (stage),
@@ -73,7 +74,7 @@ frame_cb (ClutterTimeline *timeline,
   /* Rotate everything clockwise about stage center*/
   clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
                               CLUTTER_Z_AXIS,
-                              frame_num,
+                              rotation,
                               WINWIDTH / 2, WINHEIGHT / 2, 0);
 
   for (i = 0; i < NHANDS; i++)
@@ -81,12 +82,12 @@ frame_cb (ClutterTimeline *timeline,
       /* rotate each hand around there centers */
       clutter_actor_set_rotation (oh->hand[i],
                                   CLUTTER_Z_AXIS,
-                                  - 6.0 * frame_num,
+                                  - 6.0 * rotation,
                                   clutter_actor_get_width (oh->hand[i]) / 2,
                                   clutter_actor_get_height (oh->hand[i]) / 2,
                                   0);
       if (fade == TRUE)
-        clutter_actor_set_opacity (oh->hand[i], (255 - (frame_num % 255)));
+        clutter_actor_set_opacity (oh->hand[i], (255 - (rotation % 255)));
     }
 
   /*
@@ -241,7 +242,7 @@ main (int argc, char *argv[])
   clutter_actor_show_all (CLUTTER_ACTOR (oh->group));
 
   /* Create a timeline to manage animation */
-  timeline = clutter_timeline_new (360, 60); /* num frames, fps */
+  timeline = clutter_timeline_new (6000);
   g_object_set(timeline, "loop", TRUE, NULL);   /* have it loop */
 
   /* fire a callback for frame change */
index 0125b41..f653424 100644 (file)
@@ -83,7 +83,7 @@ main (int argc, char *argv[])
                  G_STRLOC,
                  g_timer_elapsed (timer, NULL));
 
-      g_print ("%s: tex.size = %d, %d\n",
+      g_print ("%s: tex.size = %.2f, %.2f\n",
                G_STRLOC,
                clutter_actor_get_width (tex),
                clutter_actor_get_height (tex));