class VisibilitySimpleControllerBase extends inkLogicController
{
	const editable var affectedWidgets : array< CName >;
	private var m_isVisible : Bool;
	private var m_widget : weak< inkWidget >;

	protected event OnInitialize()
	{
		m_widget = GetRootWidget();
		m_widget.RegisterToCallback( 'OnHoverOver', this, 'OnHoverOver' );
		m_widget.RegisterToCallback( 'OnHoverOut', this, 'OnHoverOut' );
	}

	protected event OnUninitialize() {}

	protected event OnHoverOver( e : inkPointerEvent )
	{
		if( !( m_isVisible ) && ( e.GetCurrentTarget() == m_widget ) )
		{
			Show();
			m_isVisible = true;
		}
	}

	protected event OnHoverOut( e : inkPointerEvent )
	{
		if( m_isVisible && ( e.GetCurrentTarget() == m_widget ) )
		{
			Hide();
			m_isVisible = false;
		}
	}

	protected function Hide()
	{
		var i : Int32;
		var widget : inkWidget;
		for( i = 0; i < affectedWidgets.Size(); i += 1 )
		{
			widget = GetWidget( affectedWidgets[ i ] );
			if( widget != NULL )
			{
				widget.SetVisible( false );
			}
		}
	}

	protected function Show()
	{
		var i : Int32;
		var widget : inkWidget;
		for( i = 0; i < affectedWidgets.Size(); i += 1 )
		{
			widget = GetWidget( affectedWidgets[ i ] );
			if( widget != NULL )
			{
				widget.SetVisible( true );
			}
		}
	}

}

