* Start work on allowing pipe codes & custom drawing using items vs focusItems for menus. EXPERIMENTAL.

This commit is contained in:
Bryan Ashby 2015-08-25 23:17:09 -06:00
parent 64c8d83559
commit 9442760679
10 changed files with 171 additions and 20 deletions

View file

@ -40,6 +40,10 @@ function MenuView(options) {
this.fillChar = miscUtil.valueWithDefault(options.fillChar, ' ').substr(0, 1);
this.justify = options.justify || 'none';
this.hasFocusItems = function() {
return !_.isUndefined(self.focusItems);
};
}
util.inherits(MenuView, View);
@ -48,14 +52,23 @@ MenuView.prototype.setItems = function(items) {
var self = this;
if(items) {
this.items = []; // :TODO: better way?
items.forEach(function onItem(itemText) {
self.items.push({
text : itemText
});
items.forEach(function item(itemText) {
self.items.push( { text : itemText } );
});
}
};
MenuView.prototype.setFocusItems = function(items) {
var self = this;
if(items) {
this.focusItems = [];
items.forEach(function item(itemText) {
self.focusItems.push( { text : itemText } );
});
}
}
MenuView.prototype.setItemSpacing = function(itemSpacing) {
itemSpacing = parseInt(itemSpacing);
assert(_.isNumber(itemSpacing));
@ -68,6 +81,7 @@ MenuView.prototype.setPropertyValue = function(propName, value) {
switch(propName) {
case 'itemSpacing' : this.setItemSpacing(value); break;
case 'items' : this.setItems(value); break;
case 'focusItems' : this.setFocusItems(value); break;
case 'hotKeys' : this.setHotKeys(value); break;
}