src/widgets.js
function() {
        this.comps.base.add(this.comps.background);
        this.comps.base.add(this.comps.label);
        
        var self = this;
        this.setFill(amino.colortheme.button.fill.normal);
        amino.getCore().on('press', this, function(e) {
            self.setFill(amino.colortheme.button.fill.pressed);
        });
        amino.getCore().on("release",this,function(e) {
            self.setFill(amino.colortheme.button.fill.normal);
        });
        amino.getCore().on("click",this,function(e) {
            var event = {type:'action',source:self};
            amino.getCore().fireEvent(event);
            if(self.actioncb) self.actioncb(event);
        });
        this.setFontSize(15);
        /** @func onAction(cb) a function to call when this button fires an action. You can also listen for the 'action' event. */
        this.onAction = function(cb) {
            this.actioncb = cb;
            return this;
        }
        this.markDirty = function() {
            this.dirty = true;
            amino.dirtylist.push(this);
        }
        this.doLayout = function() {
            var textw = this.comps.label.font.calcStringWidth(this.getText(),this.getFontSize(),this.getFontWeight(),this.getFontStyle());
            this.comps.label.setTx(Math.round((this.getW()-textw)/2));
            var texth = this.comps.label.font.getHeight(this.getFontSize(),this.getFontWeight(),this.getFontStyle());
            this.comps.label.setTy(Math.round(this.getH()/2 + texth/2));
        }
        this.validate = function() {
            this.doLayout();
            this.dirty = false;
        }
    }
function() {
        this.comps.base.add(this.comps.background);
        this.comps.base.add(this.comps.label);
        
        var self = this;
        this.setFill(amino.colortheme.button.fill.normal);
        amino.getCore().on('press', this, function(e) {
            self.setFill(amino.colortheme.button.fill.pressed);
        });
        amino.getCore().on("release",this,function(e) {
            self.setFill(amino.colortheme.button.fill.normal);
        });
        amino.getCore().on("click",this,function(e) {
            var event = {type:'action',source:self};
            amino.getCore().fireEvent(event);
            if(self.actioncb) self.actioncb(event);
        });
        this.setFontSize(15);
        /** @func onAction(cb) a function to call when this button fires an action. You can also listen for the 'action' event. */
        this.onAction = function(cb) {
            this.actioncb = cb;
            return this;
        }
        this.markDirty = function() {
            this.dirty = true;
            amino.dirtylist.push(this);
        }
        this.doLayout = function() {
            var textw = this.comps.label.font.calcStringWidth(this.getText(),this.getFontSize(),this.getFontWeight(),this.getFontStyle());
            this.comps.label.setTx(Math.round((this.getW()-textw)/2));
            var texth = this.comps.label.font.getHeight(this.getFontSize(),this.getFontWeight(),this.getFontStyle());
            this.comps.label.setTy(Math.round(this.getH()/2 + texth/2));
        }
        this.validate = function() {
            this.doLayout();
            this.dirty = false;
        }
    }
function ( ) { this . comps . base . add ( this . comps . background ) ; this . comps . base . add ( this . comps . label ) ; var self = this ; this . setFill ( amino . colortheme . button . fill . normal ) ; amino . getCore ( ) . on ( 'press' , this , function ( e ) { self . setFill ( amino . colortheme . button . fill . pressed ) ; } ) ; amino . getCore ( ) . on ( "release" , this , function ( e ) { self . setFill ( amino . colortheme . button . fill . normal ) ; } ) ; amino . getCore ( ) . on ( "click" , this , function ( e ) { var event = { type : 'action' , source : self } ; amino . getCore ( ) . fireEvent ( event ) ; if ( self . actioncb ) self . actioncb ( event ) ; } ) ; this . setFontSize ( 15 ) ; /** @func onAction(cb) a function to call when this button fires an action. You can also listen for the 'action' event. */ this . onAction = function ( cb ) { this . actioncb = cb ; return this ; } this . markDirty = function ( ) { this . dirty = true ; amino . dirtylist . push ( this ) ; } this . doLayout = function ( ) { var textw = this . comps . label . font . calcStringWidth ( this . getText ( ) , this . getFontSize ( ) , this . getFontWeight ( ) , this . getFontStyle ( ) ) ; this . comps . label . setTx ( Math . round ( ( this . getW ( ) - textw ) / 2 ) ) ; var texth = this . comps . label . font . getHeight ( this . getFontSize ( ) , this . getFontWeight ( ) , this . getFontStyle ( ) ) ; this . comps . label . setTy ( Math . round ( this . getH ( ) / 2 + texth / 2 ) ) ; } this . validate = function ( ) { this . doLayout ( ) ; this . dirty = false ; } }
replaces all setters
replaces all setters