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

@ -12,5 +12,6 @@ configure_file(page.js page.js)
configure_file(pane.js pane.js)
configure_file(image.js image.js)
configure_file(button.js button.js)
configure_file(enumeration.js enumeration.js)
add_subdirectory(helpers)

View file

@ -0,0 +1,53 @@
"use strict";
(function view_enumeration_js() {
var moduleName = "views/enumeration";
var deps = [];
deps.push("views/gridLayout");
deps.push("views/label");
deps.push("lib/wController/localModel");
define(moduleName, deps, function view_enumeration_module() {
var GridLayout = require("views/gridLayout");
var Label = require("views/label");
var LocalModel = require("lib/wController/localModel");
var Enumeration = GridLayout.inherit({
className: "Enumeration",
constructor: function(controller, options) {
var base = {};
W.extend(base, options)
this._lm = new LocalModel();
GridLayout.fn.constructor.call(this, controller, base);
this._lv = new Label(this._lm);
this.append(this._lv, 0, 0, 1, 1, GridLayout.Aligment.CenterCenter);
this._uncyclic.push(this._lm.destructor.bind(this._lm));
},
_onData: function() {
if (this._f.initialized) {
var e = this._f.enum;
var value = this._f.data;
var title;
if (e.hasAdditional("title")) {
title = e.additional[value].title;
} else {
title = e.reversed[value];
}
var desc = "";
if (e.hasAdditional("description")) {
desc = e.additional[value].description;
}
this._lm.setData(title);
this._e.setAttribute("title", desc);
}
}
});
return Enumeration;
})
})();

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));
}
});

View file

@ -290,6 +290,7 @@
Image: 4,
Button: 5,
View: 6,
Enumeration: 7,
Page: 102,
PanesList: 104,
@ -302,6 +303,7 @@
"4": "Image",
"5": "Button",
"6": "View",
"7": "Enumeration",
"101": "Nav",
"102": "Page",
@ -317,7 +319,8 @@
PanesList: "views/panesList",
Image: "views/image",
Button: "views/button",
Player: "views/player"
Player: "views/player",
Enumeration: "views/enumeration"
};
View.constructors = {