[gnome-shell/wip/new-notifications: 15/17] 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: 15/17] messageTray: Add a Revealer widget and use it to animate the notification in/out
- Date: Thu, 5 Dec 2013 15:30:03 +0000 (UTC)
commit 230a105ee481158dd285019430b982938014ddbf
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 | 81 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 80 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 9d203c0..885c010 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -422,6 +422,81 @@ const NotificationApplicationPolicy = new Lang.Class({
}
});
+const RevealerLayout = new Lang.Class({
+ Name: 'RevealerLayout',
+ Extends: Clutter.LayoutManager,
+
+ _init: function() {
+ this.parent();
+
+ this._heightScale = 0;
+ },
+
+ vfunc_get_preferred_height: function(container, forWidth) {
+ let child = container.get_first_child();
+ let [minHeight, natHeight] = child.get_preferred_height(forWidth);
+ minHeight *= this._heightScale;
+ natHeight *= this._heightScale;
+ return [minHeight, natHeight];
+ },
+
+ vfunc_get_preferred_width: function(container, forHeight) {
+ let child = container.get_first_child();
+ return child.get_preferred_width(forHeight);
+ },
+
+ vfunc_allocate: function(container, box, flags) {
+ let child = container.get_first_child();
+ let [minHeight, natHeight] = child.get_preferred_height(box.x2 - box.x1);
+ // Align to the top
+ box.y2 = box.y1 + natHeight * this._heightScale;
+ child.allocate(box, flags);
+ },
+
+ 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;
+ },
+
+ _tweenTo: function(heightScale) {
+ Tweener.removeTweens(this._layout);
+ Tweener.addTween(this._layout, { heightScale: heightScale,
+ time: ANIMATION_TIME,
+ transition: 'easeOutQuad' });
+ },
+
+ set visible(value) {
+ if (this._visible == value)
+ return;
+
+ this._visible = value;
+ this._tweenTo(this._visible ? 1 : 0);
+ },
+
+ get visible() {
+ return this._visible;
+ },
+});
+
// Notification:
// @source: the notification's Source
// @title: the title
@@ -1507,6 +1582,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() {
@@ -1610,7 +1687,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);
@@ -2390,6 +2467,7 @@ const MessageTray = new Lang.Class({
onComplete: this._showNotificationCompleted,
onCompleteScope: this
});
+ this._notificationRevealer.visible = true;
},
_showNotificationCompleted: function() {
@@ -2464,6 +2542,7 @@ const MessageTray = new Lang.Class({
onComplete: this._hideNotificationCompleted,
onCompleteScope: this
});
+ this._notificationRevealer.visible = false;
} else {
Tweener.removeTweens(this._notificationWidget);
this._notificationWidget.opacity = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]