123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
"use strict";
modulum('GridLayoutInformation', ['EventListener'],
function(context, cls) {
cls.GridLayoutInformation = context.oo.Class(cls.EventListener, function($super) {
return {
__name: "GridLayoutInformation",
_useVirtual: false,
_gridX: null,
_gridY: null,
_gridWidth: null,
_gridHeight: null,
_virtualGridX: null,
_virtualGridY: null,
_virtualGridWidth: null,
_virtualGridHeight: null,
constructor: function() {
$super.constructor.call(this);
this.reset();
},
reset: function() {
this._gridX = 0;
this._gridY = 0;
this._gridWidth = 1;
this._gridHeight = 1;
this._virtualGridX = 0;
this._virtualGridY = 0;
this._virtualGridWidth = 1;
this._virtualGridHeight = 1;
},
isUsingVirtualCoordinates: function() {
return Boolean(this._useVirtual);
},
useVirtualCoordinates: function(useVirtual) {
useVirtual = Boolean(useVirtual);
if (this._useVirtual !== useVirtual) {
this._useVirtual = useVirtual;
this.invalidateInfos();
}
},
getX: function() {
return this._useVirtual ? this._virtualGridX : this._gridX;
},
getY: function() {
return this._useVirtual ? this._virtualGridY : this._gridY;
},
getWidth: function() {
return this._useVirtual ? this._virtualGridWidth : this._gridWidth;
},
getHeight: function() {
return this._useVirtual ? this._virtualGridHeight : this._gridHeight;
},
getGridX: function() {
return this._gridX;
},
setGridX: function(gridX) {
if (this._gridX !== gridX) {
this._gridX = gridX;
this.invalidateInfos();
}
},
getGridY: function() {
return this._gridY;
},
setGridY: function(gridY) {
if (this._gridY !== gridY) {
this._gridY = gridY;
this.invalidateInfos();
}
},
getGridWidth: function() {
return this._gridWidth;
},
setGridWidth: function(gridWidth) {
if (this._gridWidth !== gridWidth) {
this._gridWidth = gridWidth;
this.invalidateInfos();
}
},
getGridHeight: function() {
return this._gridHeight;
},
setGridHeight: function(gridHeight) {
if (this._gridHeight !== gridHeight) {
this._gridHeight = gridHeight;
this.invalidateInfos();
}
},
getVirtualGridX: function() {
return this._virtualGridX;
},
setVirtualGridX: function(gridX) {
if (this._virtualGridX !== gridX) {
this._virtualGridX = gridX;
this.invalidateInfos();
}
},
getVirtualGridY: function() {
return this._virtualGridY;
},
setVirtualGridY: function(gridY) {
if (this._virtualGridY !== gridY) {
this._virtualGridY = gridY;
this.invalidateInfos();
}
},
getVirtualGridWidth: function() {
return this._virtualGridWidth;
},
setVirtualGridWidth: function(gridWidth) {
if (this._virtualGridWidth !== gridWidth) {
this._virtualGridWidth = gridWidth;
this.invalidateInfos();
}
},
getVirtualGridHeight: function() {
return this._virtualGridHeight;
},
setVirtualGridHeight: function(gridHeight) {
if (this._virtualGridHeight !== gridHeight) {
this._virtualGridHeight = gridHeight;
this.invalidateInfos();
}
},
onGridLayoutInformationChanged: function(hook) {
return this.when(context.constants.widgetEvents.layoutInformationChanged, hook);
},
invalidateInfos: function() {
this.emit(context.constants.widgetEvents.layoutInformationChanged);
}
};
});
});