MessageTray: use boxpointer for summary notification

https://bugzilla.gnome.org/show_bug.cgi?id=624900
This commit is contained in:
Maxim Ermilov 2010-10-19 23:17:36 +04:00
parent 3efc7bf7f1
commit 13229a6d86
2 changed files with 72 additions and 39 deletions

View File

@ -863,9 +863,19 @@ StTooltip {
padding-bottom: 8px; padding-bottom: 8px;
} }
#summary-notification-bin #notification { .summary-notification-boxpointer {
/* message-tray.height + notification.padding-bottom */ -arrow-border-radius: 9px;
padding-bottom: 44px; -arrow-background-color: rgba(0,0,0,0.9);
-arrow-border-width: 2px;
-arrow-border-color: #5f5f5f;
-arrow-base: 30px;
-arrow-rise: 15px;
}
.summary-notification-boxpointer #notification {
border-radius: 9px;
background: rgba(0,0,0,0) !important;
padding-bottom: 12px;
} }
#notification-scrollview { #notification-scrollview {

View File

@ -12,6 +12,7 @@ const St = imports.gi.St;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
const Main = imports.ui.main; const Main = imports.ui.main;
const BoxPointer = imports.ui.boxpointer;
const Params = imports.misc.params; const Params = imports.misc.params;
const ANIMATION_TIME = 0.2; const ANIMATION_TIME = 0.2;
@ -778,15 +779,19 @@ MessageTray.prototype = {
this._summaryBin.child = this._summary; this._summaryBin.child = this._summary;
this._summaryBin.opacity = 0; this._summaryBin.opacity = 0;
this._summaryNotificationBin = new St.Bin({ name: 'summary-notification-bin', this._summaryMotionId = 0;
anchor_gravity: Clutter.Gravity.NORTH_EAST,
reactive: true, this._summaryNotificationBoxPointer = new BoxPointer.BoxPointer(St.Side.BOTTOM,
track_hover: true }); { reactive: true,
this.actor.add_actor(this._summaryNotificationBin); track_hover: true });
this._summaryNotificationBin.lower_bottom(); this._summaryNotificationBoxPointer.actor.style_class = 'summary-notification-boxpointer';
this._summaryNotificationBin.hide(); this.actor.add_actor(this._summaryNotificationBoxPointer.actor);
this._summaryNotificationBoxPointer.actor.lower_bottom();
this._summaryNotificationBoxPointer.actor.hide();
this._summaryNotification = null; this._summaryNotification = null;
this._clickedSummaryItem = null; this._clickedSummaryItem = null;
this._clickedSummaryItemAllocationChangedId = 0;
this._expandedSummaryItem = null; this._expandedSummaryItem = null;
this._summaryItemTitleWidth = 0; this._summaryItemTitleWidth = 0;
@ -817,7 +822,7 @@ MessageTray.prototype = {
Main.chrome.addActor(this.actor, { affectsStruts: false, Main.chrome.addActor(this.actor, { affectsStruts: false,
visibleInOverview: true }); visibleInOverview: true });
Main.chrome.trackActor(this._notificationBin); Main.chrome.trackActor(this._notificationBin);
Main.chrome.trackActor(this._summaryNotificationBin); Main.chrome.trackActor(this._summaryNotificationBoxPointer.actor);
global.gdk_screen.connect('monitors-changed', Lang.bind(this, this._setSizePosition)); global.gdk_screen.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
@ -859,7 +864,6 @@ MessageTray.prototype = {
// These work because of their anchor_gravity // These work because of their anchor_gravity
this._summaryBin.x = primary.width; this._summaryBin.x = primary.width;
this._summaryNotificationBin.x = primary.width;
}, },
contains: function(source) { contains: function(source) {
@ -964,7 +968,7 @@ MessageTray.prototype = {
needUpdate = true; needUpdate = true;
} }
if (this._clickedSummaryItem && this._clickedSummaryItem.source == source) { if (this._clickedSummaryItem && this._clickedSummaryItem.source == source) {
this._clickedSummaryItem = null; this._unsetClickedSummaryItem();
needUpdate = true; needUpdate = true;
} }
@ -993,7 +997,7 @@ MessageTray.prototype = {
if (!this._locked) if (!this._locked)
return; return;
this._locked = false; this._locked = false;
this._clickedSummaryItem = null; this._unsetClickedSummaryItem();
this._updateState(); this._updateState();
}, },
@ -1116,7 +1120,7 @@ MessageTray.prototype = {
if (!this._clickedSummaryItem || this._clickedSummaryItem != summaryItem) if (!this._clickedSummaryItem || this._clickedSummaryItem != summaryItem)
this._clickedSummaryItem = summaryItem; this._clickedSummaryItem = summaryItem;
else else
this._clickedSummaryItem = null; this._unsetClickedSummaryItem();
this._updateState(); this._updateState();
}, },
@ -1478,25 +1482,51 @@ MessageTray.prototype = {
if (index != -1) if (index != -1)
this._notificationQueue.splice(index, 1); this._notificationQueue.splice(index, 1);
this._summaryNotificationBin.child = this._summaryNotification.actor; this._summaryNotificationBoxPointer.bin.child = this._summaryNotification.actor;
this._summaryNotification.grabFocus(true); this._summaryNotification.grabFocus(true);
this._summaryNotificationBin.opacity = 0;
this._summaryNotificationBin.y = this.actor.height;
this._summaryNotificationBin.show();
if (!this._summaryNotificationExpandedId) if (!this._summaryNotificationExpandedId)
this._summaryNotificationExpandedId = this._summaryNotification.connect('expanded', Lang.bind(this, this._onSummaryNotificationExpanded)); this._summaryNotificationExpandedId = this._summaryNotification.connect('expanded', Lang.bind(this, this._onSummaryNotificationExpanded));
this._summaryNotification.expand(false); this._summaryNotification.expand(false);
this._clickedSummaryItemAllocationChangedId =
this._clickedSummaryItem.actor.connect('allocation-changed',
Lang.bind(this, this._adjustNotificationBoxPointerPosition));
// _clickedSummaryItem.actor can change absolute postiion without changing allocation
this._summaryMotionId = this._summary.connect('allocation-changed',
Lang.bind(this, this._adjustNotificationBoxPointerPosition));
this._summaryNotificationBoxPointer.actor.opacity = 0;
this._summaryNotificationBoxPointer.actor.show();
this._adjustNotificationBoxPointerPosition();
this._summaryNotificationState = State.SHOWNING;
this._summaryNotificationBoxPointer.animateAppear(Lang.bind(this, function() {
this._summaryNotificationState = State.SHOWN;
}));
},
_adjustNotificationBoxPointerPosition: function() {
// The position of the arrow origin should be the same as center of this._clickedSummaryItem.actor
if (!this._clickedSummaryItem)
return;
this._summaryNotificationBoxPointer.setPosition(this._clickedSummaryItem.actor, 0, St.Align.MIDDLE);
},
_unsetClickedSummaryItem: function() {
if (this._clickedSummaryItemAllocationChangedId) {
this._clickedSummaryItem.actor.disconnect(this._clickedSummaryItemAllocationChangedId);
this._summary.disconnect(this._summaryMotionId);
this._clickedSummaryItemAllocationChangedId = 0;
this._summaryMotionId = 0;
}
this._clickedSummaryItem = null;
}, },
_onSummaryNotificationExpanded: function() { _onSummaryNotificationExpanded: function() {
this._tween(this._summaryNotificationBin, '_summaryNotificationState', State.SHOWN, this._adjustNotificationBoxPointerPosition();
{ y: this.actor.height - this._summaryNotificationBin.height,
opacity: 255,
time: ANIMATION_TIME,
transition: 'easeOutQuad'
});
}, },
_hideSummaryNotification: function() { _hideSummaryNotification: function() {
@ -1504,25 +1534,18 @@ MessageTray.prototype = {
this._summaryNotification.disconnect(this._summaryNotificationExpandedId); this._summaryNotification.disconnect(this._summaryNotificationExpandedId);
this._summaryNotificationExpandedId = 0; this._summaryNotificationExpandedId = 0;
} }
// Unset this._clickedSummaryItem if we are no longer showing the summary // Unset this._clickedSummaryItem if we are no longer showing the summary
if (this._summaryState != State.SHOWN) if (this._summaryState != State.SHOWN)
this._clickedSummaryItem = null; this._unsetClickedSummaryItem();
this._summaryNotification.ungrabFocus();
this._tween(this._summaryNotificationBin, '_summaryNotificationState', State.HIDDEN, this._summaryNotification.ungrabFocus();
{ y: this.actor.height, this._summaryNotificationState = State.HIDING;
opacity: 0, this._summaryNotificationBoxPointer.animateDisappear(Lang.bind(this, this._hideSummaryNotificationCompleted));
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: this._hideSummaryNotificationCompleted,
onCompleteScope: this
});
}, },
_hideSummaryNotificationCompleted: function() { _hideSummaryNotificationCompleted: function() {
this._summaryNotificationBin.hide(); this._summaryNotificationState = State.HIDDEN;
this._summaryNotificationBin.child = null; this._summaryNotificationBoxPointer.bin.child = null;
this._summaryNotification.collapseCompleted(); this._summaryNotification.collapseCompleted();
let summaryNotification = this._summaryNotification; let summaryNotification = this._summaryNotification;
this._summaryNotification = null; this._summaryNotification = null;