Created
February 17, 2020 06:57
-
-
Save rodolf0/de8c733f0fb991e8d0aa368096afd2c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
01:56:18 ~/tmp/dash-to-dock 0 $ git show | cat | |
commit 8b12243259e0ebc17b645fece5867b0205427866 | |
Author: Rodolfo Granata <warlock.cc@gmail.com> | |
Date: Sat Feb 15 03:56:02 2020 -0500 | |
zoom effect - v0 | |
diff --git a/appIcons.js b/appIcons.js | |
index 7e4a0f4..0b68f28 100644 | |
--- a/appIcons.js | |
+++ b/appIcons.js | |
@@ -273,7 +273,7 @@ var MyAppIcon = class DashToDock_AppIcon extends Dash.DashIcon { | |
} | |
/** | |
- * Update taraget for minimization animation | |
+ * Update target for minimization animation | |
*/ | |
updateIconGeometry() { | |
// If (for unknown reason) the actor is not on the stage the reported size | |
diff --git a/dash.js b/dash.js | |
index 07f6c61..e5cb2e5 100644 | |
--- a/dash.js | |
+++ b/dash.js | |
@@ -39,6 +39,24 @@ const DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; | |
let MyDashItemContainer = GObject.registerClass( | |
class DashToDock_MyDashItemContainer extends Dash.DashItemContainer { | |
+ _init() { | |
+ super._init(); | |
+ switch (Utils.getPosition()) { | |
+ case St.Side.LEFT: | |
+ this.x_align = Clutter.ActorAlign.START; | |
+ break; | |
+ case St.Side.RIGHT: | |
+ this.x_align = Clutter.ActorAlign.END; | |
+ break; | |
+ case St.Side.TOP: | |
+ this.y_align = Clutter.ActorAlign.START; | |
+ break; | |
+ case St.Side.BOTTOM: | |
+ this.y_align = Clutter.ActorAlign.END; | |
+ break; | |
+ } | |
+ } | |
+ | |
showLabel() { | |
return AppIcons.itemShowLabel.call(this); | |
} | |
@@ -214,7 +232,7 @@ var MyDash = GObject.registerClass({ | |
this._box = new St.BoxLayout({ | |
vertical: !this._isHorizontal, | |
clip_to_allocation: false, | |
- x_align: Clutter.ActorAlign.START, | |
+ x_align: Clutter.ActorAlign.FILL, | |
y_align: Clutter.ActorAlign.START | |
}); | |
this._box._delegate = this; | |
@@ -436,7 +454,6 @@ var MyDash = GObject.registerClass({ | |
this._monitorIndex, | |
{ setSizeManually: true, | |
showLabel: false }); | |
- | |
if (appIcon._draggable) { | |
appIcon._draggable.connect('drag-begin', () => { | |
appIcon.actor.opacity = 50; | |
@@ -588,6 +605,32 @@ var MyDash = GObject.registerClass({ | |
} | |
} | |
+ _zoomIcons(hover) { | |
+ let buttons = this._box.get_children().filter(function(actor) { | |
+ return actor.child && | |
+ actor.child._delegate && | |
+ actor.child._delegate.icon && | |
+ !actor.animatingOut; | |
+ }); | |
+ | |
+ let [mouse_x, mouse_y, mask] = global.get_pointer(); | |
+ | |
+ for (let i = 0; i < buttons.length; i++) { | |
+ let scale_factor = 1.0; | |
+ let button = buttons[i]; //.child._delegate.icon; | |
+ if (hover) { | |
+ let [ix, iy] = button.get_transformed_position(); | |
+ let [iw, ih] = button.get_transformed_size(); | |
+ let c = this._isHorizontal ? | |
+ Math.abs(ix + iw/2.0 - mouse_x): | |
+ Math.abs(iy + ih/2.0 - mouse_y); | |
+ scale_factor = Math.max(2.0 - 0.00004 * c * c, 1.0); | |
+ } | |
+ button.set_pivot_point(0.0, 0.0); | |
+ button.set_scale(scale_factor, scale_factor); | |
+ } | |
+ } | |
+ | |
_adjustIconSize() { | |
// For the icon size, we only consider children which are "proper" | |
// icons (i.e. ignoring drag placeholders) and which are not | |
@@ -650,7 +693,6 @@ var MyDash = GObject.registerClass({ | |
let availSize = availHeight / iconChildren.length; | |
- | |
let newIconSize = this._availableIconSizes[0]; | |
for (let i = 0; i < iconSizes.length; i++) { | |
if (iconSizes[i] < availSize) | |
diff --git a/docking.js b/docking.js | |
index 9a6cf8c..30b17d5 100644 | |
--- a/docking.js | |
+++ b/docking.js | |
@@ -249,6 +249,7 @@ var DockedDash = GObject.registerClass({ | |
track_hover: true | |
}); | |
this._box.connect('notify::hover', this._hoverChanged.bind(this)); | |
+ this._box.connect('motion-event', this._mouseMove.bind(this)); | |
// Create and apply height constraint to the dash. It's controlled by this.height | |
this.constrainSize = new Clutter.BindConstraint({ | |
@@ -649,6 +650,10 @@ var DockedDash = GObject.registerClass({ | |
} | |
_hoverChanged() { | |
+ // TODO(rodolf0): trigger setting icon size to original scale this way? | |
+ if (!this._box.hover) | |
+ this.dash._zoomIcons(false); | |
+ | |
if (!this._ignoreHover) { | |
// Skip if dock is not in autohide mode for instance because it is shown | |
// by intellihide. | |
@@ -661,6 +666,10 @@ var DockedDash = GObject.registerClass({ | |
} | |
} | |
+ _mouseMove() { | |
+ this.dash._zoomIcons(true); | |
+ } | |
+ | |
getDockState() { | |
return this._dockState; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment