public void DispatchEvent(exUIControl _sender, string _name, exUIEvent _event) { List <exUIEventListener> listeners = _sender.GetEventListeners(_name); DispatchEvent(_sender, _name, listeners, _event); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnPointerMove( exUIEvent _e ) { ProcessMessageInfoList ( moveSlots ); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnRelease( exUIEvent _e ) { ProcessMessageInfoList ( releaseSlots ); }
public void OnHoverMove(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onHoverMove", onHoverMove, _event); }
public void OnUnfocus(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onUnfocus", onUnfocus, _event); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnPress(exUIEvent _e) { ProcessMessageInfoList(pressSlots); }
public void OnProgressChanged( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onProgressChanged", onProgressChanged, _event ); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual bool OnEvent( exUIEvent _e ) { return false; }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void FinishFadeOut() { exUIEvent uiEvent = new exUIEvent(); uiEvent.bubbles = false; OnFinishFadeOut(uiEvent); }
public void OnButtonDown(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onButtonDown", onButtonDown, _event); }
public void OnButtonUp(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onButtonUp", onButtonUp, _event); }
public void OnClick(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onClick", onClick, _event); }
/////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------ // 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!"); }
public void OnExit(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onExit", onExit, _event); }
public void OnEnter( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onEnter", onEnter, _event ); }
public void OnFinishFadeOut(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onFinishFadeOut", onFinishFadeOut, _event); }
public void OnExit( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onExit", onExit, _event ); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnClick(exUIEvent _e) { ProcessMessageInfoList(clickSlots); }
public void OnFinishFadeIn( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onFinishFadeIn", onFinishFadeIn, _event ); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual bool OnEvent(exUIEvent _e) { return(false); }
public void OnStartFadeOut( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onStartFadeOut", onStartFadeOut, _event ); }
public void OnPressUp(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onPressUp", onPressUp, _event); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void StartFadeOut() { exUIEvent uiEvent = new exUIEvent(); uiEvent.bubbles = false; OnStartFadeOut(uiEvent); }
// 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); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void Exit() { exUIEvent uiEvent = new exUIEvent(); uiEvent.bubbles = false; OnExit (uiEvent); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnHoverOut( exUIEvent _e ) { ProcessMessageInfoList ( hoverOutSlots ); }
public void OnContentResized( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onContentResized", onContentResized, _event ); }
/////////////////////////////////////////////////////////////////////////////// // 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; }
public void OnScroll( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onScroll", onScroll, _event ); }
public void OnEnter(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onEnter", onEnter, _event); }
public void OnScrollFinished( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onScrollFinished", onScrollFinished, _event ); }
public void OnStartFadeIn(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onStartFadeIn", onStartFadeIn, _event); }
// ------------------------------------------------------------------ // 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); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnHoverOut(exUIEvent _e) { ProcessMessageInfoList(hoverOutSlots); }
// ------------------------------------------------------------------ // 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); } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnRelease(exUIEvent _e) { ProcessMessageInfoList(releaseSlots); }
// ------------------------------------------------------------------ // 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 ); } }
/////////////////////////////////////////////////////////////////////////////// // 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); }
// ------------------------------------------------------------------ // 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!"); }
// ------------------------------------------------------------------ // 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; }
public void OnHoverOut(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onHoverOut", onHoverOut, _event); }
public void OnProgressChanged(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onProgressChanged", onProgressChanged, _event); }
public void OnPressDown(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onPressDown", onPressDown, _event); }
// ------------------------------------------------------------------ // 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); }
public void OnEXMouseWheel(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onMouseWheel", onMouseWheel, _event); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnPointerMove(exUIEvent _e) { ProcessMessageInfoList(moveSlots); }
public void OnDeactive(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onDeactive", onDeactive, _event); }
/////////////////////////////////////////////////////////////////////////////// // 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); }
public void OnChecked(exUIEvent _event) { exUIMng.inst.DispatchEvent(this, "onChecked", onChecked, _event); }
/////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------ // 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(); } } } } } ); }
/////////////////////////////////////////////////////////////////////////////// // 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; }
public void OnButtonDown( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onButtonDown", onButtonDown, _event ); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnPress( exUIEvent _e ) { ProcessMessageInfoList ( pressSlots ); }
public void OnButtonUp( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onButtonUp", onButtonUp, _event ); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public virtual void OnClick( exUIEvent _e ) { ProcessMessageInfoList ( clickSlots ); }
public void OnClick( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onClick", onClick, _event ); }
public void OnCheckChanged( exUIEvent _event ) { exUIMng.inst.DispatchEvent( this, "onCheckChanged", onCheckChanged, _event ); }
// ------------------------------------------------------------------ // 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); } }