Next and Prev buttons for Corax and Lorgar, debugging

This commit is contained in:
Blue 2019-01-03 03:26:42 +03:00 committed by Gitea
parent 7fdcb657a4
commit baa6f4ef23
14 changed files with 394 additions and 72 deletions

View file

@ -20,6 +20,7 @@
Layout.fn.constructor.call(this, controller, base);
this.addClass("hoverable");
this.addClass("button");
this._enabled = true;
this._hasLabel = false;
this._e.addEventListener("click", this._onClick.bind(this), false);
@ -27,10 +28,8 @@
controller.on("setEnabled", this._onSetEnabled, this);
controller.on("setLabel", this._onSetLabel, this);
if (controller.initialized) {
this._onSetEnabled(controller.enabled);
this._onSetLabel(controller.hasLabel, controller.label);
}
this._onSetEnabled(controller.enabled);
this._onSetLabel(controller.hasLabel, controller.label);
},
"destructor": function() {
this._f.off("setEnabled", this._onSetEnabled, this);

View file

@ -30,6 +30,8 @@
GridLayout.fn.constructor.call(this, ctrl, options);
this._playPause = null;
this._prev = null;
this._next = null;
this._picture = null;
this._cpbCtrl = null;
this._infoModels = {
@ -39,16 +41,17 @@
}
ctrl.on("newElement", this._onNewElement, this);
ctrl.on("removeElement", this._onRemoveElement, this);
var artist = new Label(this._infoModels.artist);
var album = new Label(this._infoModels.album);
var song = new Label(this._infoModels.song);
var spacer = new View(helper);
this.append(artist, 0, 2, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(song, 1, 2, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(album, 2, 2, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(spacer, 0, 3, 3, 1, GridLayout.Aligment.LeftCenter);
this.append(artist, 0, 4, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(song, 1, 4, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(album, 2, 4, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(spacer, 0, 5, 3, 1, GridLayout.Aligment.LeftCenter);
this._uncyclic.push(this._infoModels.artist.destructor.bind(this._infoModels.artist));
this._uncyclic.push(this._infoModels.song.destructor.bind(this._infoModels.song));
@ -56,6 +59,7 @@
},
destructor: function() {
this._f.off("newElement", this._onNewElement, this);
this._f.off("removeElement", this._onRemoveElement, this);
this._clearCpbCtrl();
GridLayout.fn.destructor.call(this);
@ -73,7 +77,15 @@
switch (type) {
case ItemType.straight.playPause:
this._playPause = new Button(ctrl);
this.append(this._playPause, 0, 1, 3, 1);
this.append(this._playPause, 0, 2, 3, 1);
break;
case ItemType.straight.prev:
this._prev = new Button(ctrl);
this.append(this._prev, 0, 1, 3, 1);
break;
case ItemType.straight.next:
this._next = new Button(ctrl);
this.append(this._next, 0, 3, 3, 1);
break;
case ItemType.straight.queue:
break;
@ -92,6 +104,33 @@
break;
}
},
_onRemoveElement: function(type) {
var ItemType = Enum.storage["ItemType"];
switch (type) {
case ItemType.straight.playPause:
this._playPause.destructor();
this._playPause = null;
break;
case ItemType.straight.prev:
this._prev.destructor();
this._prev = null;
break;
case ItemType.straight.next:
this._next.destructor();
this._next = null;
break;
case ItemType.straight.queue:
break;
case ItemType.straight.currentPlayback:
this._clearCpbCtrl();
break;
case ItemType.straight.picture:
this._picture.destructor();
this._picture = null;
break;
}
},
_onCpbNewElement: function(key, value) {
var model = this._infoModels[key];