import class inkSliderController extends inkLogicController
{
	public import function Setup( minimumValue : Float, maximumValue : Float, defaultValue : Float, optional step : Float );
	public import function GetProgress() : Float;
	public import function GetCurrentValue() : Float;
	public import function GetMaxValue() : Float;
	public import function GetMinValue() : Float;
	public import function GetStep() : Float;
	public import function GetPercentageHandleSize() : Float;
	public import function SetPercentageHandleSize( newSize : Float );
	public import function SetInputDisabled( disabled : Bool );
	public import function ChangeValue( newValue : Float );
	public import function ChangeProgress( newValue : Float );
	public import function Next();
	public import function Prior();
	public import function GetSlidingAreaRef() : inkWidgetRef;
	public import function GetHandleRef() : inkWidgetRef;

	private var m_handleWidgetRef : weak< inkWidget >;
	private var m_slidingAreaWidgetRef : weak< inkWidget >;
	private var m_isDragging : Bool;
	private var m_defaultScale : Vector2;
	private var m_pressedScale : Vector2;
	private var m_defaultOpacity : Float;
	private editable var m_defaultColor : CName;
	default m_defaultColor = 'MainColors.Red';
	private editable var m_hoveredColor : CName;
	default m_hoveredColor = 'MainColors.Blue';
	private editable var m_pressedColor : CName;
	default m_pressedColor = 'MainColors.ActiveBlue';
	private editable var m_pressedOpacity : Float;
	default m_pressedOpacity = 0.7f;

	protected event OnInitialize()
	{
		m_pressedScale = Vector2( 1.04999995, 1.04999995 );
		m_handleWidgetRef = inkWidgetRef.Get( GetHandleRef() );
		m_slidingAreaWidgetRef = inkWidgetRef.Get( GetSlidingAreaRef() );
		m_defaultOpacity = m_handleWidgetRef.GetOpacity();
		m_defaultScale = m_handleWidgetRef.GetScale();
		m_slidingAreaWidgetRef.RegisterToCallback( 'OnPress', this, 'OnPress' );
		RegisterToCallback( 'OnSliderHandleReleased', this, 'OnRelease' );
		m_slidingAreaWidgetRef.RegisterToCallback( 'OnEnter', this, 'OnHoverOver' );
		m_slidingAreaWidgetRef.RegisterToCallback( 'OnLeave', this, 'OnHoverOut' );
	}

	protected event OnUninitialize()
	{
		PlaySound( 'Scrolling', 'OnStop' );
		m_slidingAreaWidgetRef.UnregisterFromCallback( 'OnPress', this, 'OnPress' );
		UnregisterFromCallback( 'OnSliderHandleReleased', this, 'OnRelease' );
		m_slidingAreaWidgetRef.UnregisterFromCallback( 'OnEnter', this, 'OnHoverOver' );
		m_slidingAreaWidgetRef.UnregisterFromCallback( 'OnLeave', this, 'OnHoverOut' );
	}

	protected event OnPress( e : inkPointerEvent )
	{
		if( e.IsAction( 'click' ) )
		{
			m_handleWidgetRef.SetScale( m_pressedScale );
			m_handleWidgetRef.BindProperty( 'tintColor', m_pressedColor );
			m_handleWidgetRef.SetOpacity( m_pressedOpacity );
			m_isDragging = true;
			PlaySound( 'Scrolling', 'OnStart' );
		}
	}

	protected event OnRelease()
	{
		m_handleWidgetRef.SetScale( m_defaultScale );
		m_handleWidgetRef.BindProperty( 'tintColor', m_defaultColor );
		m_handleWidgetRef.SetOpacity( m_defaultOpacity );
		m_isDragging = false;
		PlaySound( 'Scrolling', 'OnStop' );
	}

	protected event OnHoverOver( e : inkPointerEvent )
	{
		if( !( m_isDragging ) )
		{
			m_handleWidgetRef.BindProperty( 'tintColor', m_hoveredColor );
		}
	}

	protected event OnHoverOut( e : inkPointerEvent )
	{
		if( !( m_isDragging ) )
		{
			m_handleWidgetRef.BindProperty( 'tintColor', m_defaultColor );
		}
	}

}

import enum inkESliderDirection
{
	Horizontal,
	Vertical,
}

