[gnome-shell/wip/swarm: 1/5] IconGrid: Allow animation of BaseIcon
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/swarm: 1/5] IconGrid: Allow animation of BaseIcon
- Date: Thu, 26 Jun 2014 20:06:24 +0000 (UTC)
commit 50362e2f47c8490f81a09f1382700d1c89c66a29
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Thu Jun 26 21:36:15 2014 +0200
IconGrid: Allow animation of BaseIcon
js/ui/iconGrid.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 0e068ac..b34e1ed 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -31,6 +31,9 @@ const ANIMATION_TYPE_SWARM_SPRING = 2;
const ANIMATION_DIRECTION_OUT = 0;
const ANIMATION_DIRECTION_IN = 1;
+const APPICON_ANIMATION_OUT_SCALE = 3;
+const APPICON_ANIMATION_OUT_TIME = 0.25;
+
const BaseIcon = new Lang.Class({
Name: 'BaseIcon',
@@ -188,9 +191,69 @@ const BaseIcon = new Lang.Class({
_onIconThemeChanged: function() {
this._createIconTexture(this.iconSize);
+ },
+
+ animateOut: function() {
+ actorZoomOut(this.actor);
}
});
+function actorZoomOut(actor) {
+ let actorClone = new Clutter.Clone({ source: actor,
+ reactive: false });
+ let [width, height] = actor.get_transformed_size();
+ let [x, y] = actor.get_transformed_position();
+ actorClone.set_size(width, height);
+ actorClone.set_position(x, y);
+ actorClone.opacity = 255;
+ actorClone.set_pivot_point(0.5, 0.5);
+
+ Main.uiGroup.add_actor(actorClone);
+
+ // Avoid monitor edges to avoid zomming outside the current monitor
+ let monitor = Main.layoutManager.findMonitorForActor(actor);
+ let finalWidth = width * APPICON_ANIMATION_OUT_SCALE;
+ let finalHeight = height * APPICON_ANIMATION_OUT_SCALE;
+ // Assume pivot point at 0.5, 0.5
+ let finalX = x - (finalWidth - width) / 2;
+ let finalY = y - (finalHeight - height) / 2;
+ let [vecX, vecY] = vectorToBeContainedInActor([finalX, finalY], [finalWidth, finalHeight], monitor);
+
+ Tweener.addTween(actorClone,
+ { time: APPICON_ANIMATION_OUT_TIME,
+ scale_x: APPICON_ANIMATION_OUT_SCALE,
+ scale_y: APPICON_ANIMATION_OUT_SCALE,
+ translation_x: vecX,
+ translation_y: vecY,
+ opacity: 0,
+ transition: 'easeOutQuad',
+ onComplete: function() {
+ actorClone.destroy();
+ }
+ });
+}
+
+function vectorToBeContainedInActor(position, size, actor) {
+ // Avoid actors bigger than the screen, since they cannot be contained
+ if (size[0] > actor.width || size[1] > actor.height)
+ return undefined;
+
+ let vecX = 0;
+ let vecY = 0;
+
+ if (position[0] < actor.x)
+ vecX = actor.x - position[0];
+ else if (position[0] + size[0] > actor.x + actor.width)
+ vecX = actor.x + actor.width - (position[0] + size[0]);
+
+ if (position[1] < actor.y)
+ vecY = actor.y - position[1];
+ else if (position[1] + size[1] > actor.y + actor.height)
+ vecY = actor.y + actor.height - (position[1] + size[1]);
+
+ return [vecX, vecY];
+}
+
const IconGrid = new Lang.Class({
Name: 'IconGrid',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]