class GenericButtonController extends inkLogicController
{
	private editable var m_label : inkTextRef;
	private editable var m_frameHovered : inkWidgetRef;
	private var m_itemHovered : Bool;
	private var m_enabled : Bool;

	protected event OnInitialize()
	{
		RegisterToCallback( 'OnRelease', this, 'OnButtonRelease' );
		RegisterToCallback( 'OnHoverOver', this, 'OnButtonHoverOver' );
		RegisterToCallback( 'OnHoverOut', this, 'OnButtonHoverOut' );
		inkWidgetRef.SetOpacity( m_frameHovered, 0.0 );
	}

	protected event OnUninitialize()
	{
		UnregisterFromCallback( 'OnRelease', this, 'OnButtonRelease' );
		UnregisterFromCallback( 'OnHoverOver', this, 'OnButtonHoverOver' );
		UnregisterFromCallback( 'OnHoverOut', this, 'OnButtonHoverOut' );
	}

	public function Init( const label : ref< String > )
	{
		inkTextRef.SetText( m_label, label );
		ApplyEnabledLayout( m_label, GetRootWidget() );
	}

	public static function ApplyDisabledLayout( label : inkTextRef, root : inkWidget )
	{
		inkTextRef.SetText( label, "LocKey#20482" );
		inkTextRef.Get( label ).BindProperty( 'tintColor', 'MainColors.MildRed' );
		inkTextRef.SetOpacity( label, 0.80000001 );
	}

	public static function ApplyEnabledLayout( label : inkTextRef, root : inkWidget )
	{
		inkTextRef.Get( label ).BindProperty( 'tintColor', 'MainColors.Blue' );
		inkTextRef.SetOpacity( label, 1.0 );
	}

	public function UpdateButton( const label : ref< String > )
	{
		inkTextRef.SetText( m_label, label );
	}

	protected event OnButtonRelease( e : inkPointerEvent )
	{
		if( e.IsAction( 'click' ) )
		{
		}
	}

	protected event OnButtonHoverOver( evt : inkPointerEvent )
	{
		if( !( m_enabled ) )
		{
			inkWidgetRef.SetOpacity( m_frameHovered, 1.0 );
			m_itemHovered = true;
		}
	}

	protected event OnButtonHoverOut( evt : inkPointerEvent )
	{
		if( !( m_enabled ) )
		{
			inkWidgetRef.SetOpacity( m_frameHovered, 0.0 );
			m_itemHovered = false;
		}
	}

}

