a draft of player view, debug
This commit is contained in:
parent
46560924ce
commit
c8b432fe57
13 changed files with 183 additions and 33 deletions
|
@ -13,5 +13,6 @@ configure_file(pane.js pane.js)
|
|||
configure_file(image.js image.js)
|
||||
configure_file(button.js button.js)
|
||||
configure_file(enumeration.js enumeration.js)
|
||||
configure_file(player.js player.js)
|
||||
|
||||
add_subdirectory(helpers)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
defineArray.push("views/navigationPanel");
|
||||
defineArray.push("views/layout");
|
||||
defineArray.push("views/enumeration");
|
||||
defineArray.push("views/player");
|
||||
defineArray.push("lib/wController/localModel");
|
||||
|
||||
define(moduleName, defineArray, function mainLayout_module() {
|
||||
|
@ -18,6 +19,7 @@
|
|||
var ViewNavigationPanel = require("views/navigationPanel");
|
||||
var Layout = require("views/layout");
|
||||
var Enumeration = require("views/enumeration");
|
||||
var Player = require("views/player");
|
||||
var LocalModel = require("lib/wController/localModel");
|
||||
|
||||
var MainLayout = GridLayout.inherit({
|
||||
|
@ -26,6 +28,7 @@
|
|||
GridLayout.fn.constructor.call(this, controller, options);
|
||||
|
||||
this._statusBarPosition = 2;
|
||||
this._player = undefined;
|
||||
|
||||
this._mainColorHelper = new LocalModel({backgroundColor: "mainColor"});
|
||||
this._statusBarModel = new LocalModel({backgroundColor: "secondaryColor"});
|
||||
|
@ -72,6 +75,21 @@
|
|||
this._statusBar.append(e, 0, this._statusBarPosition++, 1, 1, Layout.Aligment.LeftCenter);
|
||||
|
||||
this._uncyclic.push(lm.destructor.bind(lm));
|
||||
},
|
||||
appendPlayer: function(playerModel) {
|
||||
if (this._player !== undefined) {
|
||||
throw new Error("An attempt to add player to main layout for the second time");
|
||||
}
|
||||
this._player = new Player(playerModel);
|
||||
this.append(this._player, 2, 0, 1, 3);
|
||||
},
|
||||
removePlayer: function() {
|
||||
if (this._player === undefined) {
|
||||
throw new Error("An attempt to remove non existing player from mainLayout");
|
||||
}
|
||||
this.removeChild(this._player);
|
||||
this._player.destructor();
|
||||
this._player = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
99
lorgar/views/player.js
Normal file
99
lorgar/views/player.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
"use strict";
|
||||
(function() {
|
||||
var moduleName = "views/player"
|
||||
|
||||
var deps = [];
|
||||
deps.push("views/gridLayout");
|
||||
deps.push("views/button");
|
||||
deps.push("views/label");
|
||||
|
||||
deps.push("lib/wController/localModel");
|
||||
|
||||
deps.push("lib/utils/enum");
|
||||
|
||||
define(moduleName, deps, function() {
|
||||
var GridLayout = require("views/gridLayout");
|
||||
var Button = require("views/button");
|
||||
var Label = require("views/label");
|
||||
|
||||
var Model = require("lib/wController/localModel");
|
||||
|
||||
var Enum = require("lib/utils/enum");
|
||||
|
||||
var Player = GridLayout.inherit({
|
||||
className: "Player",
|
||||
constructor: function(ctrl, options) {
|
||||
GridLayout.fn.constructor.call(this, ctrl, options);
|
||||
|
||||
this._playPause = null;
|
||||
this._cpbCtrl = null;
|
||||
this._infoModels = {
|
||||
artist: new Model(null, "artist: unknown"),
|
||||
album: new Model(null, "album: unknown"),
|
||||
song: new Model(null, "song: unknown")
|
||||
}
|
||||
|
||||
ctrl.on("newElement", this._onNewElement, this);
|
||||
|
||||
var artist = new Label(this._infoModels.artist);
|
||||
var album = new Label(this._infoModels.album);
|
||||
var song = new Label(this._infoModels.song);
|
||||
|
||||
this.append(artist, 0, 2, 1, 1)
|
||||
this.append(song, 1, 2, 1, 1)
|
||||
this.append(album, 2, 2, 1, 1)
|
||||
|
||||
this._uncyclic.push(this._infoModels.artist.destructor.bind(this._infoModels.artist));
|
||||
this._uncyclic.push(this._infoModels.song.destructor.bind(this._infoModels.song));
|
||||
this._uncyclic.push(this._infoModels.album.destructor.bind(this._infoModels.album));
|
||||
},
|
||||
destructor: function() {
|
||||
this._f.off("newElement", this._onNewElement, this);
|
||||
this._clearCpbCtrl();
|
||||
|
||||
GridLayout.fn.destructor.call(this);
|
||||
},
|
||||
_clearCpbCtrl: function() {
|
||||
if (this._cpbCtrl !== null) {
|
||||
this._cpbCtrl.off("newElement", this._onCpbNewElement, this);
|
||||
this._cpbCtrl.off("removeElement", this._onCpbRemoveElement, this);
|
||||
this._cpbCtrl = null;
|
||||
}
|
||||
},
|
||||
_onNewElement: function(ctrl, type) {
|
||||
var ItemType = Enum.storage["ItemType"];
|
||||
|
||||
switch (type) {
|
||||
case ItemType.straight.playPause:
|
||||
this._playPause = new Button(ctrl);
|
||||
this.append(this._playPause, 0, 1, 3, 1);
|
||||
break;
|
||||
case ItemType.straight.queue:
|
||||
break;
|
||||
case ItemType.straight.currentPlayback:
|
||||
this._clearCpbCtrl();
|
||||
this._cpbCtrl = ctrl;
|
||||
this._cpbCtrl.on("newElement", this._onCpbNewElement, this);
|
||||
this._cpbCtrl.on("removeElement", this._onCpbRemoveElement, this);
|
||||
break;
|
||||
}
|
||||
},
|
||||
_onCpbNewElement: function(key, value) {
|
||||
var model = this._infoModels[key];
|
||||
|
||||
if (model) {
|
||||
model.setData(key + ": " + value.toString());
|
||||
}
|
||||
},
|
||||
_onCpbRemoveElement: function(key) {
|
||||
var model = this._infoModels[key];
|
||||
|
||||
if (model) {
|
||||
model.setData(key + ": unknown");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Player;
|
||||
});
|
||||
})()
|
|
@ -54,7 +54,9 @@
|
|||
for (var i = 0; i < this._f._controllers.length; ++i) {
|
||||
this._onNewController(this._f._controllers[i]);
|
||||
}
|
||||
this._onData(this._f);
|
||||
//if (this._f.initialized) {
|
||||
this._onData(this._f);
|
||||
//}
|
||||
|
||||
View.collection[this._id] = this;
|
||||
this._applyProperties();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue