[gnome-shell/wip/exalm/gestures: 37/50] workspaceThumbnail: Use scroll adjustment
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/exalm/gestures: 37/50] workspaceThumbnail: Use scroll adjustment
- Date: Wed, 16 Oct 2019 21:50:29 +0000 (UTC)
commit 08a003560644dce837c5d5cacb3977c20cc55492
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 | 73 +++++++++++++++++++++++----------------------
1 file changed, 38 insertions(+), 35 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index ff23d9e2e7..f802519848 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -660,7 +660,6 @@ var ThumbnailsBox = GObject.registerClass({
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)
@@ -703,6 +702,19 @@ var ThumbnailsBox = GObject.registerClass({
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() {
@@ -970,6 +982,8 @@ var ThumbnailsBox = GObject.registerClass({
let oldNumWorkspaces = validThumbnails.length;
let newNumWorkspaces = workspaceManager.n_workspaces;
+ this._scrollAdjustment.upper = newNumWorkspaces;
+
if (newNumWorkspaces > oldNumWorkspaces) {
this.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
} else {
@@ -1058,21 +1072,6 @@ var ThumbnailsBox = GObject.registerClass({
return this._scale;
}
- // eslint-disable-next-line camelcase
- set indicator_y(indicatorY) {
- if (this._indicatorY == indicatorY)
- return;
-
- this._indicatorY = indicatorY;
- this.notify('indicator-y');
- this.queue_relayout();
- }
-
- // eslint-disable-next-line camelcase
- get indicator_y() {
- return this._indicatorY;
- }
-
_setThumbnailState(thumbnail, state) {
this._stateCounts[thumbnail.state]--;
thumbnail.state = state;
@@ -1264,13 +1263,16 @@ var ThumbnailsBox = GObject.registerClass({
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);
@@ -1322,9 +1324,13 @@ var ThumbnailsBox = GObject.registerClass({
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
@@ -1350,23 +1356,20 @@ var ThumbnailsBox = GObject.registerClass({
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 workspaceManager = global.workspace_manager;
- let activeWorkspace = workspaceManager.get_active_workspace();
- let thumbnail = this._thumbnails.find(t => t.metaWorkspace == activeWorkspace);
-
+ _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.indicator_y = this._indicator.allocation.y1 + indicatorTopFullBorder;
- this.ease_property('indicator-y', thumbnail.allocation.y1, {
+ this._scrollAdjustment.ease(to, {
progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
duration: WorkspacesView.WORKSPACE_SWITCH_TIME,
onComplete: () => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]