예제 #1
0
        private void TranslateArea(ref ControlArea area, Vector2 translation, Points anchoredPoints)
        {
            // an anchor can move a side if it has direct control of that side
            // or it can move the opposite side is that one has no direct anchors
            // or it can move both of the other 2 sides if neither of those have direct anchors.

            var leftOrRightAnchored = EitherSelected(anchoredPoints, Points.Left, Points.Right);
            var topOrBottomAnchored = EitherSelected(anchoredPoints, Points.Top, Points.Bottom);

            // left and right
            if (Start.Selected(Points.Left) || (Start.Selected(Points.Right) && !anchoredPoints.Selected(Points.Left)) || !leftOrRightAnchored)
            {
                area.Left += (int)translation.X;
            }
            if (Start.Selected(Points.Right) || (Start.Selected(Points.Left) && !anchoredPoints.Selected(Points.Right)) || !leftOrRightAnchored)
            {
                area.Right += (int)translation.X;
            }

            // top and bottom
            if (Start.Selected(Points.Top) || (Start.Selected(Points.Bottom) && !anchoredPoints.Selected(Points.Top)) || !topOrBottomAnchored)
            {
                area.Top += (int)translation.Y;
            }
            if (Start.Selected(Points.Bottom) || (Start.Selected(Points.Top) && !anchoredPoints.Selected(Points.Bottom)) || !topOrBottomAnchored)
            {
                area.Bottom += (int)translation.Y;
            }
        }
예제 #2
0
파일: Frame.cs 프로젝트: sachgits/Myre
        private void UpdateAnchors()
        {
            Rectangle parentArea;
            var       viewport = device.Viewport;

            if (Parent != null)
            {
                parentArea = Parent.Area;
            }
            else if (RespectSafeArea)
            {
                parentArea = viewport.TitleSafeArea;
            }
            else
            {
                parentArea = new Rectangle(0, 0, viewport.Width, viewport.Height);
            }

            ControlArea area = new ControlArea(0, 0, (int)size.X, (int)size.Y);

            foreach (var side in anchors)
            {
                if (anchoredPoints.Selected(side.Key))
                {
                    side.Value.Apply(ref area, parentArea, anchoredPoints);
                }
            }

            Area = area.ToRectangle();
        }
예제 #3
0
파일: Anchor.cs 프로젝트: xoxota99/Myre
        public void Apply(ref ControlArea area, Rectangle parentArea, Points anchoredPoints)
        {
            if (AnchorControl != null)
                parentArea = AnchorControl.Area;

            Vector2 pointOnSelf = FindPosition(area.ToRectangle(), Start);
            Vector2 pointOnParent = FindPosition(parentArea, End);

            TranslateArea(ref area, pointOnParent - pointOnSelf + Offset, anchoredPoints);
        }
예제 #4
0
        public void Apply(ref ControlArea area, Rectangle parentArea, Points anchoredPoints)
        {
            if (AnchorControl != null)
            {
                parentArea = AnchorControl.Area;
            }

            Vector2 pointOnSelf   = FindPosition(area.ToRectangle(), Start);
            Vector2 pointOnParent = FindPosition(parentArea, End);

            TranslateArea(ref area, pointOnParent - pointOnSelf + Offset, anchoredPoints);
        }
예제 #5
0
파일: Anchor.cs 프로젝트: xoxota99/Myre
        private void TranslateArea(ref ControlArea area, Vector2 translation, Points anchoredPoints)
        {
            // an anchor can move a side if it has direct control of that side
            // or it can move the opposite side is that one has no direct anchors
            // or it can move both of the other 2 sides if neither of those have direct anchors.

            var leftOrRightAnchored = EitherSelected(anchoredPoints, Points.Left, Points.Right);
            var topOrBottomAnchored = EitherSelected(anchoredPoints, Points.Top, Points.Bottom);

            // left and right
            if (Start.Selected(Points.Left) || (Start.Selected(Points.Right) && !anchoredPoints.Selected(Points.Left)) || !leftOrRightAnchored)
                area.Left += (int)translation.X;
            if (Start.Selected(Points.Right) || (Start.Selected(Points.Left) && !anchoredPoints.Selected(Points.Right)) || !leftOrRightAnchored)
                area.Right += (int)translation.X;

            // top and bottom
            if (Start.Selected(Points.Top) || (Start.Selected(Points.Bottom) && !anchoredPoints.Selected(Points.Top)) || !topOrBottomAnchored)
                area.Top += (int)translation.Y;
            if (Start.Selected(Points.Bottom) || (Start.Selected(Points.Top) && !anchoredPoints.Selected(Points.Bottom)) || !topOrBottomAnchored)
                area.Bottom += (int)translation.Y;
        }
예제 #6
0
파일: Frame.cs 프로젝트: TomGillen/Myre
        private void UpdateAnchors()
        {
            Rectangle parentArea;
            var viewport = device.Viewport;
            if (Parent != null)
                parentArea = Parent.Area;
            else if (RespectSafeArea)
                parentArea = viewport.TitleSafeArea;
            else
                parentArea = new Rectangle(0, 0, viewport.Width, viewport.Height);

            ControlArea area = new ControlArea(0, 0, (int)size.X, (int)size.Y);
            foreach (var side in anchors)
            {
                if (anchoredPoints.Selected(side.Key))
                    side.Value.Apply(ref area, parentArea, anchoredPoints);
            }

            Area = area.ToRectangle();
        }