class DropdownElementController extends BaseButtonView
{
	protected editable var m_text : inkTextRef;
	protected editable var m_arrow : inkImageRef;
	protected editable var m_frame : inkWidgetRef;
	protected editable var m_contentContainer : inkWidgetRef;
	protected var m_data : DropdownItemData;
	protected var m_active : Bool;

	protected event OnInitialize()
	{
		inkWidgetRef.RegisterToCallback( m_contentContainer, 'OnHoverOver', this, 'OnHoverOver' );
		inkWidgetRef.RegisterToCallback( m_contentContainer, 'OnHoverOut', this, 'OnHoverOut' );
	}

	public function Setup( data : DropdownItemData )
	{
		m_data = data;
		inkTextRef.SetText( m_text, GetLocalizedText( NameToString( data.labelKey ) ) );
		if( data.direction == DropdownItemDirection.None )
		{
			inkImageRef.SetVisible( m_arrow, false );
		}
		else if( data.direction == DropdownItemDirection.Up )
		{
			inkImageRef.SetVisible( m_arrow, true );
			inkImageRef.SetBrushMirrorType( m_arrow, inkBrushMirrorType.Vertical );
		}
		else
		{
			inkImageRef.SetVisible( m_arrow, true );
			inkImageRef.SetBrushMirrorType( m_arrow, inkBrushMirrorType.NoMirror );
		}
	}

	public function GetIdentifier() : Variant
	{
		return m_data.identifier;
	}

	public function SetHighlighted( highlighted : Bool )
	{
		inkWidgetRef.SetState( m_frame, ( ( highlighted ) ? ( 'Hover' ) : ( 'Default' ) ) );
		if( !( m_active ) )
		{
			GetRootWidget().SetState( ( ( highlighted ) ? ( 'Hover' ) : ( 'Default' ) ) );
		}
	}

	public function SetActive( active : Bool )
	{
		m_active = active;
		GetRootWidget().SetState( ( ( active ) ? ( 'Active' ) : ( 'Default' ) ) );
	}

	protected event OnHoverOver( evt : inkPointerEvent )
	{
		SetHighlighted( true );
	}

	protected event OnHoverOut( evt : inkPointerEvent )
	{
		SetHighlighted( false );
	}

}

