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; } }
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(); }
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); }
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); }
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; }
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(); }