[gnome-shell/wip/carlosg/pad-osd-fixes: 2/10] padOsd: Move button/ring/strip label creation to PadDiagram
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/pad-osd-fixes: 2/10] padOsd: Move button/ring/strip label creation to PadDiagram
- Date: Fri, 29 May 2020 15:49:13 +0000 (UTC)
commit 5540b96c29c8342c51ec735bae7326daea598e1f
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu May 28 14:03:13 2020 +0200
padOsd: Move button/ring/strip label creation to PadDiagram
It's the natural container of those. We can create all those labels
internally, and only expose the updateLabels() method to update them
wholesome.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1290
js/ui/padOsd.js | 62 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js
index 221c8ddd6d..d874f000e2 100644
--- a/js/ui/padOsd.js
+++ b/js/ui/padOsd.js
@@ -329,6 +329,7 @@ var PadDiagram = GObject.registerClass({
this._imagePath = imagePath;
this._handle = this._composeStyledDiagram();
+ this._initLabels();
}
// eslint-disable-next-line camelcase
@@ -343,6 +344,33 @@ var PadDiagram = GObject.registerClass({
this.add_actor(actor);
}
+ _initLabels() {
+ // FIXME: Fix num buttons.
+ let i = 0;
+ for (i = 0; i < 50; i++) {
+ let [found] = this.getButtonLabelCoords(i);
+ if (!found)
+ break;
+ this._addLabel(Meta.PadActionType.BUTTON, i);
+ }
+
+ for (i = 0; i < 2; i++) {
+ let [found] = this.getRingLabelCoords(i, CW);
+ if (!found)
+ break;
+ this._addLabel(Meta.PadActionType.RING, i, CW);
+ this._addLabel(Meta.PadActionType.RING, i, CCW);
+ }
+
+ for (i = 0; i < 2; i++) {
+ let [found] = this.getStripLabelCoords(i, UP);
+ if (!found)
+ break;
+ this._addLabel(Meta.PadActionType.STRIP, i, UP);
+ this._addLabel(Meta.PadActionType.STRIP, i, DOWN);
+ }
+ }
+
_wrappingSvgHeader() {
return '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" ' +
@@ -557,7 +585,8 @@ var PadDiagram = GObject.registerClass({
this._invalidateSvg();
}
- addLabel(label, type, idx, dir) {
+ _addLabel(type, idx, dir) {
+ let label = new St.Label();
this._labels.push([label, type, idx, dir]);
this.add_actor(label);
}
@@ -711,31 +740,7 @@ var PadOsd = GObject.registerClass({
x_expand: true,
y_expand: true });
this.add_actor(this._padDiagram);
-
- // FIXME: Fix num buttons.
- let i = 0;
- for (i = 0; i < 50; i++) {
- let [found] = this._padDiagram.getButtonLabelCoords(i);
- if (!found)
- break;
- this._createLabel(Meta.PadActionType.BUTTON, i);
- }
-
- for (i = 0; i < padDevice.get_n_rings(); i++) {
- let [found] = this._padDiagram.getRingLabelCoords(i, CW);
- if (!found)
- break;
- this._createLabel(Meta.PadActionType.RING, i, CW);
- this._createLabel(Meta.PadActionType.RING, i, CCW);
- }
-
- for (i = 0; i < padDevice.get_n_strips(); i++) {
- let [found] = this._padDiagram.getStripLabelCoords(i, UP);
- if (!found)
- break;
- this._createLabel(Meta.PadActionType.STRIP, i, UP);
- this._createLabel(Meta.PadActionType.STRIP, i, DOWN);
- }
+ this._updateActionLabels();
let buttonBox = new St.Widget({ layout_manager: new Clutter.BinLayout(),
x_expand: true,
@@ -788,11 +793,6 @@ var PadOsd = GObject.registerClass({
return str ? str : _("None");
}
- _createLabel(type, number, dir) {
- let label = new St.Label({ text: this._getActionText(type, number) });
- this._padDiagram.addLabel(label, type, number, dir);
- }
-
_updateActionLabels() {
this._padDiagram.updateLabels(this._getActionText.bind(this));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]