@pilotlab/lux-types
Version:
A luxurious user experience framework, developed by your friends at Pilot.
45 lines (29 loc) • 1.74 kB
text/typescript
import is from '@pilotlab/lux-is';
import { DataType, Attribute, IAttribute, AttributeCollection, AttributeChangeOptions, IAttributeChangeOptions } from '@pilotlab/lux-attributes';
import ISize from './interfaces/iSize';
export class Size extends Attribute<Size>
implements ISize {
constructor(width?:number, height?:number, depth?:number) {
super('Size', null, DataType.COLLECTION, null, true);
this.p_width = this.children.set('width', is.notEmpty(width) ? width : 0, DataType.NUMBER_DOUBLE, AttributeChangeOptions.zero).node;
this.p_height = this.children.set('height', is.notEmpty(height) ? height : 0, DataType.NUMBER_DOUBLE, AttributeChangeOptions.zero).node;
this.p_depth = this.children.set('depth', is.notEmpty(depth) ? depth : 0, DataType.NUMBER_DOUBLE, <IAttributeChangeOptions>AttributeChangeOptions.zero).node;
}
get copy():Size { return new Size(this.width, this.height, this.depth); }
get width():number { return this.p_width.value; }
set width(value:number) { this.p_width.set(value, AttributeChangeOptions.saveAndSignal.durationZero); }
protected p_width:IAttribute;
get height():number { return this.p_height.value; }
set height(value:number) { this.p_height.set(value, AttributeChangeOptions.saveAndSignal.durationZero); }
protected p_height:IAttribute;
get depth():number { return this.p_depth.value; }
set depth(value:number) { this.p_depth.set(value, AttributeChangeOptions.saveAndSignal.durationZero); }
protected p_depth:IAttribute;
static get empty():Size {
let size:Size = new Size();
size.width = null;
size.height = null;
return size;
}
} // End of class
export default Size;