[gnome-shell/wip/new-notifications: 559/569] messageTray: Add a Revealer widget and use it to animate the notification in/out
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/new-notifications: 559/569] messageTray: Add a Revealer widget and use it to animate the notification in/out
- Date: Tue, 3 Jun 2014 18:03:37 +0000 (UTC)
commit 060917ae2bc7e011569fbb43a97ade5503cc2ed4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Dec 5 02:13:07 2013 -0500
messageTray: Add a Revealer widget and use it to animate the notification in/out
js/ui/messageTray.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 66 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 7347183..30b90e5 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -422,6 +422,66 @@ const NotificationApplicationPolicy = new Lang.Class({
}
});
+const RevealerLayout = new Lang.Class({
+ Name: 'RevealerLayout',
+ Extends: Clutter.BinLayout,
+
+ _init: function() {
+ this.parent();
+
+ this._heightScale = 0;
+ },
+
+ vfunc_get_preferred_height: function(container, forWidth) {
+ let [minHeight, natHeight] = this.parent(container, forWidth);
+ minHeight *= this._heightScale;
+ natHeight *= this._heightScale;
+ return [minHeight, natHeight];
+ },
+
+ set heightScale(value) {
+ if (this._heightScale == value)
+ return;
+
+ this._heightScale = value;
+ this.layout_changed();
+ },
+
+ get heightScale() {
+ return this._heightScale;
+ },
+});
+
+const Revealer = new Lang.Class({
+ Name: 'Revealer',
+
+ _init: function(child) {
+ this._layout = new RevealerLayout();
+ this.actor = new St.Widget({ layout_manager: this._layout });
+ this.actor.add_child(child);
+
+ this._visible = false;
+ },
+
+ _setTo: function(heightScale, animate) {
+ Tweener.removeTweens(this._layout);
+ if (animate)
+ Tweener.addTween(this._layout, { heightScale: heightScale,
+ time: ANIMATION_TIME,
+ transition: 'easeOutQuad' });
+ else
+ this._layout.heightScale = heightScale;
+ },
+
+ show: function(animate) {
+ this._setTo(1, animate);
+ },
+
+ hide: function(animate) {
+ this._setTo(0, animate);
+ },
+});
+
// Notification:
// @source: the notification's Source
// @title: the title
@@ -1468,6 +1528,8 @@ const MessageTray = new Lang.Class({
y_expand: true,
x_expand: true,
layout_manager: new Clutter.BinLayout() });
+ this._notificationRevealer = new Revealer(this._notificationWidget);
+
this._notificationWidget.connect('key-release-event', Lang.bind(this,
this._onNotificationKeyRelease));
this._notificationWidget.connect('notify::hover', Lang.bind(this, this._onNotificationHoverChanged));
this._notificationWidget.connect('notify::height', Lang.bind(this, function() {
@@ -1572,7 +1634,7 @@ const MessageTray = new Lang.Class({
}));
Main.layoutManager.trayBox.add_actor(this.actor);
- Main.layoutManager.trayBox.add_actor(this._notificationWidget);
+ Main.layoutManager.trayBox.add_actor(this._notificationRevealer.actor);
Main.layoutManager.trackChrome(this.actor);
Main.layoutManager.trackChrome(this._notificationWidget);
Main.layoutManager.trackChrome(this._closeButton);
@@ -2344,6 +2406,7 @@ const MessageTray = new Lang.Class({
onComplete: this._showNotificationCompleted,
onCompleteScope: this
});
+ this._notificationRevealer.show(true);
},
_showNotificationCompleted: function() {
@@ -2414,11 +2477,13 @@ const MessageTray = new Lang.Class({
onComplete: this._hideNotificationCompleted,
onCompleteScope: this
});
+ this._notificationRevealer.hide(true);
} else {
Tweener.removeTweens(this._notificationWidget);
this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN;
this._hideNotificationCompleted();
+ this._notificationRevealer.hide(false);
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]