[gnome-shell/wip/carlosg/pad-osd-fixes: 11/12] padOsd: Keep label coordinates in image coordinates
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/pad-osd-fixes: 11/12] padOsd: Keep label coordinates in image coordinates
- Date: Fri, 29 May 2020 15:41:39 +0000 (UTC)
commit 12a20ef28b6599fd35b457b43523dfd50fc8eb47
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 29 16:59:46 2020 +0200
padOsd: Keep label coordinates in image coordinates
Apply the necessary transforms to map those coordinates to actor
positions in the allocate phase. This all fits since it's the place
where we do know the size the actor will have.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1290
js/ui/padOsd.js | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js
index 50309e3039..932f8597b3 100644
--- a/js/ui/padOsd.js
+++ b/js/ui/padOsd.js
@@ -426,6 +426,11 @@ var PadDiagram = GObject.registerClass({
let [, natWidth] = child.get_preferred_width(natHeight);
let childBox = new Clutter.ActorBox();
+ // I miss Cairo.Matrix
+ let dimensions = this._handle.get_dimensions();
+ x = x * this._scale + this._actorWidth / 2 - dimensions.width / 2 * this._scale;
+ y = y * this._scale + this._actorHeight / 2 - dimensions.height / 2 * this._scale;
+
if (direction == LTR) {
childBox.x1 = x;
childBox.x2 = x + natWidth;
@@ -476,17 +481,6 @@ var PadDiagram = GObject.registerClass({
cr.$dispose();
}
- _transformPoint(x, y) {
- if (this._handle == null || this._scale == null)
- return [x, y];
-
- // I miss Cairo.Matrix
- let dimensions = this._handle.get_dimensions();
- x = x * this._scale + this._actorWidth / 2 - dimensions.width / 2 * this._scale;
- y = y * this._scale + this._actorHeight / 2 - dimensions.height / 2 * this._scale;
- return [Math.round(x), Math.round(y)];
- }
-
_getItemLabelCoords(labelName, leaderName) {
if (this._handle == null)
return [false];
@@ -514,9 +508,7 @@ var PadDiagram = GObject.registerClass({
pos.y = this._imageHeight - pos.y;
}
- let [x, y] = this._transformPoint(pos.x, pos.y);
-
- return [true, x, y, direction];
+ return [true, pos.x, pos.y, direction];
}
_getButtonLabels(button) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]