[gnome-shell/wip/carlosg/pad-osd-fixes: 6/12] padOsd: Move all coord/existence checks to _addLabel()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/pad-osd-fixes: 6/12] padOsd: Move all coord/existence checks to _addLabel()
- Date: Fri, 29 May 2020 15:41:14 +0000 (UTC)
commit 991b2a88a38580aefbcd49736974be84bd1f861a
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 29 15:43:55 2020 +0200
padOsd: Move all coord/existence checks to _addLabel()
Drops some repetitive code. Also rely completely on the label/leader
elements being found in order to find buttons/rings/strips.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1290
js/ui/padOsd.js | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js
index f851ae45ae..cde879862b 100644
--- a/js/ui/padOsd.js
+++ b/js/ui/padOsd.js
@@ -345,29 +345,22 @@ var PadDiagram = GObject.registerClass({
}
_initLabels() {
- // FIXME: Fix num buttons.
let i = 0;
- for (i = 0; i < 50; i++) {
- let [found] = this._getLabelCoords(Meta.PadActionType.BUTTON, i);
- if (!found)
+ for (i = 0;; i++) {
+ if (!this._addLabel(Meta.PadActionType.BUTTON, i))
break;
- this._addLabel(Meta.PadActionType.BUTTON, i);
}
- for (i = 0; i < 2; i++) {
- let [found] = this._getLabelCoords(Meta.PadActionType.RING, i, CW);
- if (!found)
+ for (i = 0;; i++) {
+ if (!this._addLabel(Meta.PadActionType.RING, i, CW) ||
+ !this._addLabel(Meta.PadActionType.RING, i, CCW))
break;
- this._addLabel(Meta.PadActionType.RING, i, CW);
- this._addLabel(Meta.PadActionType.RING, i, CCW);
}
- for (i = 0; i < 2; i++) {
- let [found] = this._getLabelCoords(Meta.PadActionType.STRIP, i, UP);
- if (!found)
+ for (i = 0;; i++) {
+ if (!this._addLabel(Meta.PadActionType.STRIP, i, UP) ||
+ !this._addLabel(Meta.PadActionType.STRIP, i, DOWN))
break;
- this._addLabel(Meta.PadActionType.STRIP, i, UP);
- this._addLabel(Meta.PadActionType.STRIP, i, DOWN);
}
}
@@ -583,9 +576,14 @@ var PadDiagram = GObject.registerClass({
}
_addLabel(type, idx, dir) {
+ let [found] = this._getLabelCoords(type, idx, dir);
+ if (!found)
+ return false;
+
let label = new St.Label();
this._labels.push([label, type, idx, dir]);
this.add_actor(label);
+ return true;
}
updateLabels(getText) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]