a new oblect utils - enum, enum view, refactoring of mainLayout, debugging, states for sockets

This commit is contained in:
blue 2018-08-29 22:54:18 +03:00
parent b5ea024faf
commit f4529f0023
14 changed files with 260 additions and 57 deletions

View file

@ -5,19 +5,43 @@
var defineArray = [];
defineArray.push("views/gridLayout");
defineArray.push("views/label");
defineArray.push("views/view");
defineArray.push("views/navigationPanel");
defineArray.push("views/layout");
defineArray.push("views/enumeration");
defineArray.push("lib/wController/localModel");
define(moduleName, defineArray, function mainLayout_module() {
var GridLayout = require("views/gridLayout");
var ViewLabel = require("views/label");
var View = require("views/view");
var ViewNavigationPanel = require("views/navigationPanel");
var Layout = require("views/layout");
var Enumeration = require("views/enumeration");
var LocalModel = require("lib/wController/localModel");
var MainLayout = GridLayout.inherit({
"className": "MainLayout",
"constructor": function(controller, options) {
GridLayout.fn.constructor.call(this, controller, options);
this._statusBarPosition = 2;
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);
},
"_onNewController": function(controller) {
GridLayout.fn._onNewController.call(this, controller);
@ -25,13 +49,8 @@
switch (controller.name) {
case "version":
var lm = new LocalModel({
backgroundColor: "secondaryColor"
});
var lay = new Layout(lm, {maxHeight: 15})
view = new ViewLabel(controller);
lay.append(view, Layout.Aligment.RightCenter);
this.append(lay, 2, 0, 1, 3);
this._statusBar.append(view, 0, 0, 1, 1, Layout.Aligment.LeftCenter);
break;
case "navigationPanel":
view = new ViewNavigationPanel(controller);
@ -43,6 +62,16 @@
//this.trigger("serviceMessage", "Unsupported view: " + name + " (" + type + ")", 1);
break;
}
},
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));
}
});