[gnome-shell/wip/carlosg/magnifier-improvements: 41/44] magnifier: Add support for animating "scroll" on focus changes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/magnifier-improvements: 41/44] magnifier: Add support for animating "scroll" on focus changes
- Date: Fri, 7 Feb 2020 17:19:28 +0000 (UTC)
commit 60c540e93aa71b5e6152d26c1bbcc57128bb1242
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Feb 6 11:00:44 2020 +0100
magnifier: Add support for animating "scroll" on focus changes
This is nice in that it provides a hint of the relative position of
the new focus area, as opposed to a sudden jump.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/984
js/ui/magnifier.js | 68 +++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 47 insertions(+), 21 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index 6e9b9e7cc3..07efadb0fe 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -1395,7 +1395,8 @@ var ZoomRegion = class ZoomRegion {
yMagFactor: this._yMagFactor,
xCenter: this._xCenter,
yCenter: this._yCenter,
- redoCursorTracking: false });
+ redoCursorTracking: false,
+ animate: false });
if (params.xMagFactor <= 0)
params.xMagFactor = this._xMagFactor;
@@ -1434,8 +1435,7 @@ var ZoomRegion = class ZoomRegion {
height: this._viewPortHeight }, true);
}
- this._updateCloneGeometry();
- this._updateMousePosition();
+ this._updateCloneGeometry(params.animate);
}
_isMouseOverRegion() {
@@ -1573,38 +1573,64 @@ var ZoomRegion = class ZoomRegion {
this._magView.set_position(this._viewPortX, this._viewPortY);
}
- _updateCloneGeometry() {
+ _updateCloneGeometry(animate = false) {
if (!this.isActive())
return;
- this._uiGroupClone.set_scale(this._xMagFactor, this._yMagFactor);
- this._mouseActor.set_scale(this._xMagFactor, this._yMagFactor);
-
let [x, y] = this._screenToViewPort(0, 0);
- this._uiGroupClone.set_position(Math.round(x), Math.round(y));
+ this._uiGroupClone.ease({
+ x: Math.round(x),
+ y: Math.round(y),
+ scale_x: this._xMagFactor,
+ scale_y: this._yMagFactor,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ duration: animate ? 100 : 0,
+ });
- this._updateMousePosition();
+ let [mouseX, mouseY] = this._getMousePosition();
+ this._mouseActor.ease({
+ x: mouseX,
+ y: mouseY,
+ scale_x: this._xMagFactor,
+ scale_y: this._yMagFactor,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ duration: animate ? 100 : 0,
+ });
+
+ if (this._crossHairsActor) {
+ let [crossX, crossY] = this._getCrossHairsPosition();
+ this._crossHairsActor.ease({
+ x: crossX,
+ y: crossY,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ duration: animate ? 100 : 0,
+ });
+ }
}
_updateMousePosition() {
- if (!this.isActive())
- return;
-
- let [xMagMouse, yMagMouse] = this._screenToViewPort(this._magnifier.xMouse,
- this._magnifier.yMouse);
-
- xMagMouse = Math.round(xMagMouse);
- yMagMouse = Math.round(yMagMouse);
-
+ let [xMagMouse, yMagMouse] = this._getMousePosition();
this._mouseActor.set_position(xMagMouse, yMagMouse);
if (this._crossHairsActor) {
- let [groupWidth, groupHeight] = this._crossHairsActor.get_size();
- this._crossHairsActor.set_position(xMagMouse - groupWidth / 2,
- yMagMouse - groupHeight / 2);
+ let [crossX, crossY] = this._getCrossHairsPosition();
+ this._crossHairsActor.set_position(crossX, crossY);
}
}
+ _getMousePosition() {
+ let [xMagMouse, yMagMouse] = this._screenToViewPort(
+ this._magnifier.xMouse, this._magnifier.yMouse);
+ return [Math.round(xMagMouse), Math.round(yMagMouse)];
+ }
+
+ _getCrossHairsPosition() {
+ let [xMagMouse, yMagMouse] = this._getMousePosition();
+ let [groupWidth, groupHeight] = this._crossHairsActor.get_size();
+
+ return [xMagMouse - groupWidth / 2, yMagMouse - groupHeight / 2];
+ }
+
_monitorsChanged() {
this._background.set_size(global.screen_width, global.screen_height);
this._updateScreenPosition();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]