static gboolean
move_actors (ClutterActor *actor,
             ClutterEvent *event,
             gpointer      user_data)
{
  State *state = user_data;
  ClutterActor *child;

  /* do nothing if the animator is already running */
  if (clutter_timeline_is_playing (clutter_animator_get_timeline (state->animator)))
    return TRUE;

  /* remove all keys from the animator */
  clutter_animator_remove_key (state->animator, NULL, NULL, -1);

  /* add keys for all actors in the group */
  for (child = clutter_actor_get_first_child (state->group);
       child != NULL;
       child = clutter_actor_get_next_sibling (child))
    {
      add_keys_for_actor (child, state->animator);
    }

  /* start the animation */
  clutter_animator_start (state->animator);

  return TRUE;
}
Exemple #2
0
static void
mex_shell_child_data_free (MexShell *self, MexShellChildData *data)
{
  ClutterTimeline *timeline = clutter_animator_get_timeline (data->animator);

  if (clutter_timeline_is_playing (timeline))
    mex_shell_timeline_completed_cb (timeline, self);

  clutter_animator_remove_key (data->animator, NULL, NULL, -1);
  g_object_unref (data->animator);
  g_slice_free (MexShellChildData, data);
}
Exemple #3
0
void
mex_shell_present (MexShell          *shell,
                   ClutterActor      *actor,
                   MexShellDirection  in)
{
  GList *l;
  ClutterActor *stage;
  ClutterActorBox box;
  MexShellPrivate *priv;
  MexShellChildData *data;
  gfloat x, y, width, height;

  g_return_if_fail (MEX_IS_SHELL (shell));
  g_return_if_fail (CLUTTER_IS_ACTOR (actor));

  priv = shell->priv;
  l = g_list_find_custom (priv->children, actor, mex_shell_find_child);
  if (!l)
    {
      g_warning (G_STRLOC ": Attempted to present an unknown child.");
      return;
    }
  data = l->data;

  clutter_actor_get_allocation_box (CLUTTER_ACTOR (shell), &box);
  width = box.x2 - box.x1;
  height = box.y2 - box.y1;
  x = 0;
  y = 0;

  if (clutter_actor_get_opacity (data->child) == 0x00)
    {
      switch (in)
        {
        case MEX_SHELL_DIRECTION_NONE:
          clutter_actor_set_position (data->child, 0, 0);
          break;

        case MEX_SHELL_DIRECTION_TOP:
          clutter_actor_set_position (data->child, x, -height);
          break;

        case MEX_SHELL_DIRECTION_RIGHT:
          clutter_actor_set_position (data->child, width, y);
          break;

        default:
        case MEX_SHELL_DIRECTION_BOTTOM:
          clutter_actor_set_position (data->child, x, height);
          break;

        case MEX_SHELL_DIRECTION_LEFT:
          clutter_actor_set_position (data->child, -width, y);
          break;
        }

      data->last_direction = in;
    }

  clutter_animator_remove_key (data->animator,
                               (GObject *)data->child, NULL, -1);
  clutter_animator_set (data->animator,
                data->child, "x", CLUTTER_LINEAR, 0.0, 0.f,
                data->child, "x", CLUTTER_EASE_OUT_QUAD, 1.0, x,
                data->child, "y", CLUTTER_LINEAR, 0.0, 0.f,
                data->child, "y", CLUTTER_EASE_OUT_QUAD, 1.0, y,
                data->child, "opacity", CLUTTER_LINEAR, 0.0, 0x00,
                data->child, "opacity", CLUTTER_EASE_OUT_QUAD, 0.1, 0xff,
                NULL);
  clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child,
                                         "x", TRUE);
  clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child,
                                         "y", TRUE);
  clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child,
                                         "opacity", TRUE);
  data->start_animator = TRUE;

  if (priv->presented && (priv->presented != actor))
    {
      MexShellDirection dir;

      l = g_list_find_custom (priv->children,
                                 priv->presented,
                                 mex_shell_find_child);
      if (!l)
        {
          g_warning (G_STRLOC ": Former presented actor is unknown");
          return;
        }
      data = l->data;

      x = y = 0;

      switch (in)
        {
        case 0:
          x = y = 0;
          dir = 0;
          break;

        case MEX_SHELL_DIRECTION_TOP:
          y = height;
          dir = MEX_SHELL_DIRECTION_BOTTOM;
          break;

        case MEX_SHELL_DIRECTION_RIGHT:
          x = -width;
          dir = MEX_SHELL_DIRECTION_LEFT;
          break;

        case MEX_SHELL_DIRECTION_BOTTOM:
          y = -height;
          dir = MEX_SHELL_DIRECTION_TOP;
          break;

        default:
        case MEX_SHELL_DIRECTION_LEFT:
          x = width;
          dir = MEX_SHELL_DIRECTION_RIGHT;
          break;
        }

      data->last_direction = dir;
      clutter_animator_remove_key (data->animator,
                                   (GObject *)data->child, NULL, -1);
      clutter_animator_set (data->animator,
                data->child, "x", CLUTTER_LINEAR, 0.0, 0.f,
                data->child, "x", CLUTTER_EASE_OUT_QUAD, 1.0, x,
                data->child, "y", CLUTTER_LINEAR, 0.0, 0.f,
                data->child, "y", CLUTTER_EASE_OUT_QUAD, 1.0, y,
                data->child, "opacity", CLUTTER_LINEAR, 0.9, 0xff,
                data->child, "opacity", CLUTTER_EASE_OUT_QUAD, 1.0, 0x00,
                NULL);
      clutter_animator_property_set_ease_in (data->animator,
                                             (GObject *)data->child,
                                             "x", TRUE);
      clutter_animator_property_set_ease_in (data->animator,
                                             (GObject *)data->child,
                                             "y", TRUE);
      clutter_animator_property_set_ease_in (data->animator,
                                             (GObject *)data->child,
                                             "opacity", TRUE);
      data->start_animator = TRUE;
    }

  priv->presented = actor;
  stage = clutter_actor_get_stage (actor);
  if (stage)
    {
      MxFocusManager *manager =
        mx_focus_manager_get_for_stage ((ClutterStage *)stage);

      if (manager)
        {
          if (MX_IS_FOCUSABLE (actor))
            mx_focus_manager_push_focus_with_hint (manager,
                                                   MX_FOCUSABLE (shell),
                                                   MX_FOCUS_HINT_PRIOR);
          else
            mx_focus_manager_move_focus (manager, MX_FOCUS_DIRECTION_OUT);
        }
    }

  clutter_actor_queue_redraw (CLUTTER_ACTOR (shell));
}