static void
video_aspect_frame_allocate(ClutterActor           *actor,
                            const ClutterActorBox  *box,
                            ClutterAllocationFlags  flags)
{
    ClutterActor *container, *camera;
    ClutterActorBox container_box;
    gfloat frame_aspect, frame_box_width, frame_box_height,
           camera_aspect, camera_width, camera_height;

    CLUTTER_ACTOR_CLASS(video_aspect_frame_parent_class)->allocate(actor, box, flags);

    /* the first child in the frame is always the camera container */
    container = clutter_actor_get_child_at_index(actor, 0);
    if (!container)
        return;

    /* the first child in the container is always the main camera that must fill the
     * container */
    camera = clutter_actor_get_child_at_index(container, 0);
    if (!camera)
        return;

    /* retrieve the size allocated for the frame box */
    frame_box_width  = box->x2 - box->x1;
    frame_box_height = box->y2 - box->y1;

    /* retrieve the preferred size for the main camera in container box */
    clutter_actor_get_preferred_size(camera, NULL, NULL, &camera_width, &camera_height);

    if (camera_width <= 0.0f || camera_height <= 0.0f)
        return;

    frame_aspect  = frame_box_width / frame_box_height;
    camera_aspect = camera_width / camera_height;

    /* resize the camera actor to fit in the frame box without loosing
     * its aspect ratio */
    if (frame_aspect < camera_aspect) {
        camera_width = frame_box_width;
        camera_height = frame_box_width / camera_aspect;
    } else {
        camera_height = frame_box_height;
        camera_width = frame_box_height * camera_aspect;
    }

    /* center the container box in the space left inside the frame box */
    container_box.x1 = (frame_box_width - camera_width) / 2;
    container_box.y1 = (frame_box_height - camera_height) / 2;
    container_box.x2 = container_box.x1 + camera_width;
    container_box.y2 = container_box.y1 + camera_height;

    /* finally really allocate the container */
    clutter_actor_allocate(container, &container_box, flags);

}
Exemple #2
0
/**
 * mx_menu_add_action:
 * @menu: A #MxMenu
 * @action: A #MxAction
 *
 * Append @action to @menu.
 *
 */
void
mx_menu_add_action (MxMenu   *menu,
                    MxAction *action)
{
    MxMenuChild child;
    ClutterActor *button_child;

    g_return_if_fail (MX_IS_MENU (menu));
    g_return_if_fail (MX_IS_ACTION (action));

    MxMenuPrivate *priv = menu->priv;

    child.action = g_object_ref_sink (action);
    /* TODO: Connect to notify signals in case action properties change */
    child.box = g_object_new (MX_TYPE_BUTTON,
                              "action", child.action,
                              NULL);
    mx_button_set_action (MX_BUTTON (child.box), child.action);

    /* align to the left */
    button_child = clutter_actor_get_child_at_index ((ClutterActor*) child.box, 0);
    clutter_actor_set_x_align (button_child, CLUTTER_ACTOR_ALIGN_START);


    g_signal_connect (child.box, "clicked",
                      G_CALLBACK (mx_menu_button_clicked_cb), action);
    g_signal_connect (child.box, "enter-event",
                      G_CALLBACK (mx_menu_button_enter_event_cb), menu);
    clutter_actor_add_child (CLUTTER_ACTOR (menu), CLUTTER_ACTOR (child.box));

    g_array_append_val (priv->children, child);

    clutter_actor_queue_relayout (CLUTTER_ACTOR (menu));
}
Exemple #3
0
/**
 * clutter_group_get_nth_child:
 * @self: A #ClutterGroup
 * @index_: the position of the requested actor.
 *
 * Gets a groups child held at @index_ in stack.
 *
 * Return value: (transfer none): A Clutter actor, or %NULL if
 *   @index_ is invalid.
 *
 * Since: 0.2
 *
 * Deprecated: 1.10: Use clutter_actor_get_child_at_index() instead.
 */
ClutterActor *
clutter_group_get_nth_child (ClutterGroup *self,
			     gint          index_)
{
  ClutterActor *actor;

  g_return_val_if_fail (CLUTTER_IS_GROUP (self), NULL);

  actor = CLUTTER_ACTOR (self);
  g_return_val_if_fail (index_ <= clutter_actor_get_n_children (actor), NULL);

  return clutter_actor_get_child_at_index (actor, index_);
}
static void
ntf_tray_notification_closed_cb (NtfNotification *ntf, NtfTray *tray)
{
  NtfTrayPrivate   *priv = tray->priv;
  ClutterActor     *ntfa = CLUTTER_ACTOR (ntf);
  ClutterAnimation *anim;

  priv->n_notifiers--;

  if (priv->n_notifiers < 0)
    {
      g_warning ("Bug in notifier accounting, attempting to fix");
      priv->n_notifiers = 0;
    }

  /* fade out closed notifier */
  if (ntfa == priv->active_notifier)
    {
      anim = clutter_actor_animate (CLUTTER_ACTOR (ntfa),
                                    CLUTTER_EASE_IN_SINE,
                                    FADE_DURATION,
                                    "opacity", 0,
                                    NULL);

      g_signal_connect_after (anim,
                        "completed",
                        G_CALLBACK
                        (ntf_tray_hide_ntf_completed_cb),
                        tray);
    }
  else
    {
      clutter_actor_destroy (ntfa);
    }

  /* Fade in newer notifier from below stack */
  if (ntfa == priv->active_notifier && priv->n_notifiers > 0)
    {
      gint prev_height, new_height;

      prev_height = clutter_actor_get_height (ntfa);

      priv->active_notifier =
    		  clutter_actor_get_child_at_index (CLUTTER_ACTOR (priv->notifiers),
                                     1); /* Next, not 0 */

      if (priv->active_notifier)
        {
          clutter_actor_set_opacity (priv->active_notifier, 0);
          clutter_actor_show (CLUTTER_ACTOR (priv->active_notifier));

  		clutter_actor_save_easing_state (priv->active_notifier);
  		clutter_actor_set_easing_duration (priv->active_notifier, FADE_DURATION);
  		clutter_actor_set_easing_mode(priv->active_notifier, CLUTTER_EASE_IN_SINE);
  		clutter_actor_set_opacity(priv->active_notifier, 0xff);
  		clutter_actor_restore_easing_state (priv->active_notifier);


          new_height = clutter_actor_get_height (priv->active_notifier);

          if (prev_height != new_height && priv->n_notifiers > 1)
            {
              gfloat new_y;

              new_y = clutter_actor_get_y (priv->control)
                - (prev_height - new_height);

				clutter_actor_save_easing_state (priv->control);
				clutter_actor_set_easing_duration (priv->control, FADE_DURATION);
				clutter_actor_set_easing_mode(priv->control, CLUTTER_EASE_IN_SINE);
				clutter_actor_set_y(priv->control, new_y);
				clutter_actor_restore_easing_state (priv->control);
            }
        }
    }

  if (priv->n_notifiers == 0)
    {
      priv->active_notifier = NULL;
      mnb_notification_gtk_hide ();
    }
  else if (priv->n_notifiers == 1)
    {
      /* slide the control out of view */
      ClutterAnimation *anim;

      anim = clutter_actor_animate (priv->control,
                                    CLUTTER_EASE_IN_SINE,
                                    FADE_DURATION,
                                    "opacity", 0x0,
                                    "y",
                                    clutter_actor_get_height (priv->active_notifier)
                                    - clutter_actor_get_height (priv->control),
                                    NULL);

      g_signal_connect_after (anim,
                        "completed",
                        G_CALLBACK
                        (ntf_tray_control_hide_completed_cb),
                        tray);
    }
  else
    {
      /* Just Update control text */
      gchar *msg;
      msg = g_strdup_printf (_("%i pending messages"), priv->n_notifiers);
      mx_label_set_text (MX_LABEL (priv->control_text), msg);
      g_free (msg);
    }
}