class inkHoverResizeController extends inkLogicController { private var m_root : weak< inkWidget >; private var m_animToNew : inkAnimDef; private var m_animToOld : inkAnimDef; editable var m_vectorNewSize : Vector2; editable var m_vectorOldSize : Vector2; editable var m_animationDuration : Float; default m_animationDuration = 0.10f; protected event OnInitialize() { m_root = GetRootWidget(); m_root.RegisterToCallback( 'OnHoverOver', this, 'OnRootHoverOver' ); m_root.RegisterToCallback( 'OnHoverOut', this, 'OnRootHoverOut' ); if( ( m_vectorNewSize.X == 0.0 ) && ( m_vectorNewSize.Y == 0.0 ) ) { m_vectorNewSize = m_root.GetSize(); } if( ( m_vectorOldSize.X == 0.0 ) && ( m_vectorOldSize.Y == 0.0 ) ) { m_vectorOldSize = m_root.GetSize(); } InitializeAnimations(); } protected event OnRootHoverOver( e : inkPointerEvent ) { if( e.GetTarget() == m_root ) { m_root.StopAllAnimations(); m_root.PlayAnimation( m_animToNew ); } } protected event OnRootHoverOut( e : inkPointerEvent ) { if( e.GetTarget() == m_root ) { m_root.StopAllAnimations(); m_root.PlayAnimation( m_animToOld ); } } private function InitializeAnimations() { var resizeInterp : inkAnimSize; m_animToNew = new inkAnimDef; resizeInterp = new inkAnimSize; resizeInterp.SetDirection( inkanimInterpolationDirection.To ); resizeInterp.SetEndSize( m_vectorNewSize ); resizeInterp.SetDuration( m_animationDuration ); m_animToNew.AddInterpolator( resizeInterp ); m_animToOld = new inkAnimDef; resizeInterp = new inkAnimSize; resizeInterp.SetDirection( inkanimInterpolationDirection.To ); resizeInterp.SetEndSize( m_vectorOldSize ); resizeInterp.SetDuration( m_animationDuration ); m_animToOld.AddInterpolator( resizeInterp ); } }