starling-framework
Version:
A fast, productive library for 2D cross-platform development.
134 lines (117 loc) • 3.48 kB
JavaScript
// Class: starling.utils.Padding
var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this
$global.Object.defineProperty(exports, "__esModule", {value: true});
var __map_reserved = {};
// Imports
var $hxClasses = require("./../../hxClasses_stub").default;
var $hxEnums = require("./../../hxEnums_stub").default;
var $import = require("./../../import_stub").default;
var $extend = require("./../../extend_stub").default;
function starling_events_EventDispatcher() {return require("./../../starling/events/EventDispatcher");}
// Constructor
var Padding = function(left,right,top,bottom) {
if(bottom == null) {
bottom = 0;
}
if(top == null) {
top = 0;
}
if(right == null) {
right = 0;
}
if(left == null) {
left = 0;
}
(starling_events_EventDispatcher().default).call(this);
this.setTo(left,right,top,bottom);
}
// Meta
Padding.__name__ = "starling.utils.Padding";
Padding.__isInterface__ = false;
Padding.__super__ = (starling_events_EventDispatcher().default);
Padding.prototype = $extend((starling_events_EventDispatcher().default).prototype, {
setTo: function(left,right,top,bottom) {
if(bottom == null) {
bottom = 0;
}
if(top == null) {
top = 0;
}
if(right == null) {
right = 0;
}
if(left == null) {
left = 0;
}
var changed = this._left != left || this._right != right || this._top != top || this._bottom != bottom;
this._left = left;
this._right = right;
this._top = top;
this._bottom = bottom;
if(changed) {
this.dispatchEventWith("change");
}
},
setToUniform: function(value) {
this.setTo(value,value,value,value);
},
setToSymmetric: function(horizontal,vertical) {
this.setTo(horizontal,horizontal,vertical,vertical);
},
copyFrom: function(padding) {
if(padding == null) {
this.setTo(0,0,0,0);
} else {
this.setTo(padding._left,padding._right,padding._top,padding._bottom);
}
},
clone: function() {
return new Padding(this._left,this._right,this._top,this._bottom);
},
get_left: function() {
return this._left;
},
set_left: function(value) {
if(this._left != value) {
this._left = value;
this.dispatchEventWith("change");
}
return value;
},
get_right: function() {
return this._right;
},
set_right: function(value) {
if(this._right != value) {
this._right = value;
this.dispatchEventWith("change");
}
return value;
},
get_top: function() {
return this._top;
},
set_top: function(value) {
if(this._top != value) {
this._top = value;
this.dispatchEventWith("change");
}
return value;
},
get_bottom: function() {
return this._bottom;
},
set_bottom: function(value) {
if(this._bottom != value) {
this._bottom = value;
this.dispatchEventWith("change");
}
return value;
}
});
Padding.prototype.__class__ = Padding.prototype.constructor = $hxClasses["starling.utils.Padding"] = Padding;
// Init
Object.defineProperties(Padding.prototype,{ left : { get : function () { return this.get_left (); }, set : function (v) { return this.set_left (v); }}, right : { get : function () { return this.get_right (); }, set : function (v) { return this.set_right (v); }}, top : { get : function () { return this.get_top (); }, set : function (v) { return this.set_top (v); }}, bottom : { get : function () { return this.get_bottom (); }, set : function (v) { return this.set_bottom (v); }}});
// Statics
// Export
exports.default = Padding;