mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-10 22:54:37 +02:00
* Bunch of WIP on new setPropertyValue() stuff making it easier to set props from JSON
This commit is contained in:
parent
8a5f890bee
commit
658c64c8c8
8 changed files with 202 additions and 45 deletions
|
@ -23,7 +23,7 @@ function VerticalMenuView(options) {
|
|||
this.performAutoScale = function() {
|
||||
if(this.autoScale.height) {
|
||||
this.dimens.height = (self.items.length * (self.itemSpacing + 1)) - (self.itemSpacing);
|
||||
this.dimens.height = Math.min(this.dimens.height, self.client.term.termHeight - self.position.row);
|
||||
this.dimens.height = Math.min(self.dimens.height, self.client.term.termHeight - self.position.row);
|
||||
}
|
||||
|
||||
if(this.autoScale.width) {
|
||||
|
@ -39,6 +39,15 @@ function VerticalMenuView(options) {
|
|||
|
||||
this.performAutoScale();
|
||||
|
||||
this.updateViewVisibleItems = function() {
|
||||
self.maxVisibleItems = Math.ceil(self.dimens.height / (self.itemSpacing + 1));
|
||||
|
||||
self.viewWindow = {
|
||||
top : self.focusedItemIndex,
|
||||
bottom : Math.min(self.focusedItemIndex + self.maxVisibleItems, self.items.length) - 1
|
||||
};
|
||||
};
|
||||
|
||||
this.drawItem = function(index) {
|
||||
var item = self.items[index];
|
||||
if(!item) {
|
||||
|
@ -60,6 +69,13 @@ util.inherits(VerticalMenuView, MenuView);
|
|||
VerticalMenuView.prototype.redraw = function() {
|
||||
VerticalMenuView.super_.prototype.redraw.call(this);
|
||||
|
||||
if(this.positionCacheExpired) {
|
||||
this.performAutoScale();
|
||||
this.updateViewVisibleItems();
|
||||
|
||||
this.positionCacheExpired = false;
|
||||
}
|
||||
|
||||
var row = this.position.row;
|
||||
for(var i = this.viewWindow.top; i <= this.viewWindow.bottom; ++i) {
|
||||
this.items[i].row = row;
|
||||
|
@ -69,6 +85,12 @@ VerticalMenuView.prototype.redraw = function() {
|
|||
}
|
||||
};
|
||||
|
||||
VerticalMenuView.prototype.setHeight = function(height) {
|
||||
VerticalMenuView.super_.prototype.setHeight.call(this, height);
|
||||
|
||||
this.positionCacheExpired = true;
|
||||
};
|
||||
|
||||
VerticalMenuView.prototype.setPosition = function(pos) {
|
||||
VerticalMenuView.super_.prototype.setPosition.call(this, pos);
|
||||
|
||||
|
@ -135,12 +157,11 @@ VerticalMenuView.prototype.getData = function() {
|
|||
VerticalMenuView.prototype.setItems = function(items) {
|
||||
VerticalMenuView.super_.prototype.setItems.call(this, items);
|
||||
|
||||
this.performAutoScale();
|
||||
this.positionCacheExpired = true;
|
||||
};
|
||||
|
||||
this.maxVisibleItems = Math.ceil(this.dimens.height / (this.itemSpacing + 1));
|
||||
VerticalMenuView.prototype.setItemSpacing = function(itemSpacing) {
|
||||
VerticalMenuView.super_.prototype.setItemSpacing.call(this, itemSpacing);
|
||||
|
||||
this.viewWindow = {
|
||||
top : this.focusedItemIndex,
|
||||
bottom : Math.min(this.focusedItemIndex + this.maxVisibleItems, this.items.length) - 1
|
||||
};
|
||||
this.positionCacheExpired = true;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue