padOsd: Figure out label/edition UI positions from unchanged fonts

We can figure out the position to render the text without resorting to
font sizes that make the whole text element sub-pixel size. As the
original labels in the SVG are themed invisible anyway, calculate the
button/ring/strip label and configuration UI position from their unchanged
size/location.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5415
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2288>
This commit is contained in:
Carlos Garnacho 2022-04-30 14:09:37 +02:00 committed by Marge Bot
parent 329a286303
commit a89d2aed84
2 changed files with 9 additions and 10 deletions

View File

@ -19,7 +19,6 @@
.Label { .Label {
stroke: none !important; stroke: none !important;
stroke-width: .1 !important; stroke-width: .1 !important;
font-size: .1 !important;
fill: transparent !important; fill: transparent !important;
} }

View File

@ -485,23 +485,23 @@ var PadDiagram = GObject.registerClass({
if (this._handle == null) if (this._handle == null)
return [false]; return [false];
let leaderPos, leaderSize, pos; const [labelFound, labelPos] = this._handle.get_position_sub(`#${labelName}`);
let found, direction; const [, labelSize] = this._handle.get_dimensions_sub(`#${labelName}`);
if (!labelFound)
[found, pos] = this._handle.get_position_sub(`#${labelName}`);
if (!found)
return [false]; return [false];
[found, leaderPos] = this._handle.get_position_sub(`#${leaderName}`); const [leaderFound, leaderPos] = this._handle.get_position_sub(`#${leaderName}`);
[found, leaderSize] = this._handle.get_dimensions_sub(`#${leaderName}`); const [, leaderSize] = this._handle.get_dimensions_sub(`#${leaderName}`);
if (!found) if (!leaderFound)
return [false]; return [false];
if (pos.x > leaderPos.x + leaderSize.width) let direction;
if (labelPos.x > leaderPos.x + leaderSize.width)
direction = LTR; direction = LTR;
else else
direction = RTL; direction = RTL;
let pos = {x: labelPos.x, y: labelPos.y + labelSize.height};
if (this.leftHanded) { if (this.leftHanded) {
direction = 1 - direction; direction = 1 - direction;
pos.x = this._imageWidth - pos.x; pos.x = this._imageWidth - pos.x;