2018-08-04 21:46:25 +00:00
|
|
|
"use strict";
|
|
|
|
(function mainLayout_js() {
|
|
|
|
var moduleName = "views/mainLayout";
|
|
|
|
|
|
|
|
var defineArray = [];
|
|
|
|
defineArray.push("views/gridLayout");
|
|
|
|
defineArray.push("views/label");
|
2018-08-29 19:54:18 +00:00
|
|
|
defineArray.push("views/view");
|
2018-08-04 21:46:25 +00:00
|
|
|
defineArray.push("views/navigationPanel");
|
|
|
|
defineArray.push("views/layout");
|
2018-08-29 19:54:18 +00:00
|
|
|
defineArray.push("views/enumeration");
|
2018-10-28 21:32:44 +00:00
|
|
|
defineArray.push("views/player");
|
2018-08-04 21:46:25 +00:00
|
|
|
defineArray.push("lib/wController/localModel");
|
|
|
|
|
|
|
|
define(moduleName, defineArray, function mainLayout_module() {
|
|
|
|
var GridLayout = require("views/gridLayout");
|
|
|
|
var ViewLabel = require("views/label");
|
2018-08-29 19:54:18 +00:00
|
|
|
var View = require("views/view");
|
2018-08-04 21:46:25 +00:00
|
|
|
var ViewNavigationPanel = require("views/navigationPanel");
|
|
|
|
var Layout = require("views/layout");
|
2018-08-29 19:54:18 +00:00
|
|
|
var Enumeration = require("views/enumeration");
|
2018-10-28 21:32:44 +00:00
|
|
|
var Player = require("views/player");
|
2018-08-04 21:46:25 +00:00
|
|
|
var LocalModel = require("lib/wController/localModel");
|
|
|
|
|
|
|
|
var MainLayout = GridLayout.inherit({
|
|
|
|
"className": "MainLayout",
|
2018-08-29 19:54:18 +00:00
|
|
|
"constructor": function(controller, options) {
|
|
|
|
GridLayout.fn.constructor.call(this, controller, options);
|
|
|
|
|
|
|
|
this._statusBarPosition = 2;
|
2018-10-28 21:32:44 +00:00
|
|
|
this._player = undefined;
|
2018-08-29 19:54:18 +00:00
|
|
|
|
|
|
|
this._mainColorHelper = new LocalModel({backgroundColor: "mainColor"});
|
|
|
|
this._statusBarModel = new LocalModel({backgroundColor: "secondaryColor"});
|
|
|
|
|
|
|
|
this._uncyclic.push(this._statusBarModel.destructor.bind(this._statusBarModel));
|
|
|
|
this._uncyclic.push(this._mainColorHelper.destructor.bind(this._mainColorHelper));
|
|
|
|
|
|
|
|
var spacerL = new View(this._mainColorHelper, {maxWidth: 50});
|
|
|
|
var spacerR = new View(this._mainColorHelper, {maxWidth: 50});
|
|
|
|
this.append(spacerL, 1, 0, 1, 1);
|
|
|
|
this.append(spacerR, 1, 2, 1, 1);
|
|
|
|
|
|
|
|
this._statusBar = new GridLayout(this._statusBarModel);
|
|
|
|
this._statusBar.append(new View(this._statusBarModel), 0, 1, 1, 1);
|
|
|
|
this.append(this._statusBar, 3, 0, 1, 3);
|
|
|
|
},
|
2018-08-04 21:46:25 +00:00
|
|
|
"_onNewController": function(controller) {
|
|
|
|
GridLayout.fn._onNewController.call(this, controller);
|
|
|
|
|
|
|
|
var view;
|
|
|
|
|
|
|
|
switch (controller.name) {
|
|
|
|
case "version":
|
|
|
|
view = new ViewLabel(controller);
|
2018-08-29 19:54:18 +00:00
|
|
|
this._statusBar.append(view, 0, 0, 1, 1, Layout.Aligment.LeftCenter);
|
2018-08-04 21:46:25 +00:00
|
|
|
break;
|
|
|
|
case "navigationPanel":
|
|
|
|
view = new ViewNavigationPanel(controller);
|
|
|
|
this.append(view, 0, 0, 1, 3);
|
|
|
|
break;
|
|
|
|
case "themes":
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//this.trigger("serviceMessage", "Unsupported view: " + name + " (" + type + ")", 1);
|
|
|
|
break;
|
|
|
|
}
|
2018-08-29 19:54:18 +00:00
|
|
|
},
|
|
|
|
addState: function(name, state) {
|
|
|
|
var lm = new LocalModel({fontFamily: "casualFont"});
|
|
|
|
lm.setData(name + ": ");
|
|
|
|
var lv = new ViewLabel(lm);
|
|
|
|
var e = new Enumeration(state);
|
|
|
|
this._statusBar.append(lv, 0, this._statusBarPosition++, 1, 1, Layout.Aligment.LeftCenter);
|
|
|
|
this._statusBar.append(e, 0, this._statusBarPosition++, 1, 1, Layout.Aligment.LeftCenter);
|
|
|
|
|
|
|
|
this._uncyclic.push(lm.destructor.bind(lm));
|
2018-10-28 21:32:44 +00:00
|
|
|
},
|
|
|
|
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;
|
2018-08-04 21:46:25 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return MainLayout;
|
|
|
|
});
|
|
|
|
})();
|