public override void TestCollision(Cursor cursor)
        {
            if (!mCollapsed)
            {
                base.TestCollision(cursor);


                if (cursor.WindowOver == this && cursor.PrimaryDoubleClick &&
                    cursor.YForUI > mWorldUnitY + mScaleY - 2.1f)
                {
                    DoubleClickCollapse();
                }
            }
            else
            {
                if (cursor.YForUI > mWorldUnitY + mScaleY - 2.1f)
                {
                    if (cursor.PrimaryPush)
                    {                    // drag the window
                        cursor.WindowPushed = this;
                        cursor.GrabWindow(this);
                    }
                    if (cursor.PrimaryDoubleClick)
                    {
                        DoubleClickCollapse();
                    }
                }
            }
        }
示例#2
0
		public override void TestCollision(Cursor cursor)
		{
			base.TestCollision(cursor);


			if(cursor.PrimaryPush && cursor.WindowOver == mPositionBar)
			{// dragging the position bar
				cursor.GrabWindow(mPositionBar);
			}
		}
示例#3
0
        public override void TestCollision(Cursor cursor)
        {
            base.TestCollision(cursor);

            if (cursor.PrimaryPush && cursor.WindowOver == positionBar)
            {
                mBeforeChangeValue = mCurrentValue;

                cursor.GrabWindow(positionBar);
            }
        }
示例#4
0
        public virtual void TestCollision(FlatRedBall.Gui.Cursor cursor)
        {
            if (HasCursorOver(cursor))
            {
                cursor.WindowOver = this;

                if (cursor.PrimaryPush)
                {
                    cursor.WindowPushed = this;

                    if (Push != null)
                    {
                        Push(this);
                    }


                    cursor.GrabWindow(this);
                }

                if (cursor.PrimaryClick) // both pushing and clicking can occur in one frame because of buffered input
                {
                    if (cursor.WindowPushed == this)
                    {
                        if (Click != null)
                        {
                            Click(this);
                        }
                        if (cursor.PrimaryClickNoSlide && ClickNoSlide != null)
                        {
                            ClickNoSlide(this);
                        }

                        // if (cursor.PrimaryDoubleClick && DoubleClick != null)
                        //   DoubleClick(this);
                    }
                    else
                    {
                        if (SlideOnClick != null)
                        {
                            SlideOnClick(this);
                        }
                    }
                }
            }
        }
示例#5
0
        public override void TestCollision(Cursor cursor)
		{
			if(!mCollapsed)
			{
				base.TestCollision(cursor);


				if(cursor.WindowOver == this && cursor.PrimaryDoubleClick &&
                    cursor.YForUI > mWorldUnitY + mScaleY - 2.1f)
				{
					DoubleClickCollapse();
				}
			}
			else
			{
                if (cursor.YForUI > mWorldUnitY + mScaleY - 2.1f)
				{ 
					if(cursor.PrimaryPush)
					{// drag the window
						cursor.WindowPushed = this;
						cursor.GrabWindow(this);
					}
					if(cursor.PrimaryDoubleClick)
					{
						DoubleClickCollapse();
					}
				}
			}
		}
        public void TestCollision(Cursor cursor)
        {
            if (HasCursorOver(cursor))
            {
                cursor.WindowOver = this;

                if (cursor.PrimaryPush)
                {

                    cursor.WindowPushed = this;

                    if (Push != null)
                        Push(this);

                    cursor.GrabWindow(this);

                }

                if (cursor.PrimaryClick) // both pushing and clicking can occur in one frame because of buffered input
                {
                    if (cursor.WindowPushed == this)
                    {
                        if (Click != null)
                        {
                            Click(this);
                        }
                        if (cursor.PrimaryClickNoSlide && ClickNoSlide != null)
                        {
                            ClickNoSlide(this);
                        }

                        // if (cursor.PrimaryDoubleClick && DoubleClick != null)
                        //   DoubleClick(this);
                    }
                    else
                    {
                        if (SlideOnClick != null)
                        {
                            SlideOnClick(this);
                        }
                    }
                }
            }
        }
示例#7
0
		public override void TestCollision(Cursor cursor)
		{
			
			base.TestCollision(cursor);

			if(cursor.PrimaryPush && cursor.WindowOver == positionBar)
			{
                mBeforeChangeValue = mCurrentValue;

				cursor.GrabWindow(positionBar);
			}
        }
        /// <summary>
        /// Tries to handle cursor activity. If this returns true, then either this element or one of its
        /// children handled the activity. 
        /// </summary>
        /// <param name="cursor">Reference to the cursor object</param>
        /// <returns>Whether this or one of its children handled the cursor activity, blocking other windows from receiving cursor input this frame.</returns>
        /// <remarks>This method will always allow children to handle the activity first, as children draw in front of their parents. Only components
        /// can have UI elements. Standard elements such as Sprites or Containers cannot themselves handle the activity, but they do give their children the
        /// opportunity to handle activity. This is because components (such as buttons) may be part of a container for stacking or other organization.
        /// 
        /// Ultimately this hierarchical logic exists because only the top-most parent is added to the GuiManager, and it is responsible for
        /// giving its children the opportunity to perform cursor-related input. </remarks>
        private bool TryHandleCursorActivity(Cursor cursor)
        {
            bool handledByChild = false;
            bool handledByThis = false;

            if (HasCursorOver(cursor))
            {

                #region Try handling by children

                // Let's see if any children have the cursor over:
                for(int i = this.Children.Count -1; i > -1; i--)
                {
                    var child = this.Children[i];
                    if (child is GraphicalUiElement)
                    {
                        var asGue = child as GraphicalUiElement;
                        // Children should always have the opportunity to handle activity,
                        // even if they are not components, because they may contain components as their children
                        //if (asGue.IsComponentOrInstanceOfComponent() && asGue.HasCursorOver(cursor))
                        if (asGue.HasCursorOver(cursor))
                            {
                            handledByChild = asGue.TryHandleCursorActivity(cursor);

                            if(handledByChild)
                            {
                                break;
                            }
                        }
                    }
                }

                #endregion


                if (!handledByChild && this.IsComponentOrInstanceOfComponent())
                {
                    handledByThis = true;

                    cursor.WindowOver = this;

                    if (cursor.PrimaryPush)
                    {

                        cursor.WindowPushed = this;

                        if (Push != null)
                            Push(this);


                        cursor.GrabWindow(this);

                    }

                    if (cursor.PrimaryClick) // both pushing and clicking can occur in one frame because of buffered input
                    {
                        if (cursor.WindowPushed == this)
                        {
                            if (Click != null)
                            {
                                Click(this);
                            }
                            if (cursor.PrimaryClickNoSlide && ClickNoSlide != null)
                            {
                                ClickNoSlide(this);
                            }

                            // if (cursor.PrimaryDoubleClick && DoubleClick != null)
                            //   DoubleClick(this);
                        }
                        else
                        {
                            if (SlideOnClick != null)
                            {
                                SlideOnClick(this);
                            }
                        }
                    }
                }
            }

            return handledByThis || handledByChild;
        }