padOsd: Use map to store misc action label data
We'll be adding more stuff here, so it's a bit inconvenient to keep it an array. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1290
This commit is contained in:
parent
159ac3f180
commit
064633f4d5
@ -444,13 +444,13 @@ var PadDiagram = GObject.registerClass({
|
|||||||
this._updateDiagramScale();
|
this._updateDiagramScale();
|
||||||
|
|
||||||
for (let i = 0; i < this._labels.length; i++) {
|
for (let i = 0; i < this._labels.length; i++) {
|
||||||
let [label, action, idx, dir] = this._labels[i];
|
const { label, action, idx, dir } = this._labels[i];
|
||||||
let [found_, x, y, arrangement] = this._getLabelCoords(action, idx, dir);
|
let [found_, x, y, arrangement] = this._getLabelCoords(action, idx, dir);
|
||||||
this._allocateChild(label, x, y, arrangement);
|
this._allocateChild(label, x, y, arrangement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._editorActor && this._curEdited) {
|
if (this._editorActor && this._curEdited) {
|
||||||
let [label_, action, idx, dir] = this._curEdited;
|
const { action, idx, dir } = this._curEdited;
|
||||||
let [found_, x, y, arrangement] = this._getLabelCoords(action, idx, dir);
|
let [found_, x, y, arrangement] = this._getLabelCoords(action, idx, dir);
|
||||||
this._allocateChild(this._editorActor, x, y, arrangement);
|
this._allocateChild(this._editorActor, x, y, arrangement);
|
||||||
}
|
}
|
||||||
@ -575,20 +575,20 @@ var PadDiagram = GObject.registerClass({
|
|||||||
this._invalidateSvg();
|
this._invalidateSvg();
|
||||||
}
|
}
|
||||||
|
|
||||||
_addLabel(type, idx, dir) {
|
_addLabel(action, idx, dir) {
|
||||||
let [found] = this._getLabelCoords(type, idx, dir);
|
let [found] = this._getLabelCoords(action, idx, dir);
|
||||||
if (!found)
|
if (!found)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let label = new St.Label();
|
let label = new St.Label();
|
||||||
this._labels.push([label, type, idx, dir]);
|
this._labels.push({ label, action, idx, dir });
|
||||||
this.add_actor(label);
|
this.add_actor(label);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLabels(getText) {
|
updateLabels(getText) {
|
||||||
for (let i = 0; i < this._labels.length; i++) {
|
for (let i = 0; i < this._labels.length; i++) {
|
||||||
let [label, action, idx, dir] = this._labels[i];
|
const { label, action, idx, dir } = this._labels[i];
|
||||||
let str = getText(action, idx, dir);
|
let str = getText(action, idx, dir);
|
||||||
label.set_text(str);
|
label.set_text(str);
|
||||||
}
|
}
|
||||||
@ -608,13 +608,13 @@ var PadDiagram = GObject.registerClass({
|
|||||||
this._editorActor.hide();
|
this._editorActor.hide();
|
||||||
|
|
||||||
if (this._prevEdited) {
|
if (this._prevEdited) {
|
||||||
let [label, action, idx, dir] = this._prevEdited;
|
const { label, action, idx, dir } = this._prevEdited;
|
||||||
this._applyLabel(label, action, idx, dir, str);
|
this._applyLabel(label, action, idx, dir, str);
|
||||||
this._prevEdited = null;
|
this._prevEdited = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._curEdited) {
|
if (this._curEdited) {
|
||||||
let [label, action, idx, dir] = this._curEdited;
|
const { label, action, idx, dir } = this._curEdited;
|
||||||
this._applyLabel(label, action, idx, dir, str);
|
this._applyLabel(label, action, idx, dir, str);
|
||||||
if (continues)
|
if (continues)
|
||||||
this._prevEdited = this._curEdited;
|
this._prevEdited = this._curEdited;
|
||||||
@ -629,10 +629,10 @@ var PadDiagram = GObject.registerClass({
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (let i = 0; i < this._labels.length; i++) {
|
for (let i = 0; i < this._labels.length; i++) {
|
||||||
let [label, itemAction, itemIdx, itemDir] = this._labels[i];
|
if (action == this._labels[i].action &&
|
||||||
if (action == itemAction && idx == itemIdx && dir == itemDir) {
|
idx == this._labels[i].idx && dir == this._labels[i].dir) {
|
||||||
this._curEdited = this._labels[i];
|
this._curEdited = this._labels[i];
|
||||||
editedLabel = label;
|
editedLabel = this._curEdited.label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user