コード例 #1
0
        private void positionOnPoint()
        {
            Vector3 screenPos    = sceneWindow.getProjectedPosition(scenePoint);
            int     windowLeft   = sceneWindow.RenderXLoc;
            int     windowTop    = sceneWindow.RenderYLoc;
            int     windowRight  = windowLeft + sceneWindow.RenderWidth;
            int     windowBottom = windowTop + sceneWindow.RenderHeight;

            int left   = (int)screenPos.x + windowLeft;
            int top    = (int)screenPos.y + windowTop;
            int right  = left + widget.Width;
            int bottom = top + widget.Height;

            if (right > windowRight)
            {
                left += windowRight - right;
            }
            if (bottom > windowBottom)
            {
                top += windowBottom - bottom;
            }

            if (left < windowLeft)
            {
                left = windowLeft;
            }
            if (top < windowTop)
            {
                top = windowTop;
            }

            widget.setPosition(left, top);
        }