[gnome-shell/wip/exalm/gestures: 35/47] workspaceThumbnail: Use scroll adjustment
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/exalm/gestures: 35/47] workspaceThumbnail: Use scroll adjustment
- Date: Mon, 5 Aug 2019 12:15:46 +0000 (UTC)
commit 46459fd791ac8ce9ef465ee53f494e13e59285f5
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Fri Jun 28 01:51:10 2019 +0500
workspaceThumbnail: Use scroll adjustment
This will allow it to share adjustment with WorkspacesDisplay in the next
commit.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/605
js/ui/workspaceThumbnail.js | 75 +++++++++++++++++++++++----------------------
1 file changed, 39 insertions(+), 36 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index b2b7eeb9c..c89a17b93 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -626,7 +626,6 @@ class ThumbnailsBox extends St.Widget {
this._pendingScaleUpdate = false;
this._stateUpdateQueued = false;
this._animatingIndicator = false;
- this._indicatorY = 0; // only used when _animatingIndicator is true
this._stateCounts = {};
for (let key in ThumbnailState)
@@ -673,6 +672,19 @@ class ThumbnailsBox extends St.Widget {
this._nWorkspacesNotifyId = 0;
this._syncStackingId = 0;
this._workareasChangedId = 0;
+
+ let workspaceManager = global.workspace_manager;
+ let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
+ this._scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
+ lower: 0,
+ page_increment: 1,
+ page_size: 1,
+ step_increment: 0,
+ upper: workspaceManager.n_workspaces });
+
+ this._scrollAdjustment.connect('notify::value', adj => {
+ this.queue_relayout();
+ });
}
_updateSwitcherVisibility() {
@@ -927,6 +939,8 @@ class ThumbnailsBox extends St.Widget {
let oldNumWorkspaces = validThumbnails.length;
let newNumWorkspaces = workspaceManager.n_workspaces;
+ this._scrollAdjustment.upper = newNumWorkspaces;
+
if (newNumWorkspaces > oldNumWorkspaces) {
this.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
} else {
@@ -1011,15 +1025,6 @@ class ThumbnailsBox extends St.Widget {
return this._scale;
}
- set indicatorY(indicatorY) {
- this._indicatorY = indicatorY;
- this.queue_relayout();
- }
-
- get indicatorY() {
- return this._indicatorY;
- }
-
_setThumbnailState(thumbnail, state) {
this._stateCounts[thumbnail.state]--;
thumbnail.state = state;
@@ -1219,13 +1224,16 @@ class ThumbnailsBox extends St.Widget {
else
slideOffset = thumbnailWidth + themeNode.get_padding(St.Side.RIGHT);
- let indicatorY1 = this._indicatorY;
- let indicatorY2;
- // when not animating, the workspace position overrides this._indicatorY
- let activeWorkspace = workspaceManager.get_active_workspace();
- let indicatorWorkspace = !this._animatingIndicator ? activeWorkspace : null;
- let indicatorThemeNode = this._indicator.get_theme_node();
+ let indicatorValue = this._scrollAdjustment.value;
+ let indicatorUpperWs = Math.ceil(indicatorValue);
+ let indicatorLowerWs = Math.floor(indicatorValue);
+
+ let indicatorLowerY1;
+ let indicatorLowerY2;
+ let indicatorUpperY1;
+ let indicatorUpperY2;
+ let indicatorThemeNode = this._indicator.get_theme_node();
let indicatorTopFullBorder = indicatorThemeNode.get_padding(St.Side.TOP) +
indicatorThemeNode.get_border_width(St.Side.TOP);
let indicatorBottomFullBorder = indicatorThemeNode.get_padding(St.Side.BOTTOM) +
indicatorThemeNode.get_border_width(St.Side.BOTTOM);
let indicatorLeftFullBorder = indicatorThemeNode.get_padding(St.Side.LEFT) +
indicatorThemeNode.get_border_width(St.Side.LEFT);
@@ -1277,9 +1285,13 @@ class ThumbnailsBox extends St.Widget {
let y2 = Math.round(y + thumbnailHeight);
let roundedVScale = (y2 - y1) / portholeHeight;
- if (thumbnail.metaWorkspace == indicatorWorkspace) {
- indicatorY1 = y1;
- indicatorY2 = y2;
+ if (i == indicatorUpperWs) {
+ indicatorUpperY1 = y1;
+ indicatorUpperY2 = y2;
+ }
+ if (i == indicatorLowerWs) {
+ indicatorLowerY1 = y1;
+ indicatorLowerY2 = y2;
}
// Allocating a scaled actor is funny - x1/y1 correspond to the origin
@@ -1305,30 +1317,21 @@ class ThumbnailsBox extends St.Widget {
childBox.x1 = box.x2 - thumbnailWidth;
childBox.x2 = box.x2;
}
+ let indicatorY1 = indicatorLowerY1 + (indicatorUpperY1 - indicatorLowerY1) * (indicatorValue % 1);
+ let indicatorY2 = indicatorLowerY2 + (indicatorUpperY2 - indicatorLowerY2) * (indicatorValue % 1);
+
childBox.x1 -= indicatorLeftFullBorder;
childBox.x2 += indicatorRightFullBorder;
childBox.y1 = indicatorY1 - indicatorTopFullBorder;
- childBox.y2 = (indicatorY2 ? indicatorY2 : (indicatorY1 + thumbnailHeight)) +
indicatorBottomFullBorder;
+ childBox.y2 = indicatorY2 + indicatorBottomFullBorder;
this._indicator.allocate(childBox, flags);
}
- _activeWorkspaceChanged(_wm, _from, _to, _direction) {
- let thumbnail;
- let workspaceManager = global.workspace_manager;
- let activeWorkspace = workspaceManager.get_active_workspace();
- for (let i = 0; i < this._thumbnails.length; i++) {
- if (this._thumbnails[i].metaWorkspace == activeWorkspace) {
- thumbnail = this._thumbnails[i];
- break;
- }
- }
-
+ _activeWorkspaceChanged(_wm, from, to, _direction) {
+ this._scrollAdjustment.value = from;
this._animatingIndicator = true;
- let indicatorThemeNode = this._indicator.get_theme_node();
- let indicatorTopFullBorder = indicatorThemeNode.get_padding(St.Side.TOP) +
indicatorThemeNode.get_border_width(St.Side.TOP);
- this.indicatorY = this._indicator.allocation.y1 + indicatorTopFullBorder;
- Tweener.addTween(this,
- { indicatorY: thumbnail.actor.allocation.y1,
+ Tweener.addTween(this._scrollAdjustment,
+ { value: to,
time: WorkspacesView.WORKSPACE_SWITCH_TIME,
transition: 'easeOutQuad',
onComplete: () => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]