IsCursorOver() публичный статический Метод

Static utility method to check if the cursor is over an overlay element.
public static IsCursorOver ( OverlayElement element, Vector2 cursorPos ) : bool
element Axiom.Overlays.OverlayElement
cursorPos Vector2
Результат bool
Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cursorPos"></param>
        public override void OnCursorPressed(Vector2 cursorPos)
        {
            if (!this.scrollHandle.IsVisible)
            {
                return;                 // don't care about clicks if text not scrollable
            }

            Vector2 co = Widget.CursorOffset(this.scrollHandle, cursorPos);

            if (co.LengthSquared <= 81)
            {
                this.isDragging = true;
                this.dragOffset = co.y;
            }
            else if (Widget.IsCursorOver(this.scrollTrack, cursorPos))
            {
                Real newTop        = this.scrollHandle.Top + co.y;
                Real lowerBoundary = this.scrollTrack.Height - this.scrollHandle.Height;
                this.scrollHandle.Top = Math.Utility.Clamp <Real>(newTop, lowerBoundary, 0);

                // update text area contents based on new scroll percentage
                this.scrollPercentage = Math.Utility.Clamp <Real>(newTop / lowerBoundary, 1, 0);
                FilterLines();
            }

            base.OnCursorPressed(cursorPos);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cursorPos"></param>
        public override void OnCursorPressed(Vector2 cursorPos)
        {
            if (!this.handle.IsVisible)
            {
                return;
            }

            Vector2 co = Widget.CursorOffset(this.handle, cursorPos);

            if (co.LengthSquared <= 81)
            {
                this.isDragging = true;
                this.dragOffset = co.x;
            }
            else if (Widget.IsCursorOver(this.track, cursorPos))
            {
                Real newLeft       = this.handle.Left + co.x;
                Real rightBoundary = this.track.Width - this.handle.Width;

                this.handle.Left = Math.Utility.Clamp <Real>(newLeft, rightBoundary, 0);
                Value            = GetSnappedValue(newLeft / rightBoundary);
            }

            base.OnCursorPressed(cursorPos);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public override bool MousePressed(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
        {
            if (this.TrayManager.InjectMouseDown(evt, id))
            {
                return(true);
            }

            if (this.TitleLabel.TrayLocation != TrayLocation.None)
            {
                for (int i = 0; i < this.Thumbs.Count; i++)
                {
                    if (this.Thumbs[i].IsVisible &&
                        Widget.IsCursorOver(this.Thumbs[i],
                                            new Vector2(this.TrayManager.CursorContainer.Left, this.TrayManager.CursorContainer.Top),
                                            0))
                    {
                        this.SampleMenu.SelectItem(i);
                        break;
                    }
                }
            }
            try
            {
                return(base.MousePressed(evt, id));
            }
            catch (Exception ex)
            {
                RunSample(null);
                string msg = ex.Message + "\nSource: " + ex.InnerException;
                LogManager.Instance.Write("[Samples] Error! " + msg);
                this.TrayManager.ShowOkDialog("Error!", msg);
            }
            return(true);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cursorPos"></param>
        public override void OnCursorPressed(Vector2 cursorPos)
        {
            OverlayManager om = OverlayManager.Instance;

            if (this.isExpanded)
            {
                if (this.scrollHandle.IsVisible)                   // check for scrolling
                {
                    Vector2 co = Widget.CursorOffset(this.scrollHandle, cursorPos);

                    if (co.LengthSquared <= 81)
                    {
                        this.isDragging = true;
                        this.dragOffset = co.y;
                        return;
                    }
                    else if (Widget.IsCursorOver(this.scrollTrack, cursorPos))
                    {
                        Real newTop        = this.scrollHandle.Top + co.y;
                        Real lowerBoundary = this.scrollTrack.Height - this.scrollHandle.Height;
                        this.scrollHandle.Top = Math.Utility.Clamp <Real>(newTop, lowerBoundary, 0);

                        var scrollPercentage = Math.Utility.Clamp <Real>(newTop / lowerBoundary, 1, 0);
                        DisplayIndex = (int)(scrollPercentage * (this.items.Count - this.itemElements.Count) + 0.5);
                        return;
                    }
                }

                if (!IsCursorOver(this.expandedBox, cursorPos, 3))
                {
                    Retract();
                }
                else
                {
                    Real l = this.itemElements[0].DerivedLeft * om.ViewportWidth + 5;
                    Real t = this.itemElements[0].DerivedTop * om.ViewportHeight + 5;
                    Real r = l + this.itemElements[this.itemElements.Count - 1].Width - 10;
                    Real b = this.itemElements[this.itemElements.Count - 1].DerivedTop * om.ViewportHeight +
                             this.itemElements[this.itemElements.Count - 1].Height - 5;

                    if (cursorPos.x >= l && cursorPos.x <= r && cursorPos.y >= t && cursorPos.y <= b)
                    {
                        if (this.highlightIndex != this.sectionIndex)
                        {
                            SelectItem(this.highlightIndex);
                        }
                        Retract();
                    }
                }
            }
            else
            {
                if (this.items.Count < 2)
                {
                    return;                     // don't waste time showing a menu if there's no choice
                }

                if (IsCursorOver(this.smallBox, cursorPos, 4))
                {
                    this.expandedBox.Show();
                    this.smallBox.Hide();

                    // calculate how much vertical space we need
                    Real idealHeight = this.itemsShown * (this.smallBox.Height - 8) + 20;
                    this.expandedBox.Height = idealHeight;
                    this.scrollTrack.Height = this.expandedBox.Height - 20;

                    this.expandedBox.Left = this.smallBox.Left - 4;

                    // if the expanded menu goes down off the screen, make it go up instead
                    if (this.smallBox.DerivedTop * om.ViewportHeight + idealHeight > om.ViewportHeight)
                    {
                        this.expandedBox.Top = this.smallBox.Top + this.smallBox.Height - idealHeight + 3;
                        // if we're in thick style, hide the caption because it will interfere with the expanded menu
                        if (this.textArea.HorizontalAlignment == HorizontalAlignment.Center)
                        {
                            this.textArea.Hide();
                        }
                    }
                    else
                    {
                        this.expandedBox.Top = this.smallBox.Top + 3;
                    }

                    this.isExpanded     = true;
                    this.highlightIndex = this.sectionIndex;
                    DisplayIndex        = this.highlightIndex;

                    if (this.itemsShown < this.items.Count)                       // update scrollbar position
                    {
                        this.scrollHandle.Show();
                        Real lowerBoundary = this.scrollTrack.Height - this.scrollHandle.Height;
                        this.scrollHandle.Top = (int)(this.displayIndex * lowerBoundary / (this.items.Count - this.itemElements.Count));
                    }
                    else
                    {
                        this.scrollHandle.Hide();
                    }
                }
            }

            base.OnCursorPressed(cursorPos);
        }