Beispiel #1
0
static void
add_drag_object (ClutterActor *target)
{
  ClutterActor *parent;

  if (drag == NULL)
    {
      ClutterAction *action;

      drag = clutter_actor_new ();
      clutter_actor_set_background_color (drag, CLUTTER_COLOR_LightSkyBlue);
      clutter_actor_set_size (drag, HANDLE_SIZE, HANDLE_SIZE);
      clutter_actor_set_position (drag,
                                  (TARGET_SIZE - HANDLE_SIZE) / 2.0,
                                  (TARGET_SIZE - HANDLE_SIZE) / 2.0);
      clutter_actor_set_reactive (drag, TRUE);

      action = clutter_drag_action_new ();
      g_signal_connect (action, "drag-begin", G_CALLBACK (on_drag_begin), NULL);
      g_signal_connect (action, "drag-end", G_CALLBACK (on_drag_end), NULL);

      clutter_actor_add_action (drag, action);
    }

  parent = clutter_actor_get_parent (drag);
  if (parent == target)
    {
      clutter_actor_save_easing_state (target);
      clutter_actor_set_easing_mode (target, CLUTTER_LINEAR);
      clutter_actor_set_opacity (target, 255);
      clutter_actor_restore_easing_state (target);
      return;
    }

  g_object_ref (drag);
  if (parent != NULL && parent != stage)
    {
      clutter_actor_remove_child (parent, drag);

      clutter_actor_save_easing_state (parent);
      clutter_actor_set_easing_mode (parent, CLUTTER_LINEAR);
      clutter_actor_set_opacity (parent, 64);
      clutter_actor_restore_easing_state (parent);
    }

  clutter_actor_add_child (target, drag);

  clutter_actor_save_easing_state (target);
  clutter_actor_set_easing_mode (target, CLUTTER_LINEAR);
  clutter_actor_set_opacity (target, 255);
  clutter_actor_restore_easing_state (target);

  g_object_unref (drag);
}
Beispiel #2
0
static void
on_drag_end (ClutterDragAction   *action,
             ClutterActor        *actor,
             gfloat               event_x,
             gfloat               event_y,
             ClutterModifierType  modifiers)
{
  ClutterActor *handle = clutter_drag_action_get_drag_handle (action);

  g_print ("Drag ended at: %.0f, %.0f\n",
           event_x, event_y);

  clutter_actor_save_easing_state (actor);
  clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR);
  clutter_actor_set_opacity (actor, 255);
  clutter_actor_restore_easing_state (actor);

  clutter_actor_save_easing_state (handle);

  if (!drop_successful)
    {
      ClutterActor *parent = clutter_actor_get_parent (actor);
      gfloat x_pos, y_pos;

      clutter_actor_save_easing_state (parent);
      clutter_actor_set_easing_mode (parent, CLUTTER_LINEAR);
      clutter_actor_set_opacity (parent, 255);
      clutter_actor_restore_easing_state (parent);

      clutter_actor_get_transformed_position (actor, &x_pos, &y_pos);

      clutter_actor_set_easing_mode (handle, CLUTTER_EASE_OUT_BOUNCE);
      clutter_actor_set_position (handle, x_pos, y_pos);
      clutter_actor_set_opacity (handle, 0);
      clutter_actor_restore_easing_state (handle);

    }
  else
    {
      clutter_actor_set_easing_mode (handle, CLUTTER_LINEAR);
      clutter_actor_set_opacity (handle, 0);
    }

  clutter_actor_restore_easing_state (handle);

  g_signal_connect (handle, "transitions-completed",
                    G_CALLBACK (clutter_actor_destroy),
                    NULL);
}
Beispiel #3
0
static void
on_drag_begin (ClutterDragAction   *action,
               ClutterActor        *actor,
               gfloat               event_x,
               gfloat               event_y,
               ClutterModifierType  modifiers)
{
  ClutterActor *handle;
  gfloat x_pos, y_pos;

  clutter_actor_get_position (actor, &x_pos, &y_pos);

  handle = clutter_actor_new ();
  clutter_actor_set_background_color (handle, CLUTTER_COLOR_DarkSkyBlue);
  clutter_actor_set_size (handle, 128, 128);
  clutter_actor_set_position (handle, event_x - x_pos, event_y - y_pos);
  clutter_actor_add_child (stage, handle);

  clutter_drag_action_set_drag_handle (action, handle);

  clutter_actor_save_easing_state (actor);
  clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR);
  clutter_actor_set_opacity (actor, 128);
  clutter_actor_restore_easing_state (actor);

  drop_successful = FALSE;
}
Beispiel #4
0
void
meta_compositor_flash_window (MetaCompositor *compositor,
                              MetaWindow     *window)
{
  ClutterActor *window_actor =
    CLUTTER_ACTOR (meta_window_get_compositor_private (window));
  ClutterActor *flash;
  ClutterTransition *transition;

  flash = clutter_actor_new ();
  clutter_actor_set_background_color (flash, CLUTTER_COLOR_Black);
  clutter_actor_set_size (flash, window->rect.width, window->rect.height);
  clutter_actor_set_position (flash,
                              window->custom_frame_extents.left,
                              window->custom_frame_extents.top);
  clutter_actor_set_opacity (flash, 0);
  clutter_actor_add_child (window_actor, flash);

  clutter_actor_save_easing_state (flash);
  clutter_actor_set_easing_mode (flash, CLUTTER_EASE_IN_QUAD);
  clutter_actor_set_easing_duration (flash, FLASH_TIME_MS);
  clutter_actor_set_opacity (flash, 192);

  transition = clutter_actor_get_transition (flash, "opacity");
  clutter_timeline_set_auto_reverse (CLUTTER_TIMELINE (transition), TRUE);
  clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (transition), 2);

  g_signal_connect (transition, "stopped",
                    G_CALLBACK (window_flash_out_completed), flash);

  clutter_actor_restore_easing_state (flash);
}
Beispiel #5
0
static void
mx_notebook_update_children (MxNotebook *book)
{
  MxNotebookPrivate *priv = book->priv;
  GList *l;

  for (l = priv->children; l; l = l->next)
    {
      ClutterActor *child = CLUTTER_ACTOR (l->data);

      if (child == priv->current_page)
        {
          clutter_actor_show (child);

          clutter_actor_save_easing_state (child);
          clutter_actor_set_easing_mode (child, CLUTTER_LINEAR);
          clutter_actor_set_easing_duration (child, 250);
          clutter_actor_set_opacity (child, 0xff);
          clutter_actor_restore_easing_state (child);

          g_signal_connect (child, "transition-stopped::opacity",
                            G_CALLBACK (mx_notebook_show_complete_cb), book);
        }
    }
}
Beispiel #6
0
void
meta_compositor_flash_screen (MetaCompositor *compositor,
                              MetaScreen     *screen)
{
  ClutterActor *stage;
  ClutterActor *flash;
  ClutterTransition *transition;
  gfloat width, height;

  stage = meta_get_stage_for_screen (screen);
  clutter_actor_get_size (stage, &width, &height);

  flash = clutter_actor_new ();
  clutter_actor_set_background_color (flash, CLUTTER_COLOR_Black);
  clutter_actor_set_size (flash, width, height);
  clutter_actor_set_opacity (flash, 0);
  clutter_actor_add_child (stage, flash);

  clutter_actor_save_easing_state (flash);
  clutter_actor_set_easing_mode (flash, CLUTTER_EASE_IN_QUAD);
  clutter_actor_set_easing_duration (flash, FLASH_TIME_MS);
  clutter_actor_set_opacity (flash, 192);

  transition = clutter_actor_get_transition (flash, "opacity");
  clutter_timeline_set_auto_reverse (CLUTTER_TIMELINE (transition), TRUE);
  clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (transition), 2);

  g_signal_connect (transition, "stopped",
                    G_CALLBACK (flash_out_completed), flash);

  clutter_actor_restore_easing_state (flash);
}
Beispiel #7
0
static void overview_animated_destroy(MosesOverview* self, MosesOverviewQuitReason reason, gboolean animate)
{
    MosesOverviewPrivate* priv = self->priv;

    gboolean just_destroy = !animate;
    if (reason == MOSES_OV_REASON_ACTIVATE_WINDOW && !priv->selected_actor) {
        just_destroy = TRUE;
    } else if (reason == MOSES_OV_REASON_ACTIVATE_WORKSPACE && !priv->selected_workspace) {
        just_destroy = TRUE;
    } else if (reason == MOSES_OV_REASON_NORMAL) {
        just_destroy = TRUE;
    }

    if (just_destroy) {
        clutter_actor_destroy(CLUTTER_ACTOR(self));
        return;
    }

    gfloat x, y, w, h;
    ClutterActor* target = NULL;

    if (reason == MOSES_OV_REASON_ACTIVATE_WINDOW) {
        target = self->priv->selected_actor;

        ClutterActor* orig = clutter_clone_get_source(CLUTTER_CLONE(target));
        clutter_actor_get_position(orig, &x, &y);
        clutter_actor_get_size(orig, &w, &h);
        g_signal_handlers_disconnect_by_func(target, on_effect_complete, self);

    } else if (reason == MOSES_OV_REASON_ACTIVATE_WORKSPACE) {
        g_assert(priv->selected_actor == NULL);

        MetaScreen* screen = meta_plugin_get_screen(priv->plugin);
        target = overview_head_get_actor_for_workspace(priv->ov_head, priv->selected_workspace);

        MetaRectangle geom;
        int focused_monitor = meta_screen_get_current_monitor(screen);
        meta_screen_get_monitor_geometry(screen, focused_monitor, &geom);
        x = geom.x, y = geom.y, w = geom.width, h = geom.height;
    }

    if (target) {
        clutter_actor_remove_all_transitions(target);
        clutter_actor_set_child_above_sibling(clutter_actor_get_parent(target), target, NULL);

        clutter_actor_save_easing_state(target);
        clutter_actor_set_easing_mode(target, CLUTTER_LINEAR);
        clutter_actor_set_easing_duration(target, 150);

        clutter_actor_set_position(target, x, y);
        clutter_actor_set_scale(target, w / clutter_actor_get_width(target),
                h / clutter_actor_get_height(target));
        clutter_actor_restore_easing_state(target);
        g_object_connect(target, "signal::transitions-completed",
                G_CALLBACK(on_restore_position_effect_complete), self, NULL);
    }
}
Beispiel #8
0
void map(MetaPlugin *plugin, MetaWindowActor *window_actor)
{
        ClutterActor *actor = CLUTTER_ACTOR(window_actor);

        clutter_actor_remove_all_transitions(actor);

        switch (MWT(window_actor)) {
                case META_WINDOW_POPUP_MENU:
                case META_WINDOW_DROPDOWN_MENU:
                case META_WINDOW_NOTIFICATION:
                case META_WINDOW_MENU:
                        /* For menus we'll give em a nice fade in */
                        g_object_set(actor, "opacity", 0, NULL);
                        clutter_actor_show(actor);

                        clutter_actor_save_easing_state(actor);
                        clutter_actor_set_easing_mode(actor, CLUTTER_EASE_IN_SINE);
                        clutter_actor_set_easing_duration(actor, FADE_TIMEOUT);
                        g_signal_connect(actor, "transitions-completed", G_CALLBACK(map_done), plugin);

                        g_object_set(actor, "opacity", 255, NULL);
                        clutter_actor_restore_easing_state(actor);
                        break;
                case META_WINDOW_NORMAL:
                case META_WINDOW_DIALOG:
                case META_WINDOW_MODAL_DIALOG:
                        g_object_set(actor, "opacity", 0, "scale-x", MAP_SCALE, "scale-y", MAP_SCALE, "pivot-point", &PV_CENTER, NULL);
                        clutter_actor_show(actor);

                        /* Initialise animation */
                        clutter_actor_save_easing_state(actor);
                        clutter_actor_set_easing_mode(actor, CLUTTER_EASE_IN_SINE);
                        clutter_actor_set_easing_duration(actor, MAP_TIMEOUT);
                        g_signal_connect(actor, "transitions-completed", G_CALLBACK(map_done), plugin);

                        /* Now animate. */
                        g_object_set(actor, "scale-x", 1.0, "scale-y", 1.0, "opacity", 255, NULL);
                        clutter_actor_restore_easing_state(actor);
                        break;
                default:
                        meta_plugin_map_completed(plugin, window_actor);
                        break;
        }
}
Beispiel #9
0
static void budgie_wm_start(MetaPlugin *plugin)
{
        BudgieWM *self = BUDGIE_WM(plugin);
        MetaScreen *screen = meta_plugin_get_screen(plugin);
        ClutterActor* actors[2];

        /* Init background */
        self->priv->background_group = meta_background_group_new();
        clutter_actor_set_reactive(self->priv->background_group, TRUE);
        clutter_actor_insert_child_below(meta_get_window_group_for_screen(screen),
        self->priv->background_group, NULL);

        g_signal_connect(screen, "monitors-changed",
                G_CALLBACK(on_monitors_changed), plugin);
        on_monitors_changed(screen, plugin);


        /* Now we're in action. */
        clutter_actor_show(meta_get_window_group_for_screen(screen));
        clutter_actor_show(self->priv->background_group);
        clutter_actor_set_opacity(meta_get_window_group_for_screen(screen), 0);
        clutter_actor_set_opacity(self->priv->background_group, 0);

        actors[0] = meta_get_window_group_for_screen(screen);
        actors[1] = self->priv->background_group;

        clutter_actor_set_background_color(meta_get_stage_for_screen(screen),
                clutter_color_get_static(CLUTTER_COLOR_BLACK));
        clutter_actor_show(meta_get_stage_for_screen(screen));

        for (int i = 0; i < 2; i++) {
                clutter_actor_save_easing_state(actors[i]);
                clutter_actor_set_easing_mode(actors[i], CLUTTER_EASE_OUT_QUAD);
                clutter_actor_set_easing_duration(actors[i], SHOW_TIMEOUT);
                g_object_set(actors[i], "opacity", 255, NULL);
                clutter_actor_restore_easing_state(actors[i]);
        }

        /* Set up our own keybinding overrides */
        meta_keybindings_set_custom_handler(BUDGIE_KEYBINDING_MAIN_MENU,
                budgie_launch_menu, NULL, NULL);
        meta_keybindings_set_custom_handler(BUDGIE_KEYBINDING_RUN_DIALOG,
                budgie_launch_rundialog, NULL, NULL);
        meta_keybindings_set_custom_handler("switch-windows",
                (MetaKeyHandlerFunc)switch_windows, self, NULL);
        meta_keybindings_set_custom_handler("switch-applications",
                (MetaKeyHandlerFunc)switch_windows, self, NULL);

        /* Handle keys.. */
        budgie_keys_init(meta_screen_get_display(screen));
        budgie_menus_init(self);
        g_signal_connect(meta_screen_get_display(screen), "overlay-key",
            G_CALLBACK(overlay_cb), NULL);
}
Beispiel #10
0
static void
plate5anim (ClutterTimeline *timeline,
            const gchar     *marker_name,
            guint            frame_num,
            ClutterActor    *lowerInner)
{
	clutter_actor_save_easing_state (lowerInner);
	clutter_actor_set_easing_duration (lowerInner, 875);
	clutter_actor_set_easing_mode (lowerInner, CLUTTER_EASE_OUT_EXPO);
	clutter_actor_set_position(lowerInner, 0, 0);
	clutter_actor_restore_easing_state (lowerInner);
}
Beispiel #11
0
static void
plate4anim (ClutterTimeline *timeline,
            const gchar     *marker_name,
            guint            frame_num,
            ClutterActor    *fixed)
{
	clutter_actor_save_easing_state (fixed);
	clutter_actor_set_easing_duration (fixed, 1250);
	clutter_actor_set_easing_mode (fixed, CLUTTER_EASE_OUT_EXPO);
	clutter_actor_set_position(fixed, 0, 0);
	clutter_actor_restore_easing_state (fixed);
}
Beispiel #12
0
static void
plate1anim (ClutterTimeline *timeline,
            const gchar     *marker_name,
            guint            frame_num,
            ClutterActor    *bg)
{
	clutter_actor_set_easing_duration (bg, 750);
	clutter_actor_save_easing_state (bg);
	clutter_actor_set_easing_mode (bg, CLUTTER_EASE_OUT_CIRC);
	clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_FILL);
	clutter_actor_restore_easing_state (bg);
}
Beispiel #13
0
static void
plate3anim (ClutterTimeline *timeline,
            const gchar     *marker_name,
            guint            frame_num,
            ClutterActor    *labelbg)
{
	clutter_actor_save_easing_state (labelbg);
	clutter_actor_set_easing_duration (labelbg, 583);
	clutter_actor_set_easing_mode (labelbg, CLUTTER_EASE_OUT_CUBIC);
	clutter_actor_set_width(labelbg, 400);
	clutter_actor_restore_easing_state (labelbg);
}
Beispiel #14
0
static gboolean
on_box_leave (ClutterActor *box,
              ClutterEvent *event,
              ClutterActor *emblem)
{
  clutter_actor_save_easing_state (emblem);
  clutter_actor_set_easing_mode (emblem, CLUTTER_LINEAR);
  clutter_actor_set_opacity (emblem, 0);
  clutter_actor_restore_easing_state (emblem);

  return CLUTTER_EVENT_STOP;
}
Beispiel #15
0
static void
mx_tooltip_set_opacity (MxTooltip *tooltip,
                        guchar     opacity)
{
  ClutterActor *self = CLUTTER_ACTOR (tooltip);

  clutter_actor_save_easing_state (self);
  clutter_actor_set_easing_mode (self, CLUTTER_EASE_OUT_QUAD);
  clutter_actor_set_easing_duration (self, 150);
  clutter_actor_set_opacity (self, opacity);
  clutter_actor_restore_easing_state (self);
}
Beispiel #16
0
static gboolean
on_box_enter (ClutterActor *box,
              ClutterEvent *event,
              ClutterActor *emblem)
{
  /* we ease the opacity linearly */
  clutter_actor_save_easing_state (emblem);
  clutter_actor_set_easing_mode (emblem, CLUTTER_LINEAR);
  clutter_actor_set_opacity (emblem, 255);
  clutter_actor_restore_easing_state (emblem);

  return CLUTTER_EVENT_STOP;
}
Beispiel #17
0
void destroy(MetaPlugin *plugin, MetaWindowActor *window_actor)
{
        ClutterActor *actor = CLUTTER_ACTOR(window_actor);

        clutter_actor_remove_all_transitions(actor);

        switch (MWT(window_actor)) {
                case META_WINDOW_NOTIFICATION:
                case META_WINDOW_NORMAL:
                case META_WINDOW_DIALOG:
                case META_WINDOW_MODAL_DIALOG:
                        /* Initialise animation */
                        g_object_set(actor, "pivot-point", &PV_CENTER, NULL);
                        clutter_actor_save_easing_state(actor);
                        clutter_actor_set_easing_mode(actor, CLUTTER_EASE_OUT_QUAD);
                        clutter_actor_set_easing_duration(actor, DESTROY_TIMEOUT);
                        g_signal_connect(actor, "transitions-completed", G_CALLBACK(destroy_done), plugin);

                        /* Now animate. */
                        g_object_set(actor, "scale-x", DESTROY_SCALE, "scale-y", DESTROY_SCALE, "opacity", 0, NULL);
                        clutter_actor_restore_easing_state(actor);
                        break;
                case META_WINDOW_MENU:
                        /* Initialise animation */
                        clutter_actor_save_easing_state(actor);
                        clutter_actor_set_easing_mode(actor, CLUTTER_EASE_OUT_QUAD);
                        clutter_actor_set_easing_duration(actor, DESTROY_TIMEOUT);
                        g_signal_connect(actor, "transitions-completed", G_CALLBACK(destroy_done), plugin);

                        /* Now animate. */
                        g_object_set(actor, "opacity", 0, NULL);
                        clutter_actor_restore_easing_state(actor);
                        break;
                default:
                        meta_plugin_destroy_completed(plugin, window_actor);
                        break;
        }
}
Beispiel #18
0
static void place_window(MosesOverview* self, ClutterActor* actor, MetaRectangle rect)
{
    g_debug("%s: %d,%d,%d,%d", __func__, rect.x, rect.y, rect.width, rect.height);
    float fscale = rect.width / clutter_actor_get_width(actor);

    clutter_actor_save_easing_state(actor);
    clutter_actor_set_easing_mode(actor, CLUTTER_EASE_OUT_CUBIC);
    clutter_actor_set_easing_duration(actor, PLACEMENT_ANIMATION_DURATION);

    clutter_actor_set_scale(actor, fscale, fscale);
    clutter_actor_set_position(actor, rect.x, rect.y);
    /*clutter_actor_set_size(actor, rect.width, rect.height);*/
    clutter_actor_restore_easing_state(actor);

}
Beispiel #19
0
static void
mx_menu_close (ClutterActor *menu)
{
    ClutterActor *actor = (ClutterActor *) menu;

    clutter_actor_save_easing_state (actor);
    clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR);
    clutter_actor_set_easing_duration (actor, 250);
    clutter_actor_set_opacity (actor, 0);
    clutter_actor_restore_easing_state (actor);

    g_signal_connect (actor, "transition-stopped::opacity",
                      G_CALLBACK (mx_menu_close_complete), NULL);

    clutter_actor_set_reactive ((ClutterActor*) menu, FALSE);
}
Beispiel #20
0
static void
on_target_over (ClutterDropAction *action,
                ClutterActor      *actor,
                gpointer           _data)
{
  gboolean is_over = GPOINTER_TO_UINT (_data);
  guint8 final_opacity = is_over ? 128 : 64;
  ClutterActor *target;

  target = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));

  clutter_actor_save_easing_state (target);
  clutter_actor_set_easing_mode (target, CLUTTER_LINEAR);
  clutter_actor_set_opacity (target, final_opacity);
  clutter_actor_restore_easing_state (target);
}
Beispiel #21
0
static void on_window_removed(MetaWorkspace *ws, MetaWindow *win, MetaSwitcher* self)
{
    g_debug("%s", __func__);
    MetaSwitcherPrivate* priv = self->priv;

    ClutterActor* win_actor = NULL;
    gboolean need_reselect = FALSE;
    int id = 0;
    for (id = 0; id < priv->apps->len; id++) {
        if (g_ptr_array_index(priv->apps, id) == win) {
            win_actor = g_hash_table_lookup(priv->icons, win);
            need_reselect = (id == priv->selected_id);
        }
    }

    if (win_actor) {
        if (need_reselect)
            _set_highlight(self, priv->selected_id, FALSE);

        g_hash_table_remove(priv->icons, win);
        g_ptr_array_remove(priv->apps, win);

        if (need_reselect) {
            if (id == 0) {
                clutter_actor_set_margin_left(
                        g_hash_table_lookup(priv->icons, g_ptr_array_index(priv->apps, 0)), 10);
            } else if (id >= priv->apps->len) {
                clutter_actor_set_margin_right(
                        g_hash_table_lookup(priv->icons, g_ptr_array_index(priv->apps, priv->apps->len-1)), 10);
            }
            priv->selected_id = (priv->selected_id + 1) % priv->apps->len;
            _set_highlight(self, priv->selected_id, TRUE);
        }

        clutter_actor_save_easing_state(priv->top);
        clutter_actor_set_easing_duration(priv->top, 200);
        clutter_actor_set_easing_mode(priv->top, CLUTTER_LINEAR);

        clutter_actor_remove_child(priv->top, win_actor);

        clutter_actor_restore_easing_state(priv->top);

        reposition_switcher(self);
    }
}
Beispiel #22
0
static void reposition_switcher(MetaSwitcher* self)
{
    MetaSwitcherPrivate* priv = self->priv;
    MetaScreen* screen = meta_plugin_get_screen(priv->plugin);

    gint screen_width = 0, screen_height = 0;
    meta_screen_get_size(screen, &screen_width, &screen_height);

    clutter_actor_save_easing_state(priv->top);
    clutter_actor_set_easing_duration(priv->top, 400);
    clutter_actor_set_easing_mode(priv->top, CLUTTER_LINEAR);

    gfloat w = clutter_actor_get_width(priv->top), h = clutter_actor_get_height(priv->top),
            tx = (screen_width - w)/2, ty = (screen_height - h)/2;
    clutter_actor_set_position(priv->top, tx, ty);

    clutter_actor_restore_easing_state(priv->top);
}
Beispiel #23
0
static void
timeline_complete (ClutterTimeline *timeline,
                   ClutterActor    *expander)
{
  guchar opacity;
  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);
    }

  if (!priv->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_transition (priv->child, "opacity"))
    {
      clutter_actor_show (priv->child);
      return;
    }

  opacity = clutter_actor_get_opacity (priv->child);
  clutter_actor_set_opacity (priv->child, 0);

  clutter_actor_show (priv->child);

  clutter_actor_save_easing_state (priv->child);
  clutter_actor_set_easing_mode (priv->child, CLUTTER_EASE_IN_SINE);
  clutter_actor_set_easing_duration (priv->child, 100);
  clutter_actor_set_opacity (priv->child, opacity);
  clutter_actor_restore_easing_state (priv->child);
}
Beispiel #24
0
static void
on_emblem_clicked (ClutterClickAction *action,
                   ClutterActor       *emblem,
                   ClutterActor       *box)
{
  /* we add a little bounce to the resizing of the box */
  clutter_actor_save_easing_state (box);
  clutter_actor_set_easing_mode (box, CLUTTER_EASE_OUT_BOUNCE);
  clutter_actor_set_easing_duration (box, 500);

  if (!is_expanded)
    clutter_actor_set_size (box, 400, 400);
  else
    clutter_actor_set_size (box, 200, 200);

  clutter_actor_restore_easing_state (box);

  is_expanded = !is_expanded;
}
Beispiel #25
0
//FIXME: ClutterClone seems to have problem rendering children, so badges are stay in grandpar
static void create_window_badge(MosesOverview* self, ClutterActor* parent, int order)
{
    ClutterActor* badge = clutter_actor_new();
    clutter_actor_insert_child_above(clutter_actor_get_parent(parent), badge, NULL);

    gfloat tw, th;
    clutter_actor_get_transformed_size(parent, &tw, &th);

    gfloat w = 60.0, h = 60.0,
            x = (tw - w) / 2.0 + clutter_actor_get_x(parent),
            y = (th - h) / 2.0 + clutter_actor_get_y(parent);
    clutter_actor_set_position(badge, x, y);
    clutter_actor_set_size(badge, w, h);

    g_object_set_qdata(G_OBJECT(badge), moses_overview_window_clone_order(), GINT_TO_POINTER(order));
    g_object_set_qdata(G_OBJECT(parent), moses_overview_window_clone_order(), GINT_TO_POINTER(order));

    ClutterContent* canvas = clutter_canvas_new();
    clutter_canvas_set_size(CLUTTER_CANVAS(canvas), w, h);
    clutter_actor_set_content(badge, canvas);
    g_object_unref(canvas);
    g_signal_connect(canvas, "draw", G_CALLBACK(on_badge_draw), badge);

    clutter_content_invalidate(canvas);

    clutter_actor_set_scale(badge, 0.0, 0.0);

    //do animated show
    clutter_actor_save_easing_state(badge);
    clutter_actor_set_easing_mode(badge, CLUTTER_EASE_OUT_BACK);
    clutter_actor_set_easing_duration(badge, 350);

    clutter_actor_set_pivot_point(badge, 0.5, 0.5);
    clutter_actor_set_scale(badge, 1.0, 1.0);
    clutter_actor_restore_easing_state(badge);

    g_ptr_array_add(self->priv->badges, badge);
}
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);
}
static void
clutter_bin_layout_allocate (ClutterLayoutManager   *manager,
                             ClutterContainer       *container,
                             const ClutterActorBox  *allocation,
                             ClutterAllocationFlags  flags)
{
  gfloat allocation_x, allocation_y;
  gfloat available_w, available_h;
  ClutterActor *actor, *child;
  ClutterActorIter iter;
  gboolean use_animations;
  ClutterAnimationMode easing_mode;
  guint easing_duration, easing_delay;

  clutter_actor_box_get_origin (allocation, &allocation_x, &allocation_y);
  clutter_actor_box_get_size (allocation, &available_w, &available_h);

  actor = CLUTTER_ACTOR (container);

  use_animations = clutter_layout_manager_get_easing_state (manager,
                                                            &easing_mode,
                                                            &easing_duration,
                                                            &easing_delay);
  clutter_actor_iter_init (&iter, actor);
  while (clutter_actor_iter_next (&iter, &child))
    {
      ClutterLayoutMeta *meta;
      ClutterBinLayer *layer;
      ClutterActorBox child_alloc = { 0, };
      gdouble x_align, y_align;
      gboolean x_fill, y_fill;

      meta = clutter_layout_manager_get_child_meta (manager,
                                                    container,
                                                    child);
      layer = CLUTTER_BIN_LAYER (meta);

      if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
        child_alloc.x1 = clutter_actor_get_x (child);
      else
        child_alloc.x1 = allocation_x;

      if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
        child_alloc.y1 = clutter_actor_get_y (child);
      else
        child_alloc.y1 = allocation_y;

      child_alloc.x2 = available_w;
      child_alloc.y2 = available_h;

      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL))
        {
          ClutterActorAlign align;

          align = _clutter_actor_get_effective_x_align (child);
          x_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
          x_align = get_actor_align_factor (align);
        }
      else
        {
          x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL);
          x_align = get_bin_alignment_factor (layer->x_align);
        }

      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL))
        {
          ClutterActorAlign align;

          align = clutter_actor_get_y_align (child);
          y_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
          y_align = get_actor_align_factor (align);
        }
      else
        {
          y_fill = (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL);
          y_align = get_bin_alignment_factor (layer->y_align);
        }

      if (use_animations)
        {
          clutter_actor_save_easing_state (child);
          clutter_actor_set_easing_mode (child, easing_mode);
          clutter_actor_set_easing_duration (child, easing_duration);
          clutter_actor_set_easing_delay (child, easing_delay);
        }

      clutter_actor_allocate_align_fill (child, &child_alloc,
                                         x_align, y_align,
                                         x_fill, y_fill,
                                         flags);

      if (use_animations)
        clutter_actor_restore_easing_state (child);
    }
}
void
ntf_tray_add_notification (NtfTray *tray, NtfNotification *ntf)
{
  NtfTrayPrivate   *priv;
  ClutterActor     *ntfa;
  ClutterAnimation *anim;
  MetaPlugin     *plugin;

  g_return_if_fail (NTF_IS_TRAY (tray) && NTF_IS_NOTIFICATION (ntf));

  priv   = tray->priv;
  ntfa   = CLUTTER_ACTOR (ntf);
  plugin = meego_netbook_get_plugin_singleton ();

  if (meego_netbook_compositor_disabled (plugin))
    {
      mnb_notification_gtk_show ();
    }

  g_signal_connect (ntf, "closed",
                    G_CALLBACK (ntf_tray_notification_closed_cb),
                    tray);

  clutter_actor_add_child (CLUTTER_ACTOR (priv->notifiers), ntfa);

  clutter_actor_set_width (ntfa, CLUSTER_WIDTH);

  priv->n_notifiers++;

  if (priv->n_notifiers == 1)
    {
      /* May have been previously hidden */
      clutter_actor_show (CLUTTER_ACTOR (tray));

      /* show just the single notification */
      priv->active_notifier = ntfa;
      clutter_actor_set_opacity (ntfa, 0);

		clutter_actor_save_easing_state (ntfa);
		clutter_actor_set_easing_duration (ntfa, FADE_DURATION);
		clutter_actor_set_easing_mode(ntfa, CLUTTER_EASE_IN_SINE);
		clutter_actor_set_y(ntfa, 0xff);
		clutter_actor_restore_easing_state (ntfa);

     }
  else if (priv->n_notifiers == 2)
    {
      /* slide the control into view */
      mx_label_set_text (MX_LABEL(priv->control_text),
                         _("1 pending message"));

      clutter_actor_show (priv->control);

      clutter_actor_set_opacity (priv->control, 0);
      clutter_actor_set_y (priv->control,
              clutter_actor_get_height (priv->active_notifier)
                 - clutter_actor_get_height (priv->control) - 30);

      anim = clutter_actor_animate (priv->control,
                                    CLUTTER_EASE_IN_SINE,
                                    FADE_DURATION,
                                    "opacity", 0xff,
                                    "y", clutter_actor_get_height
                                    (priv->active_notifier)- 30,
                                    NULL);
    }
  else
    {
      /* simply update the control */
      gchar *msg;

      msg = g_strdup_printf (_("%i pending messages"), priv->n_notifiers-1);

      mx_label_set_text (MX_LABEL (priv->control_text), msg);

      g_free (msg);
    }
}
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);
    }
}
Beispiel #30
0
static void
bjb_editor_toolbar_init (BjbEditorToolbar *self)
{
  BjbEditorToolbarPrivate   *priv;
  GtkWidget                 *bin;
  GtkWidget                 *image;
  GdkPixbuf                 *pixbuf;
  GtkStyleContext           *context;
  GdkRGBA                    transparent = {0.0, 0.0, 0.0, 0.0};
  GdkRGBA                    black = {0.0, 0.0, 0.0, 0.6};
  gchar                     *icons_path, *full_path;
  GError                    *error = NULL;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_EDITOR_TOOLBAR, BjbEditorToolbarPrivate);
  priv = self->priv;

  priv->accel = gtk_accel_group_new ();

  priv->widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
  context = gtk_widget_get_style_context (priv->widget);
  gtk_style_context_add_class (context, "osd");
  gtk_style_context_add_class (context, "toolbar");

  priv->actor = gtk_clutter_actor_new_with_contents (priv->widget);
  clutter_actor_set_opacity (priv->actor, 0);
  g_object_set (priv->actor, "show-on-set-parent", FALSE, NULL);

  clutter_actor_set_easing_mode (priv->actor, CLUTTER_EASE_IN_QUAD);
  clutter_actor_set_easing_duration (priv->actor, 300.0);

  bin = gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->actor));
  gtk_widget_override_background_color (bin,
                                        GTK_STATE_FLAG_NORMAL,
                                        &transparent);

  priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  priv->group = gtk_tool_item_new ();
  gtk_container_add (GTK_CONTAINER (priv->group), priv->box);
  gtk_container_add (GTK_CONTAINER (priv->widget), GTK_WIDGET(priv->group));
  gtk_widget_show_all (GTK_WIDGET (priv->group));

  /* Cut */
  priv->toolbar_cut = gtk_button_new_with_label ("Cut");
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_cut);
  gtk_widget_override_background_color (priv->toolbar_cut,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  /* Copy */
  priv->toolbar_copy = gtk_button_new_with_label ("Copy");
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_copy);
  gtk_widget_override_background_color (priv->toolbar_copy,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  /* 'n paste */
  priv->toolbar_paste = gtk_button_new_with_label ("Paste");
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_paste);
  gtk_widget_override_background_color (priv->toolbar_paste,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  /* GtkWidget         *toolbar_bold   */
  priv->toolbar_bold = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("gtk-bold", GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
  gtk_container_add (GTK_CONTAINER (priv->toolbar_bold), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_bold), _("Bold"));
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_bold);
  gtk_widget_override_background_color (priv->toolbar_bold,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  /* GtkWidget          *toolbar_italic; */
  priv->toolbar_italic = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("gtk-italic", GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
  gtk_container_add (GTK_CONTAINER (priv->toolbar_italic), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_italic), _("Italic"));
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_italic);
  gtk_widget_override_background_color (priv->toolbar_italic,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  /* GtkWidget          *toolbar_strike; */
  priv->toolbar_strike = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("gtk-strikethrough", GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
  gtk_container_add (GTK_CONTAINER (priv->toolbar_strike), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_strike), _("Strike"));
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_strike);
  gtk_widget_override_background_color (priv->toolbar_strike,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  /* GtkWidget          *toolbar_link; */
  priv->toolbar_link = gtk_button_new ();

  icons_path = (gchar*) bijiben_get_bijiben_dir ();
  full_path = g_build_filename (icons_path,
                                "bijiben",
                                "icons",
                                "hicolor",
                                "scalable",
                                "actions",
                                "link.svg",
                                NULL);

  pixbuf = gdk_pixbuf_new_from_file (full_path, &error);
  g_free (full_path);

  if (error)
    g_warning ("error loading link icon : %s",error->message);

  image = gtk_image_new_from_pixbuf (pixbuf);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 24);

  gtk_container_add (GTK_CONTAINER (priv->toolbar_link), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_link), _("Link"));
  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_link);
  gtk_widget_override_background_color (priv->toolbar_link,
                                        GTK_STATE_FLAG_NORMAL,
                                        &black);

  priv->glued = FALSE;
  gtk_widget_show_all (GTK_WIDGET(priv->group));
  clutter_actor_show (priv->actor);
}