コード例 #1
0
        public static bool IsCursorOver(Mogre.OverlayElement element, Mogre.Vector2 cursorPos, float voidBorder)
        {
            if (element == null)
            {
                return(false);
            }
            Mogre.OverlayManager om = Mogre.OverlayManager.Singleton;
            float detrivedLeft      = element._getDerivedLeft();
            float detrivedTop       = element._getDerivedTop();
            float l = detrivedLeft * om.ViewportWidth;
            float t = detrivedTop * om.ViewportHeight;
            float r = 0;
            float b = 0;

            if (element.MetricsMode == GuiMetricsMode.GMM_RELATIVE)
            {
                r = l + element.Width * om.ViewportWidth;
                b = t + element.Height * om.ViewportHeight;
            }
            else if (element.MetricsMode == GuiMetricsMode.GMM_PIXELS)
            {
                r = l + element.Width;
                b = t + element.Height;
            }

            bool b1 = cursorPos.x >= l + voidBorder;
            bool b2 = cursorPos.x <= r - voidBorder;
            bool b3 = cursorPos.y >= t + voidBorder;
            bool b4 = cursorPos.y <= b - voidBorder;

            return(b1 && b2 && b3 && b4);
        }
コード例 #2
0
 /// <summary>
 /// Static utility method used to get the cursor's offset from the center of an overlay element in pixels.
 /// </summary>
 public static Mogre.Vector2 CursorOffset(Mogre.OverlayElement element, Mogre.Vector2 cursorPos)
 {
     Mogre.OverlayManager om = Mogre.OverlayManager.Singleton;
     return(new Mogre.Vector2(cursorPos.x - (element._getDerivedLeft() * om.ViewportWidth + element.Width / 2), cursorPos.y - (element._getDerivedTop() * om.ViewportHeight + element.Height / 2f)));
 }
コード例 #3
0
 /// <summary>
 /// Static utility method to check if the cursor is over an overlay element.
 /// </summary>
 /// <returns></returns>
 public static bool IsCursorOver(Mogre.OverlayElement element, Mogre.Vector2 cursorPos)
 {
     return(IsCursorOver(element, cursorPos, 0f));
 }