Exemple #1
0
    public void DispatchEvent(exUIControl _sender, string _name, exUIEvent _event)
    {
        List <exUIEventListener> listeners = _sender.GetEventListeners(_name);

        DispatchEvent(_sender, _name, listeners, _event);
    }
Exemple #2
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public virtual void OnPointerMove( exUIEvent _e )
 {
     ProcessMessageInfoList ( moveSlots );
 }
Exemple #3
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public virtual void OnRelease( exUIEvent _e )
 {
     ProcessMessageInfoList ( releaseSlots );
 }
Exemple #4
0
 public void OnHoverMove(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onHoverMove", onHoverMove, _event);
 }
Exemple #5
0
 public void OnUnfocus(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onUnfocus", onUnfocus, _event);
 }
Exemple #6
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public virtual void OnPress(exUIEvent _e)
    {
        ProcessMessageInfoList(pressSlots);
    }
 public void OnProgressChanged( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onProgressChanged", onProgressChanged, _event );
 }
Exemple #8
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public virtual bool OnEvent( exUIEvent _e )
 {
     return false;
 }
Exemple #9
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public void FinishFadeOut()
 {
     exUIEvent uiEvent = new exUIEvent();
     uiEvent.bubbles = false;
     OnFinishFadeOut(uiEvent);
 }
Exemple #10
0
 public void OnButtonDown(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onButtonDown", onButtonDown, _event);
 }
Exemple #11
0
 public void OnButtonUp(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onButtonUp", onButtonUp, _event);
 }
Exemple #12
0
 public void OnClick(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onClick", onClick, _event);
 }
Exemple #13
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected new void Awake()
    {
        base.Awake();

        AddEventListener("onPressDown",
                         delegate(exUIEvent _event) {
            if (pressing)
            {
                return;
            }

            exUIPointEvent pointEvent = _event as exUIPointEvent;

            if (pointEvent.isTouch || pointEvent.GetMouseButton(0))
            {
                pressing    = true;
                pressDownAt = pointEvent.mainPoint.pos;
                pressingID  = pointEvent.mainPoint.id;

                exUIMng.inst.SetFocus(this);

                exUIEvent evtButtonDown = new exUIEvent();
                evtButtonDown.bubbles   = false;
                OnButtonDown(evtButtonDown);

                _event.StopPropagation();
            }
        });

        AddEventListener("onPressUp",
                         delegate(exUIEvent _event) {
            exUIPointEvent pointEvent = _event as exUIPointEvent;
            if (pointEvent.isTouch || pointEvent.GetMouseButton(0))
            {
                exUIEvent evtButtonUp = new exUIEvent();
                evtButtonUp.bubbles   = false;
                OnButtonUp(evtButtonUp);

                if (pressing)
                {
                    pressing = false;

                    exUIEvent evtClick = new exUIEvent();
                    evtClick.bubbles   = false;
                    OnClick(evtClick);

                    _event.StopPropagation();
                }
            }
        });

        AddEventListener("onHoverOut",
                         delegate(exUIEvent _event) {
            if (pressing)
            {
                pressing   = false;
                pressingID = -1;
                _event.StopPropagation();
            }
        });

        AddEventListener("onHoverMove",
                         delegate(exUIEvent _event) {
            if (pressing)
            {
                exUIPointEvent pointEvent = _event as exUIPointEvent;

                for (int i = 0; i < pointEvent.pointInfos.Length; ++i)
                {
                    exUIPointInfo point = pointEvent.pointInfos[i];
                    if (point.id == pressingID)
                    {
                        Vector2 delta = pointEvent.mainPoint.pos - pressDownAt;
                        if (allowDrag == false &&
                            delta.sqrMagnitude >= dragThreshold * dragThreshold)
                        {
                            exUIMng.inst.HoverOut(this, point.id);
                        }
                        else
                        {
                            _event.StopPropagation();
                        }
                    }
                }
            }
        });
    }
 void SayHello(exUIEvent _event)
 {
     Debug.Log("Hello World!");
 }
Exemple #15
0
 public void OnExit(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onExit", onExit, _event);
 }
Exemple #16
0
 public void OnEnter( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onEnter",    onEnter, _event );
 }
Exemple #17
0
 public void OnFinishFadeOut(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onFinishFadeOut", onFinishFadeOut, _event);
 }
Exemple #18
0
 public void OnExit( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onExit",     onExit,  _event );
 }
Exemple #19
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public virtual void OnClick(exUIEvent _e)
    {
        ProcessMessageInfoList(clickSlots);
    }
Exemple #20
0
 public void OnFinishFadeIn( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onFinishFadeIn",     onFinishFadeIn,  _event );
 }
Exemple #21
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public virtual bool OnEvent(exUIEvent _e)
    {
        return(false);
    }
Exemple #22
0
 public void OnStartFadeOut( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onStartFadeOut",     onStartFadeOut,  _event );
 }
Exemple #23
0
 public void OnPressUp(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onPressUp", onPressUp, _event);
 }
Exemple #24
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public void StartFadeOut()
 {
     exUIEvent uiEvent = new exUIEvent();
     uiEvent.bubbles = false;
     OnStartFadeOut(uiEvent);
 }
Exemple #25
0
 // TODO {
 // public void OnHoverEnter    ( exUIEvent _event )  { if ( onHoverIn    != null ) exUIMng.inst.DispatchEvent( this, onHoverIn,    _event ); }
 // public void OnHoverLeave   ( exUIEvent _event )  { if ( onHoverOut   != null ) exUIMng.inst.DispatchEvent( this, onHoverOut,   _event ); }
 // } TODO end
 public void OnHoverIn(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onHoverIn", onHoverIn, _event);
 }
Exemple #26
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public void Exit()
 {
     exUIEvent uiEvent = new exUIEvent();
     uiEvent.bubbles = false;
     OnExit (uiEvent);
 }
Exemple #27
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public virtual void OnHoverOut( exUIEvent _e )
 {
     ProcessMessageInfoList ( hoverOutSlots );
 }
Exemple #28
0
 public void OnContentResized( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onContentResized", onContentResized,  _event );
 }
Exemple #29
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public override bool OnEvent( exUIEvent _e )
    {
        exUIMng uimng = exUIMng.instance;

        // ========================================================
        if ( _e.category == exUIEvent.Category.Mouse ) {
        // ========================================================

            if ( _e.type == exUIEvent.Type.MouseEnter ) {
                if ( hoverInSlots.Count > 0 ) {
                    OnHoverIn (_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseExit ) {
                if ( uimng.GetMouseFocus() == this ) {
                    isPressing = false;
                    uimng.SetMouseFocus(null);
                }

                if ( hoverOutSlots.Count > 0 ) {
                    OnHoverOut(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseDown &&
                      _e.buttons == exUIEvent.MouseButtonFlags.Left )
            {
                if ( uimng.GetMouseFocus() == null ) {
                    uimng.SetMouseFocus( this );
                    isPressing = true;

                    if ( pressSlots.Count > 0 ) {
                        OnPress(_e);
                        return true;
                    }
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseUp &&
                      _e.buttons == exUIEvent.MouseButtonFlags.Left )
            {
                bool used = false;
                if ( isPressing ) {
                    if ( uimng.GetMouseFocus() == this ) {
                        uimng.SetMouseFocus( null );

                        if ( clickSlots.Count > 0 ) {
                            OnClick(_e);
                            used = true;
                        }
                    }
                    isPressing = false;
                }

                if ( releaseSlots.Count > 0 ) {
                    OnRelease(_e);
                    used = true;
                }
                return used;
            }
        }

        // ========================================================
        else if ( _e.category == exUIEvent.Category.Touch ) {
        // ========================================================

            if ( _e.type == exUIEvent.Type.TouchEnter ) {
                if ( hoverInSlots.Count > 0 ) {
                    OnHoverIn (_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.TouchExit ) {
                if ( uimng.GetTouchFocus(_e.touchID) == this ) {
                    isPressing = false;
                    uimng.SetTouchFocus( _e.touchID, null );
                }

                if ( hoverOutSlots.Count > 0 ) {
                    OnHoverOut(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.TouchDown ) {
                if ( uimng.GetTouchFocus( _e.touchID ) == null ) {
                    uimng.SetTouchFocus( _e.touchID, this );
                    isPressing = true;

                    if ( pressSlots.Count > 0 ) {
                        OnPress(_e);
                        return true;
                    }
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.TouchUp ) {
                bool used = false;
                if ( isPressing ) {
                    if ( uimng.GetTouchFocus(_e.touchID) == this ) {
                        uimng.SetTouchFocus( _e.touchID, null );

                        if ( clickSlots.Count > 0 ) {
                            OnClick(_e);
                            used = true;
                        }
                    }
                    isPressing = false;
                }

                if ( releaseSlots.Count > 0 ) {
                    OnRelease(_e);
                    used = true;
                }

                if ( hoverOutSlots.Count > 0 ) {
                    OnHoverOut(_e);
                    used = true;
                }

                return used;
            }
        }

        //
        return false;
    }
Exemple #30
0
 public void OnScroll( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onScroll", onScroll, _event );
 }
Exemple #31
0
 public void OnEnter(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onEnter", onEnter, _event);
 }
Exemple #32
0
 public void OnScrollFinished( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onScrollFinished", onScrollFinished,  _event );
 }
Exemple #33
0
 public void OnStartFadeIn(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onStartFadeIn", onStartFadeIn, _event);
 }
Exemple #34
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public void Scroll( Vector2 _delta )
    {
        if ( allowHorizontalScroll == false )
            _delta.x = 0.0f;
        if ( allowVerticalScroll == false )
            _delta.y = 0.0f;

        scrollOffset_ += _delta;

        if ( dragEffect != DragEffect.MomentumAndSpring ) {
            scrollOffset_.x = Mathf.Clamp( scrollOffset_.x, 0.0f, contentSize_.x - width );
            scrollOffset_.y = Mathf.Clamp( scrollOffset_.y, 0.0f, contentSize_.y - height );
        }

        if ( contentAnchor != null ) {
            scrollDest = new Vector3 ( originalAnchorPos.x - scrollOffset_.x,
                                 originalAnchorPos.y + scrollOffset_.y,
                                 originalAnchorPos.z );
            // contentAnchor.localPosition = scrollDest;
        }

        exUIEvent uiEvent = new exUIEvent();
        uiEvent.bubbles = false;
        OnScroll(uiEvent);
    }
Exemple #35
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public virtual void OnHoverOut(exUIEvent _e)
    {
        ProcessMessageInfoList(hoverOutSlots);
    }
Exemple #36
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public void StartScroll()
    {
        if ( dragEffect != DragEffect.None ) {
            damping = true;

            float contentX = (horizontalContentDir == ContentDirection.LeftToRight) ? 0.0f : -(contentSize_.x - width);
            float contentY = (verticalContentDir == ContentDirection.TopToBottom) ? 0.0f : -(contentSize_.y - height);
            Vector2 constrainOffset = exGeometryUtility.GetConstrainOffset ( new Rect( scrollOffset_.x, scrollOffset_.y, width, height ),
                                                                             new Rect( contentX, contentY, contentSize_.x, contentSize_.y ) );
            if ( Mathf.Abs(constrainOffset.x) > 0.001f ) {
                if ( dragEffect == DragEffect.MomentumAndSpring ) {
                    velocity.x *= 0.5f;
                }
            }

            if ( Mathf.Abs(constrainOffset.y) > 0.001f ) {
                if ( dragEffect == DragEffect.MomentumAndSpring ) {
                    velocity.y *= 0.5f;
                }
            }
        }
        else {
            velocity = Vector2.zero;
            damping = false;

            exUIEvent uiEvent = new exUIEvent();
            uiEvent.bubbles = false;
            OnScrollFinished(uiEvent);
        }
    }
Exemple #37
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public virtual void OnRelease(exUIEvent _e)
    {
        ProcessMessageInfoList(releaseSlots);
    }
Exemple #38
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    void LateUpdate()
    {
        Vector2 constrainOffset = Vector2.zero;
        Vector2 deltaScroll = Vector2.zero;
        bool doScroll = (damping || spring);

        float contentX = (horizontalContentDir == ContentDirection.LeftToRight) ? 0.0f : -(contentSize_.x - width);
        float contentY = (verticalContentDir == ContentDirection.TopToBottom) ? 0.0f : -(contentSize_.y - height);
        Rect scrollRect = new Rect( scrollOffset_.x, scrollOffset_.y, width, height );
        Rect contentRect = new Rect( contentX, contentY, Mathf.Max( contentSize_.x, width ), Mathf.Max( contentSize_.y, height ) );

        if ( damping || spring  )
            constrainOffset = exGeometryUtility.GetConstrainOffset ( scrollRect, contentRect );

        // deceleration
        velocity.x *= 0.9f;
        velocity.y *= 0.9f;

        // process damping first
        if ( damping ) {

            if ( Mathf.Abs(constrainOffset.x) > 0.001f ) {
                if ( dragEffect != DragEffect.MomentumAndSpring ) {
                    velocity.x = 0.0f;
                }
                else {
                    spring = true;
                }

                // more deceleration
                // velocity.x *= 0.8f;
            }

            if ( Mathf.Abs(constrainOffset.y) > 0.001f ) {
                if ( dragEffect != DragEffect.MomentumAndSpring ) {
                    velocity.y = 0.0f;
                }
                else {
                    spring = true;
                }

                // more deceleration
                // velocity.y *= 0.8f;
            }

            //
            if ( velocity.sqrMagnitude < 1.0f ) {
                damping = false;
                velocity = Vector2.zero;
            }
            else {
                deltaScroll = velocity * Time.deltaTime;
            }
        }

        // process spring
        if ( spring ) {
            Vector2 before = contentAnchor.localPosition;
            Vector2 after = exMath.SpringLerp ( before, before - constrainOffset, 15.0f, Time.deltaTime );
            Vector2 deltaSpring = after - before;

            if ( deltaSpring.sqrMagnitude < 0.001f ) {
                deltaScroll = -constrainOffset;
                spring = false;
            }
            else {
                deltaScroll = deltaScroll + deltaSpring;
            }
        }

        //
        if ( doScroll ) {
            Scroll ( deltaScroll );
            contentAnchor.localPosition = scrollDest;

            bool shouldFinish = (damping || spring);
            if ( shouldFinish ) {
                exUIEvent uiEvent = new exUIEvent();
                uiEvent.bubbles = false;
                OnScrollFinished(uiEvent);
            }
        }
        else {
            contentAnchor.localPosition = Vector3.Lerp( contentAnchor.localPosition, scrollDest, 0.6f );
        }
    }
Exemple #39
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public override bool OnEvent(exUIEvent _e)
    {
        exUIMng uimng = exUIMng.instance;

        // ========================================================
        if (_e.category == exUIEvent.Category.Mouse)
        {
            // ========================================================

            if (_e.type == exUIEvent.Type.MouseEnter)
            {
                if (hoverInSlots.Count > 0)
                {
                    OnHoverIn(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseExit)
            {
                if (uimng.GetMouseFocus() == this)
                {
                    isPressing = false;
                    uimng.SetMouseFocus(null);
                }

                if (hoverOutSlots.Count > 0)
                {
                    OnHoverOut(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseDown &&
                     _e.buttons == exUIEvent.MouseButtonFlags.Left)
            {
                if (uimng.GetMouseFocus() == null)
                {
                    uimng.SetMouseFocus(this);
                    isPressing = true;

                    if (pressSlots.Count > 0)
                    {
                        OnPress(_e);
                        return(true);
                    }
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseUp &&
                     _e.buttons == exUIEvent.MouseButtonFlags.Left)
            {
                bool used = false;
                if (isPressing)
                {
                    if (uimng.GetMouseFocus() == this)
                    {
                        uimng.SetMouseFocus(null);

                        if (clickSlots.Count > 0)
                        {
                            OnClick(_e);
                            used = true;
                        }
                    }
                    isPressing = false;
                }

                if (releaseSlots.Count > 0)
                {
                    OnRelease(_e);
                    used = true;
                }
                return(used);
            }
        }

        // ========================================================
        else if (_e.category == exUIEvent.Category.Touch)
        {
            // ========================================================

            if (_e.type == exUIEvent.Type.TouchEnter)
            {
                if (hoverInSlots.Count > 0)
                {
                    OnHoverIn(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.TouchExit)
            {
                if (uimng.GetTouchFocus(_e.touchID) == this)
                {
                    isPressing = false;
                    uimng.SetTouchFocus(_e.touchID, null);
                }

                if (hoverOutSlots.Count > 0)
                {
                    OnHoverOut(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.TouchDown)
            {
                if (uimng.GetTouchFocus(_e.touchID) == null)
                {
                    uimng.SetTouchFocus(_e.touchID, this);
                    isPressing = true;

                    if (pressSlots.Count > 0)
                    {
                        OnPress(_e);
                        return(true);
                    }
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.TouchUp)
            {
                bool used = false;
                if (isPressing)
                {
                    if (uimng.GetTouchFocus(_e.touchID) == this)
                    {
                        uimng.SetTouchFocus(_e.touchID, null);

                        if (clickSlots.Count > 0)
                        {
                            OnClick(_e);
                            used = true;
                        }
                    }
                    isPressing = false;
                }

                if (releaseSlots.Count > 0)
                {
                    OnRelease(_e);
                    used = true;
                }

                if (hoverOutSlots.Count > 0)
                {
                    OnHoverOut(_e);
                    used = true;
                }

                return(used);
            }
        }

        //
        return(false);
    }
Exemple #40
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    void StartDrag( exUIEvent _event )
    {
        exUIPointEvent pointEvent = _event as exUIPointEvent;
        if ( draggable && ( pointEvent.isTouch || pointEvent.GetMouseButton(0) ) ) {
            dragging = true;
            draggingID = pointEvent.mainPoint.id;

            damping = false;
            spring = false;
            velocity = Vector2.zero;

            exUIMng.inst.SetFocus(this);

            _event.StopPropagation();
        }
    }
 void SayHello( exUIEvent _event )
 {
     Debug.Log("Hello World!");
 }
Exemple #42
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public override bool OnEvent( exUIEvent _e )
    {
        exUIMng uimng = exUIMng.instance;

        // ========================================================
        if ( _e.category == exUIEvent.Category.Mouse ) {
        // ========================================================

            if ( _e.type == exUIEvent.Type.MouseUp ) {
                if ( isPressing ) {
                    if ( uimng.GetMouseFocus() == this ) {
                        uimng.SetMouseFocus(null);
                    }
                    if ( isDragging ) {
                        isDragging = false;

                        if ( Time.time - pressTime < 0.01f ) {
                            velocity = Vector2.zero;
                        }
                        else {
                            velocity = (pressPoint - _e.position)/(Time.time - pressTime);
                        }

                        if ( scrollDirection == ScrollDirection.Vertical || contentOffset.x < minX || contentOffset.x > maxX ) {
                            velocity.x = 0.0f;
                        }
                        if ( scrollDirection == ScrollDirection.Horizontal || contentOffset.y < minY || contentOffset.y > maxY ) {
                            velocity.y = 0.0f;
                        }

                        flickingX = true;
                        flickingY = true;
                    }
                    isPressing = false;
                }
                return true;
            }
            else if ( _e.type == exUIEvent.Type.MouseDown &&
                      _e.buttons == exUIEvent.MouseButtonFlags.Left )
            {
                isPressing = true;
                scrollingToX = false;
                scrollingToY = false;
                velocity = Vector2.zero;
                pressPoint = _e.position;
                pressTime = Time.time;
                return true;
            }
            else if ( _e.type == exUIEvent.Type.MouseMove &&
                      _e.buttons == exUIEvent.MouseButtonFlags.Left )
            {
                if ( isDragging == false ) {
                    if ( (pressPoint - _e.position).sqrMagnitude > 1.0f ) {
                        pressPoint = _e.position;
                        pressTime = Time.time;
                        isDragging = true;
                        uimng.SetMouseFocus( this );

                        if ( showSliderOnDragging ) {
                            if ( scrollDirection != ScrollDirection.Vertical ) {
                                StopCoroutine ( "FadeToHorizontal" );
                                StartCoroutine ( "FadeToHorizontal", new FadeToParams( horizontalSlider, 1.0f, 0.3f ) );
                            }

                            if ( scrollDirection != ScrollDirection.Horizontal ) {
                                StopCoroutine ( "FadeToVertical" );
                                StartCoroutine ( "FadeToVertical", new FadeToParams( verticalSlider, 1.0f, 0.3f ) );
                            }
                        }
                    }
                }

                if ( isDragging ) {
                    float dragCoefX = 1.0f;
                    float dragCoefY = 1.0f;

                    if ( contentOffset.x < minX || contentOffset.x > maxX )
                        dragCoefX = 0.4f;
                    if ( contentOffset.y < minY || contentOffset.y > maxY )
                        dragCoefY = 0.4f;

                    float newX = -_e.delta.x * dragCoefX;
                    float newY = -_e.delta.y * dragCoefY;
                    Vector2 scrollDistance = Vector2.zero;

                    //
                    if ( scrollDirection == ScrollDirection.Vertical )
                        newX = 0.0f;
                    else if ( scrollDirection == ScrollDirection.Horizontal )
                        newY = 0.0f;

                    scrollDistance = new Vector2( newX, newY );
                    contentOffset += scrollDistance;
                    SetOffset ( contentOffset );
                }

                return true;
            }
        }

        // ========================================================
        else if ( _e.category == exUIEvent.Category.Touch ) {
        // ========================================================

            if ( _e.type == exUIEvent.Type.TouchUp ) {
                if ( isPressing ) {
                    if ( uimng.GetTouchFocus(_e.touchID) == this ) {
                        uimng.SetTouchFocus( _e.touchID, null );
                    }
                    if ( isDragging ) {
                        isDragging = false;

                        if ( Time.time - pressTime < 0.01f ) {
                            velocity = Vector2.zero;
                        }
                        else {
                            velocity = (pressPoint - _e.position)/(Time.time - pressTime);
                        }

                        if ( scrollDirection == ScrollDirection.Vertical || contentOffset.x < minX || contentOffset.x > maxX ) {
                            velocity.x = 0.0f;
                        }
                        if ( scrollDirection == ScrollDirection.Horizontal || contentOffset.y < minY || contentOffset.y > maxY ) {
                            velocity.y = 0.0f;
                        }

                        flickingX = true;
                        flickingY = true;
                    }
                    isPressing = false;
                }
                return true;
            }
            else if ( _e.type == exUIEvent.Type.TouchDown ) {
                isPressing = true;
                scrollingToX = false;
                scrollingToY = false;
                velocity = Vector2.zero;
                pressPoint = _e.position;
                pressTime = Time.time;
                return true;
            }
            else if ( _e.type == exUIEvent.Type.TouchMove ) {
                if ( isDragging == false ) {

                    if ( (pressPoint - _e.position).sqrMagnitude > 1.0f ) {
                        pressPoint = _e.position;
                        pressTime = Time.time;
                        isDragging = true;
                        uimng.SetTouchFocus( _e.touchID, this );

                        if ( showSliderOnDragging ) {
                            if ( scrollDirection != ScrollDirection.Vertical ) {
                                StopCoroutine ( "FadeToHorizontal" );
                                StartCoroutine ( "FadeToHorizontal", new FadeToParams( horizontalSlider, 1.0f, 0.3f ) );
                            }

                            if ( scrollDirection != ScrollDirection.Horizontal ) {
                                StopCoroutine ( "FadeToVertical" );
                                StartCoroutine ( "FadeToVertical", new FadeToParams( verticalSlider, 1.0f, 0.3f ) );
                            }
                        }
                    }
                }

                if ( isDragging ) {
                    float dragCoefX = 1.0f;
                    float dragCoefY = 1.0f;

                    if ( contentOffset.x < minX || contentOffset.x > maxX )
                        dragCoefX = 0.4f;
                    if ( contentOffset.y < minY || contentOffset.y > maxY )
                        dragCoefY = 0.4f;

                    float newX = -_e.delta.x * dragCoefX;
                    float newY = -_e.delta.y * dragCoefY;
                    Vector2 scrollDistance = Vector2.zero;

                    //
                    if ( scrollDirection == ScrollDirection.Vertical )
                        newX = 0.0f;
                    else if ( scrollDirection == ScrollDirection.Horizontal )
                        newY = 0.0f;

                    scrollDistance = new Vector2( newX, newY );
                    contentOffset += scrollDistance;
                    SetOffset ( contentOffset );
                }

                return true;
            }
        }

        return false;
    }
Exemple #43
0
 public void OnHoverOut(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onHoverOut", onHoverOut, _event);
 }
Exemple #44
0
 public void OnProgressChanged(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onProgressChanged", onProgressChanged, _event);
 }
Exemple #45
0
 public void OnPressDown(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onPressDown", onPressDown, _event);
 }
Exemple #46
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public override bool OnEvent(exUIEvent _e)
    {
        exUIMng uimng = exUIMng.instance;

        // ========================================================
        if (_e.category == exUIEvent.Category.Mouse)
        {
            // ========================================================

            if (_e.type == exUIEvent.Type.MouseUp)
            {
                if (isPressing)
                {
                    if (uimng.GetMouseFocus() == this)
                    {
                        uimng.SetMouseFocus(null);
                    }
                    if (isDragging)
                    {
                        isDragging = false;

                        if (Time.time - pressTime < 0.01f)
                        {
                            velocity = Vector2.zero;
                        }
                        else
                        {
                            velocity = (pressPoint - _e.position) / (Time.time - pressTime);
                        }

                        if (scrollDirection == ScrollDirection.Vertical || contentOffset.x < minX || contentOffset.x > maxX)
                        {
                            velocity.x = 0.0f;
                        }
                        if (scrollDirection == ScrollDirection.Horizontal || contentOffset.y < minY || contentOffset.y > maxY)
                        {
                            velocity.y = 0.0f;
                        }

                        flickingX = true;
                        flickingY = true;
                    }
                    isPressing = false;
                }
                return(true);
            }
            else if (_e.type == exUIEvent.Type.MouseDown &&
                     _e.buttons == exUIEvent.MouseButtonFlags.Left)
            {
                isPressing   = true;
                scrollingToX = false;
                scrollingToY = false;
                velocity     = Vector2.zero;
                pressPoint   = _e.position;
                pressTime    = Time.time;
                return(true);
            }
            else if (_e.type == exUIEvent.Type.MouseMove &&
                     _e.buttons == exUIEvent.MouseButtonFlags.Left)
            {
                if (isDragging == false)
                {
                    if ((pressPoint - _e.position).sqrMagnitude > 1.0f)
                    {
                        pressPoint = _e.position;
                        pressTime  = Time.time;
                        isDragging = true;
                        uimng.SetMouseFocus(this);

                        if (showSliderOnDragging)
                        {
                            if (scrollDirection != ScrollDirection.Vertical)
                            {
                                StopCoroutine("FadeToHorizontal");
                                StartCoroutine("FadeToHorizontal", new FadeToParams(horizontalSlider, 1.0f, 0.3f));
                            }

                            if (scrollDirection != ScrollDirection.Horizontal)
                            {
                                StopCoroutine("FadeToVertical");
                                StartCoroutine("FadeToVertical", new FadeToParams(verticalSlider, 1.0f, 0.3f));
                            }
                        }
                    }
                }

                if (isDragging)
                {
                    float dragCoefX = 1.0f;
                    float dragCoefY = 1.0f;

                    if (contentOffset.x < minX || contentOffset.x > maxX)
                    {
                        dragCoefX = 0.4f;
                    }
                    if (contentOffset.y < minY || contentOffset.y > maxY)
                    {
                        dragCoefY = 0.4f;
                    }

                    float   newX           = -_e.delta.x * dragCoefX;
                    float   newY           = -_e.delta.y * dragCoefY;
                    Vector2 scrollDistance = Vector2.zero;

                    //
                    if (scrollDirection == ScrollDirection.Vertical)
                    {
                        newX = 0.0f;
                    }
                    else if (scrollDirection == ScrollDirection.Horizontal)
                    {
                        newY = 0.0f;
                    }

                    scrollDistance = new Vector2(newX, newY);
                    contentOffset += scrollDistance;
                    SetOffset(contentOffset);
                }

                return(true);
            }
        }

        // ========================================================
        else if (_e.category == exUIEvent.Category.Touch)
        {
            // ========================================================

            if (_e.type == exUIEvent.Type.TouchUp)
            {
                if (isPressing)
                {
                    if (uimng.GetTouchFocus(_e.touchID) == this)
                    {
                        uimng.SetTouchFocus(_e.touchID, null);
                    }
                    if (isDragging)
                    {
                        isDragging = false;

                        if (Time.time - pressTime < 0.01f)
                        {
                            velocity = Vector2.zero;
                        }
                        else
                        {
                            velocity = (pressPoint - _e.position) / (Time.time - pressTime);
                        }

                        if (scrollDirection == ScrollDirection.Vertical || contentOffset.x < minX || contentOffset.x > maxX)
                        {
                            velocity.x = 0.0f;
                        }
                        if (scrollDirection == ScrollDirection.Horizontal || contentOffset.y < minY || contentOffset.y > maxY)
                        {
                            velocity.y = 0.0f;
                        }

                        flickingX = true;
                        flickingY = true;
                    }
                    isPressing = false;
                }
                return(true);
            }
            else if (_e.type == exUIEvent.Type.TouchDown)
            {
                isPressing   = true;
                scrollingToX = false;
                scrollingToY = false;
                velocity     = Vector2.zero;
                pressPoint   = _e.position;
                pressTime    = Time.time;
                return(true);
            }
            else if (_e.type == exUIEvent.Type.TouchMove)
            {
                if (isDragging == false)
                {
                    if ((pressPoint - _e.position).sqrMagnitude > 1.0f)
                    {
                        pressPoint = _e.position;
                        pressTime  = Time.time;
                        isDragging = true;
                        uimng.SetTouchFocus(_e.touchID, this);

                        if (showSliderOnDragging)
                        {
                            if (scrollDirection != ScrollDirection.Vertical)
                            {
                                StopCoroutine("FadeToHorizontal");
                                StartCoroutine("FadeToHorizontal", new FadeToParams(horizontalSlider, 1.0f, 0.3f));
                            }

                            if (scrollDirection != ScrollDirection.Horizontal)
                            {
                                StopCoroutine("FadeToVertical");
                                StartCoroutine("FadeToVertical", new FadeToParams(verticalSlider, 1.0f, 0.3f));
                            }
                        }
                    }
                }

                if (isDragging)
                {
                    float dragCoefX = 1.0f;
                    float dragCoefY = 1.0f;

                    if (contentOffset.x < minX || contentOffset.x > maxX)
                    {
                        dragCoefX = 0.4f;
                    }
                    if (contentOffset.y < minY || contentOffset.y > maxY)
                    {
                        dragCoefY = 0.4f;
                    }

                    float   newX           = -_e.delta.x * dragCoefX;
                    float   newY           = -_e.delta.y * dragCoefY;
                    Vector2 scrollDistance = Vector2.zero;

                    //
                    if (scrollDirection == ScrollDirection.Vertical)
                    {
                        newX = 0.0f;
                    }
                    else if (scrollDirection == ScrollDirection.Horizontal)
                    {
                        newY = 0.0f;
                    }

                    scrollDistance = new Vector2(newX, newY);
                    contentOffset += scrollDistance;
                    SetOffset(contentOffset);
                }

                return(true);
            }
        }

        return(false);
    }
Exemple #47
0
 public void OnEXMouseWheel(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onMouseWheel", onMouseWheel, _event);
 }
Exemple #48
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public virtual void OnPointerMove(exUIEvent _e)
    {
        ProcessMessageInfoList(moveSlots);
    }
Exemple #49
0
 public void OnDeactive(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onDeactive", onDeactive, _event);
 }
Exemple #50
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public override bool OnEvent(exUIEvent _e)
    {
        exUIMng uimng = exUIMng.instance;

        if (_e.category == exUIEvent.Category.Mouse)
        {
            if (_e.type == exUIEvent.Type.MouseEnter)
            {
                if (hoverInSlots.Count > 0)
                {
                    OnHoverIn(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseExit)
            {
                if (uimng.GetMouseFocus() == this)
                {
                    uimng.SetMouseFocus(null);
                }

                if (hoverOutSlots.Count > 0)
                {
                    OnHoverOut(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseDown)
            {
                if (uimng.GetMouseFocus() == null)
                {
                    uimng.SetMouseFocus(this);
                }

                if (pressSlots.Count > 0)
                {
                    OnPress(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseUp)
            {
                if (uimng.GetMouseFocus() == this)
                {
                    uimng.SetMouseFocus(null);
                }

                if (releaseSlots.Count > 0)
                {
                    OnRelease(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.MouseMove)
            {
                if (moveSlots.Count > 0)
                {
                    OnPointerMove(_e);
                    return(true);
                }
                return(false);
            }
        }
        else if (_e.category == exUIEvent.Category.Touch)
        {
            if (_e.type == exUIEvent.Type.TouchEnter)
            {
                if (hoverInSlots.Count > 0)
                {
                    OnHoverIn(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.TouchExit)
            {
                if (uimng.GetTouchFocus(_e.touchID) == this)
                {
                    uimng.SetTouchFocus(_e.touchID, null);
                }

                if (hoverOutSlots.Count > 0)
                {
                    OnHoverOut(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.TouchDown)
            {
                if (uimng.GetTouchFocus(_e.touchID) == null)
                {
                    uimng.SetTouchFocus(_e.touchID, this);
                }

                if (pressSlots.Count > 0)
                {
                    OnPress(_e);
                    return(true);
                }
                return(false);
            }
            else if (_e.type == exUIEvent.Type.TouchUp)
            {
                if (uimng.GetTouchFocus(_e.touchID) == this)
                {
                    uimng.SetTouchFocus(_e.touchID, null);
                }

                bool used = false;
                if (releaseSlots.Count > 0)
                {
                    OnRelease(_e);
                    used = true;
                }
                if (hoverOutSlots.Count > 0)
                {
                    OnHoverOut(_e);
                    used = true;
                }
                return(used);
            }
            else if (_e.type == exUIEvent.Type.TouchMove)
            {
                if (moveSlots.Count > 0)
                {
                    OnPointerMove(_e);
                    return(true);
                }
                return(false);
            }
        }

        //
        return(false);
    }
Exemple #51
0
 public void OnChecked(exUIEvent _event)
 {
     exUIMng.inst.DispatchEvent(this, "onChecked", onChecked, _event);
 }
Exemple #52
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    protected new void Awake()
    {
        base.Awake();

        AddEventListener( "onPressDown",
                          delegate ( exUIEvent _event ) {
                              if ( pressing )
                                  return;

                              exUIPointEvent pointEvent = _event as exUIPointEvent;

                              if ( pointEvent.isTouch || pointEvent.GetMouseButton(0) ) {
                                  pressing = true;
                                  pressDownAt = pointEvent.mainPoint.pos;
                                  pressingID = pointEvent.mainPoint.id;

                                  exUIMng.inst.SetFocus(this);

                                  exUIEvent evtButtonDown = new exUIEvent();
                                  evtButtonDown.bubbles = false;
                                  OnButtonDown(evtButtonDown);

                                  _event.StopPropagation();
                              }
                          } );

        AddEventListener( "onPressUp",
                          delegate ( exUIEvent _event ) {
                              exUIPointEvent pointEvent = _event as exUIPointEvent;
                              if ( pointEvent.isTouch || pointEvent.GetMouseButton(0) ) {
                                  exUIEvent evtButtonUp = new exUIEvent();
                                  evtButtonUp.bubbles = false;
                                  OnButtonUp(evtButtonUp);

                                  if ( pressing ) {
                                      pressing = false;

                                      exUIEvent evtClick = new exUIEvent();
                                      evtClick.bubbles = false;
                                      OnClick (evtClick);

                                      _event.StopPropagation();
                                  }
                              }
                          } );

        AddEventListener( "onHoverOut",
                          delegate ( exUIEvent _event ) {
                              if ( pressing ) {
                                  pressing = false;
                                  pressingID = -1;
                                  _event.StopPropagation();
                              }
                          } );

        AddEventListener( "onHoverMove",
                          delegate ( exUIEvent _event ) {
                              if ( pressing ) {
                                  exUIPointEvent pointEvent = _event as exUIPointEvent;

                                   for ( int i = 0; i < pointEvent.pointInfos.Length; ++i ) {
                                       exUIPointInfo point = pointEvent.pointInfos[i];
                                       if ( point.id == pressingID ) {
                                          Vector2 delta = pointEvent.mainPoint.pos - pressDownAt;
                                          if ( allowDrag == false &&
                                               delta.sqrMagnitude >= dragThreshold * dragThreshold )
                                          {
                                              exUIMng.inst.HoverOut ( this, point.id);
                                          }
                                          else {
                                              _event.StopPropagation();
                                          }
                                       }
                                  }
                              }
                          } );
    }
Exemple #53
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public override bool OnEvent( exUIEvent _e )
    {
        exUIMng uimng = exUIMng.instance;

        if ( _e.category == exUIEvent.Category.Mouse ) {
            if ( _e.type == exUIEvent.Type.MouseEnter ) {
                if ( hoverInSlots.Count > 0 ) {
                    OnHoverIn (_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseExit ) {
                if ( uimng.GetMouseFocus() == this ) {
                    uimng.SetMouseFocus(null);
                }

                if ( hoverOutSlots.Count > 0 ) {
                    OnHoverOut(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseDown ) {
                if ( uimng.GetMouseFocus() == null )
                    uimng.SetMouseFocus( this );

                if ( pressSlots.Count > 0 ) {
                    OnPress(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseUp ) {
                if ( uimng.GetMouseFocus() == this ) {
                    uimng.SetMouseFocus( null );
                }

                if ( releaseSlots.Count > 0 ) {
                    OnRelease(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.MouseMove ) {
                if ( moveSlots.Count > 0 ) {
                    OnPointerMove(_e);
                    return true;
                }
                return false;
            }
        }
        else if ( _e.category == exUIEvent.Category.Touch ) {
            if ( _e.type == exUIEvent.Type.TouchEnter ) {
                if ( hoverInSlots.Count > 0 ) {
                    OnHoverIn (_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.TouchExit ) {
                if ( uimng.GetTouchFocus(_e.touchID) == this ) {
                    uimng.SetTouchFocus( _e.touchID, null );
                }

                if ( hoverOutSlots.Count > 0 ) {
                    OnHoverOut(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.TouchDown ) {
                if ( uimng.GetTouchFocus(_e.touchID) == null ) {
                    uimng.SetTouchFocus( _e.touchID, this );
                }

                if ( pressSlots.Count > 0 ) {
                    OnPress(_e);
                    return true;
                }
                return false;
            }
            else if ( _e.type == exUIEvent.Type.TouchUp ) {
                if ( uimng.GetTouchFocus(_e.touchID) == this ) {
                    uimng.SetTouchFocus( _e.touchID, null );
                }

                bool used = false;
                if ( releaseSlots.Count > 0 ) {
                    OnRelease(_e);
                    used = true;
                }
                if ( hoverOutSlots.Count > 0 ) {
                    OnHoverOut(_e);
                    used = true;
                }
                return used;
            }
            else if ( _e.type == exUIEvent.Type.TouchMove ) {
                if ( moveSlots.Count > 0 ) {
                    OnPointerMove(_e);
                    return true;
                }
                return false;
            }
        }

        //
        return false;
    }
Exemple #54
0
 public void OnButtonDown( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onButtonDown",  onButtonDown, _event );
 }
Exemple #55
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public virtual void OnPress( exUIEvent _e )
 {
     ProcessMessageInfoList ( pressSlots );
 }
Exemple #56
0
 public void OnButtonUp( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onButtonUp",    onButtonUp,   _event );
 }
Exemple #57
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public virtual void OnClick( exUIEvent _e )
 {
     ProcessMessageInfoList ( clickSlots );
 }
Exemple #58
0
 public void OnClick( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onClick",       onClick,      _event );
 }
Exemple #59
0
 public void OnCheckChanged( exUIEvent _event )
 {
     exUIMng.inst.DispatchEvent( this, "onCheckChanged", onCheckChanged, _event );
 }
Exemple #60
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public void DispatchEvent(exUIControl _sender, string _name, List <exUIEventListener> _listeners, exUIEvent _event)
    {
        _event.target = _sender;

        if (_event.bubbles)
        {
            List <exUIControl> routine = GetRoutine(_sender);

            // capture phase
            if (_listeners != null)
            {
                for (int i = 0; i < _listeners.Count; ++i)
                {
                    exUIEventListener listener = _listeners[i];
                    if (listener.capturePhase)
                    {
                        _event.eventPhase = exUIEventPhase.Capture;

                        for (int j = routine.Count - 1; j >= 0; --j)
                        {
                            exUIControl sender2 = routine[j];
                            List <exUIEventListener> listeners2 = sender2.GetEventListeners(_name);
                            _event.currentTarget = sender2;
                            DoDispatchEvent(sender2, listeners2, _event);
                            if (_event.isPropagationStopped)
                            {
                                return;
                            }
                        }
                    }
                }
            }

            // target phase
            if (_listeners != null)
            {
                _event.eventPhase    = exUIEventPhase.Target;
                _event.currentTarget = _sender;
                DoDispatchEvent(_sender, _listeners, _event);
                if (_event.isPropagationStopped)
                {
                    return;
                }
            }

            // bubble phase
            _event.eventPhase = exUIEventPhase.Bubble;
            for (int j = 0; j < routine.Count; ++j)
            {
                exUIControl sender2 = routine[j];
                List <exUIEventListener> listeners2 = sender2.GetEventListeners(_name);
                _event.currentTarget = sender2;
                DoDispatchEvent(sender2, listeners2, _event);
                if (_event.isPropagationStopped)
                {
                    return;
                }
            }
        }
        else
        {
            _event.eventPhase    = exUIEventPhase.Target;
            _event.currentTarget = _sender;
            DoDispatchEvent(_sender, _listeners, _event);
        }
    }