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

@ -142,6 +142,9 @@
this._emptyHelper = new LocalModel();
this._gc.on("serviceMessage", this._onServiceMessage, this);
this._ps.on("serviceMessage", this._onServiceMessage, this);
this._gc.on("themeSelected", this.setTheme, this);
this._ps.on("pageName", this._onPageName, this);
},
@ -175,6 +178,24 @@
address: this._currentPageCtl.getPairAddress().toArray()
}, "", name);
},
"_onServiceMessage": function(text, severity) {
var fn;
switch (severity) {
case 2:
fn = console.error;
break;
case 1:
fn = console.warn;
break;
case 0:
default:
fn = console.info;
break;
}
fn(text);
},
"_onSocketConnected": function(name) {
console.log(name + " socket connected");
var node = this._nodes[name];
@ -301,6 +322,8 @@
this._playerCtl.register(this.dispatcher, this._nodes["Corax"].socket);
this._playerCtl.subscribe();
this._mainLayout.appendPlayer(this._playerCtl);
this._playerCtl.on("serviceMessage", this._onServiceMessage, this);
},
"setTheme": function(theme) {
View.setTheme(theme);

View file

@ -47,5 +47,13 @@ div.dragging .draggable {
}
.disabled {
opacity: 0.7;
opacity: 0.5;
}
.button {
cursor: pointer
}
.button.disabled {
cursor: not-allowed
}

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];