コード例 #1
0
ファイル: mx-menu.c プロジェクト: jku/mx
static gboolean
mx_menu_captured_event_handler (ClutterActor *actor,
                                ClutterEvent *event,
                                ClutterActor *menu)
{
  int i;
  ClutterActor *source;
  MxMenuPrivate *priv = MX_MENU (menu)->priv;

  /* allow the event to continue if it is applied to the menu or any of its
   * children
   */
  source = clutter_event_get_source (event);
  if (source == menu)
    return FALSE;
  for (i = 0; i < priv->children->len; i++)
    {
      MxMenuChild *child;

      child = &g_array_index (priv->children, MxMenuChild, i);

      if (source == (ClutterActor*) child->box)
        return FALSE;
    }
  if (source == priv->up_button || source == priv->down_button)
    return FALSE;

  /* hide the menu if the user clicks outside the menu */
  if (event->type == CLUTTER_BUTTON_PRESS)
    {
      if (clutter_actor_get_animation (menu))
        {
          clutter_animation_completed (clutter_actor_get_animation (menu));

          return FALSE;
        }


      clutter_actor_set_reactive (menu, FALSE);
      clutter_actor_animate (menu, CLUTTER_LINEAR, 250,
                             "opacity", (guchar) 0,
                             "signal-swapped::completed", clutter_actor_hide,
                             menu,
                             NULL);
    }


  return TRUE;
}
コード例 #2
0
ファイル: mx-menu.c プロジェクト: jku/mx
static void
mx_menu_show (ClutterActor *actor)
{
  ClutterAnimation *animation = NULL;
  ClutterStage *stage;

  /* set reactive and opacity, since these may have been set by the fade-out
   * animation (e.g. from captured_event_handler or button_release_cb) */
  if ((animation = clutter_actor_get_animation (actor)))
    {
      clutter_animation_completed (animation);
    }
  clutter_actor_set_reactive (actor, TRUE);
  clutter_actor_set_opacity (actor, 0xff);

  /* chain up to run show after re-setting properties above */
  CLUTTER_ACTOR_CLASS (mx_menu_parent_class)->show (actor);

  clutter_actor_grab_key_focus (actor);

  stage = (ClutterStage*) clutter_actor_get_stage (actor);

  mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (stage),
                               MX_FOCUSABLE (actor));

}
コード例 #3
0
	/*
		Hides the panel
	*/
	void WindowPanel::hide_panel() {
		if (clutter_actor_get_animation(actor_) != NULL) {
			clutter_actor_detach_animation(actor_);
		}

		clutter_actor_animate(actor_, CLUTTER_LINEAR, 500, "opacity", 0, NULL);
		hide_panel_timeout_id_ = 0;
	}
コード例 #4
0
	/*
		Shows the panel
	*/
	void WindowPanel::show_panel() {
		if (clutter_actor_get_animation(actor_) != NULL) {
			return;
		}

		clutter_actor_animate(actor_, CLUTTER_LINEAR, 250, "opacity", 255, NULL);

		if (hide_panel_timeout_id_ != 0) {
			g_source_remove(hide_panel_timeout_id_);
			hide_panel_timeout_id_ = 0;
		}

		if (auto_hide_) {
			hide_panel_timeout_id_ = g_timeout_add_seconds(3, hide_panel_cb, this);
		}
	}
コード例 #5
0
ファイル: foofone.c プロジェクト: UIKit0/toys
void
button_activate (App *app, Button *b)
{
  // Wait for the previous animation to end
  if (clutter_actor_get_animation (b->actor))
    return;

  clutter_text_insert_text (CLUTTER_TEXT(app->dpy_entry), b->face, -1);

  clutter_actor_set_opacity (b->actor, 0xff);
  clutter_actor_set_scale (b->actor, 1.0, 1.0);
  clutter_actor_animate (b->actor, CLUTTER_LINEAR, 50,
                         "opacity", 0x00,
                         "scale-x", 1.5,
                         "scale-y", 1.5,
                         "signal-after::completed", on_button_effect_complete, b->actor,
                         NULL);
}
コード例 #6
0
ファイル: mx-expander.c プロジェクト: GunioRobot/mx
static void
timeline_complete (ClutterTimeline *timeline,
                   ClutterActor    *expander)
{
  guchar opacity;
  ClutterActor *child;
  MxExpanderPrivate *priv = MX_EXPANDER (expander)->priv;

  g_signal_emit (expander, expander_signals[EXPAND_COMPLETE], 0);

  /* if the expander is now closed, update the style */
  if (!priv->expanded)
    {
      clutter_actor_set_name (priv->arrow, "mx-expander-arrow-closed");
      mx_stylable_set_style_class (MX_STYLABLE (expander), "closed-expander");

      clutter_actor_queue_relayout (expander);
    }

  child = mx_bin_get_child (MX_BIN (expander));

  if (!child)
    return;

  /* continue only if we are "opening" */
  if (!priv->expanded)
    return;

  /* we can't do an animation if there is already one in progress,
   * because we cannot get the actors original opacity */
  if (clutter_actor_get_animation (child))
    {
      clutter_actor_show (child);
      return;
    }

  opacity = clutter_actor_get_opacity (child);
  clutter_actor_set_opacity (child, 0);

  clutter_actor_show (child);
  clutter_actor_animate (child, CLUTTER_EASE_IN_SINE, 100,
                         "opacity", opacity,
                         NULL);
}
コード例 #7
0
ファイル: mex-column.c プロジェクト: ocrete/media-explorer
static void
mex_column_shrink_child (ClutterActor *child)
{
  ClutterActorClass *actor_class;
  gfloat new_height;
  ClutterAnimation *animation;

  /* get the preferred directly from the class, to avoid getting any fixed
   * value */
  actor_class = CLUTTER_ACTOR_GET_CLASS (child);
  actor_class->get_preferred_height (child, -1, &new_height, NULL);

  animation = clutter_actor_get_animation (child);

  /* prevent the completed signal being called if the child was expanding */
  if (animation)
    g_signal_handlers_disconnect_by_func (animation, child_expand_complete_cb,
                                          child);

  clutter_actor_animate (child, CLUTTER_EASE_OUT_CUBIC, 200,
                         "height", new_height, NULL);
}
コード例 #8
0
void
mnb_zones_preview_change_workspace (MnbZonesPreview *preview,
                                    gint             workspace)
{
  gboolean reset_anim;
  MnbZonesPreviewPrivate *priv = preview->priv;

  /* If we're already going towards this workspace, ignore */
  if ((priv->dest_workspace == workspace) && priv->anim_phase)
    return;

  /* Figure out what we need to be doing with this animation */
  switch (priv->anim_phase)
    {
    default:
    case MNB_ZP_STATIC:
      /* We weren't animating, start a new one */
      reset_anim = TRUE;
      break;

    case MNB_ZP_ZOOM_OUT:
      /* If we're on the right workspace, zoom in and finish, otherwise
       * continue the animation like normal.
       */
      if (priv->dest_workspace == workspace)
        {
          priv->anim_phase = MNB_ZP_PAN;
          reset_anim = TRUE;
        }
      else
        reset_anim = FALSE;
      break;

    case MNB_ZP_PAN:
      /* If we're heading towards the right workspace, continue the
       * animation, otherwise change direction.
       */
      if (priv->dest_workspace != workspace)
        {
          priv->anim_phase = MNB_ZP_ZOOM_OUT;
          reset_anim = TRUE;
        }
      else
        reset_anim = FALSE;
      break;

    case MNB_ZP_ZOOM_IN:
      /* Restart the animation if we're not heading towards the right
       * workspace.
       */
      if (priv->dest_workspace != workspace)
        {
          priv->anim_phase = MNB_ZP_STATIC;
          reset_anim = TRUE;
        }
      else
        reset_anim = FALSE;
      break;
    }

  priv->dest_workspace = workspace;
  if (reset_anim)
    {
      ClutterAnimation *animation =
        clutter_actor_get_animation (CLUTTER_ACTOR (preview));

      if (animation)
        g_signal_handlers_disconnect_by_func (animation,
                                              mnb_zones_preview_completed_cb,
                                              preview);

      mnb_zones_preview_completed_cb (animation, preview);
    }
}
コード例 #9
0
static void
mnb_zones_preview_completed_cb (ClutterAnimation *animation,
                                MnbZonesPreview  *preview)
{
  MnbZonesPreviewPrivate *priv = preview->priv;

  switch (priv->anim_phase)
    {
    case MNB_ZP_STATIC:
      /* Start zooming out */
      priv->anim_phase = MNB_ZP_ZOOM_OUT;
      mnb_zones_preview_enable_fanciness (preview, TRUE);

	  clutter_actor_save_easing_state (CLUTTER_ACTOR(preview));
	  clutter_actor_set_easing_duration (CLUTTER_ACTOR(preview), 220);
	  clutter_actor_set_easing_mode(CLUTTER_ACTOR(preview), CLUTTER_EASE_IN_SINE);
	  clutter_actor_set_scale(CLUTTER_ACTOR(preview), 0.3f, 0.3f);
      clutter_actor_restore_easing_state (CLUTTER_ACTOR(preview));

      break;

    case MNB_ZP_ZOOM_OUT:
      /* Start panning */
      {
        guint duration = 175 * abs (priv->dest_workspace - priv->workspace);

        if (duration)
          {
            priv->anim_phase = MNB_ZP_PAN;

			clutter_actor_save_easing_state (CLUTTER_ACTOR(preview));
			clutter_actor_set_easing_duration (CLUTTER_ACTOR(preview), duration);
			clutter_actor_set_easing_mode(CLUTTER_ACTOR(preview), CLUTTER_LINEAR);
			clutter_actor_set_scale(CLUTTER_ACTOR(preview), (gdouble)priv->dest_workspace, (gdouble)priv->dest_workspace);
			clutter_actor_restore_easing_state (CLUTTER_ACTOR(preview));

            break;
          }
        /* If duration == 0, fall through here to the next phase*/
      }
    case MNB_ZP_PAN:
      /* Start zooming in */
      mnb_zones_preview_enable_fanciness (preview, FALSE);
      priv->anim_phase = MNB_ZP_ZOOM_IN;
      clutter_actor_save_easing_state (CLUTTER_ACTOR(preview));
	  clutter_actor_set_easing_duration (CLUTTER_ACTOR(preview), 250);
	  clutter_actor_set_easing_mode(CLUTTER_ACTOR(preview), CLUTTER_EASE_OUT_CUBIC);
	  clutter_actor_set_scale(CLUTTER_ACTOR(preview), 1.0f, 1.0f);
	  clutter_actor_restore_easing_state (CLUTTER_ACTOR(preview));
      break;

    case MNB_ZP_ZOOM_IN:
      /* Complete the animation */
      priv->anim_phase = MNB_ZP_STATIC;
      g_signal_emit (preview, signals[SWITCH_COMPLETED], 0);
      return;

    default:
      g_warning (G_STRLOC ": This shouldn't happen");
      return;
    }

  animation = clutter_actor_get_animation (CLUTTER_ACTOR (preview));
  g_signal_connect_after (animation, "completed",
                          G_CALLBACK (mnb_zones_preview_completed_cb), preview);
}
コード例 #10
0
static void
mnb_zones_preview_completed_cb (ClutterAnimation *animation,
                                MnbZonesPreview  *preview)
{
  MnbZonesPreviewPrivate *priv = preview->priv;

  switch (priv->anim_phase)
    {
    case MNB_ZP_STATIC:
      /* Start zooming out */
      priv->anim_phase = MNB_ZP_ZOOM_OUT;
      clutter_actor_animate (CLUTTER_ACTOR (preview),
                             CLUTTER_EASE_IN_SINE,
                             220,
                             "zoom", 0.75,
                             NULL);
      break;

    case MNB_ZP_ZOOM_OUT:
      /* Start panning */
      {
        guint duration = MIN (175 * fabs ((gdouble) priv->dest_workspace - priv->workspace), 525);

        if (duration)
          {
            priv->anim_phase = MNB_ZP_PAN;
            clutter_actor_animate (CLUTTER_ACTOR (preview),
                                   CLUTTER_LINEAR,
                                   duration,
                                   "workspace", (gdouble)priv->dest_workspace,
                                   NULL);
            break;
          }
        /* If duration == 0, fall through here to the next phase*/
      }
    case MNB_ZP_PAN:
      /* Start zooming in */
      priv->anim_phase = MNB_ZP_ZOOM_IN;
      clutter_actor_animate (CLUTTER_ACTOR (preview),
                             CLUTTER_EASE_OUT_CUBIC,
                             250,
                             /* Force workspace to destination in case
                                a previous pan animation is already
                                running. */
                             "workspace", (gdouble) priv->dest_workspace,
                             "zoom", 1.0,
                             NULL);
      break;

    case MNB_ZP_ZOOM_IN:
      /* Complete the animation */
      priv->anim_phase = MNB_ZP_STATIC;
      g_signal_emit (preview, signals[SWITCH_COMPLETED], 0);
      return;

    default:
      g_warning (G_STRLOC ": This shouldn't happen");
      return;
    }

  animation = clutter_actor_get_animation (CLUTTER_ACTOR (preview));
  g_signal_connect_after (animation, "completed",
                          G_CALLBACK (mnb_zones_preview_completed_cb), preview);
}