define(["Ti/_/declare","Ti/_/UI/Widget","Ti/_/dom","Ti/_/css","Ti/_/style","Ti/_/lang","Ti/Locale","Ti/UI"],function(t,o,e,i,r,s,d,n){var a=require.on,l=r.set,h={post:function(){this.backgroundColor||this.backgroundDisabledColor||this.backgroundDisabledImage||this.backgroundFocusedColor||this.backgroundFocusedImage||this.backgroundImage||this.backgroundSelectedColor||this.backgroundSelectedImage?this._clearDefaultLook():this._setDefaultLook(),this._doBackground()}},u={post:function(){this._buttonTitle.text=d._getString(this.titleid,this.title),this._hasSizeDimensions()&&this._triggerLayout()}};return t("Ti.UI.Button",o,{constructor:function(){var t=this._contentContainer=n.createView({width:n.INHERIT,height:n.INHERIT,layout:n._LAYOUT_CONSTRAINING_HORIZONTAL,borderColor:"transparent"}),o=this.domNode;this._add(t),t._add(this._buttonImage=n.createImageView()),t._add(this._buttonTitle=n.createLabel({textAlign:n.TEXT_ALIGNMENT_CENTER,verticalAlign:n.TEXT_VERTICAL_ALIGNMENT_CENTER,width:n.INHERIT,height:n.INHERIT})),this._setDefaultLook(),a(this,"touchstart",this,function(){this._hasDefaultLook?(i.remove(o,"TiUIElementGradient"),i.add(o,"TiUIElementGradientActive")):(this.selectedColor&&(this._buttonTitle.color=this.selectedColor),this.backgroundSelectedColor&&l(this.domNode,"backgroundColor",this.backgroundSelectedColor))}),a(this,"touchend",this,function(){this._hasDefaultLook?(i.remove(o,"TiUIElementGradientActive"),i.add(o,"TiUIElementGradient")):(this.selectedColor&&(this._buttonTitle.color=this.color||"#000"),this.backgroundSelectedColor&&l(this.domNode,"backgroundColor",this.backgroundColor))}),a(o,"mouseout",this,function(){this.selectedColor&&(this._buttonTitle.color=this.color||"#000")})},_defaultWidth:n.SIZE,_defaultHeight:n.SIZE,_setDefaultLook:function(){this._hasDefaultLook||(this._hasDefaultLook=!0,this._previousBorderWidth=this.borderWidth,this._previousBorderColor=this.borderColor,i.add(this.domNode,"TiUIElementGradient"),i.add(this.domNode,"TiUIButtonDefault"),this._contentContainer.borderWidth=6,this._getBorderFromCSS())},_clearDefaultLook:function(){this._hasDefaultLook&&(this._hasDefaultLook=!1,this.borderWidth=this._previousBorderWidth,this.borderColor=this._previousBorderColor,i.remove(this.domNode,"TiUIElementGradient"),i.remove(this.domNode,"TiUIButtonDefault"),this._contentContainer.borderWidth=0)},properties:{backgroundColor:h,backgroundDisabledColor:h,backgroundDisabledImage:h,backgroundFocusedColor:h,backgroundFocusedImage:h,backgroundImage:h,backgroundSelectedColor:h,backgroundSelectedImage:h,enabled:{set:function(t,o){return t!==o&&(this._hasDefaultLook&&(t?(i.add(this.domNode,"TiUIElementGradient"),l(this.domNode,"backgroundColor","")):(i.remove(this.domNode,"TiUIElementGradient"),l(this.domNode,"backgroundColor","#aaa"))),this._setTouchEnabled(t)),t},value:!0},image:{set:function(t){return this._buttonImage.image=t,t}},shadowColor:{post:function(t){this._buttonTitle.shadowColor=t}},shadowOffset:{post:function(t){this._buttonTitle.shadowOffset=t}},shadowRadius:{post:function(t){this._buttonTitle.shadowRadius=t}},selectedColor:void 0,textAlign:{set:function(t){return this._buttonTitle.textAlign=t}},title:u,titleid:u,verticalAlign:{set:function(t){return this._buttonTitle.verticalAlign=t}}}})});