3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
14 private readonly
GUIFrame rightFrame;
19 private float leftAnimState = 1.0f;
20 private float rightAnimState = 0.0f;
24 get => leftButton.Enabled;
25 set => leftButton.Enabled = value;
29 get => rightButton.Enabled;
30 set => rightButton.Enabled = value;
40 this.leftFrame = leftFrame;
41 this.middleFrame = middleFrame;
42 this.rightFrame = rightFrame;
55 { MinSize = new Point(20, 0), MaxSize = new Point(int.MaxValue, (int)(150 * GUI.Scale)) },
56 style:
"UIToggleButton")
58 OnClicked = (_, __) =>
79 static void updateState(ref
float state,
bool visible)
80 => state = MathHelper.Lerp(state, visible ? 0.0f : 1.0f, 0.5f);
87 int height = container.RectTransform.NonScaledSize.Y;
88 int buttonY = height/2 - leftButton.RectTransform.NonScaledSize.Y/2;
90 leftFrame.RectTransform.AbsoluteOffset =
new Point((
int)(-width(leftFrame) * leftAnimState), 0);
91 leftButton.RectTransform.AbsoluteOffset = leftFrame.RectTransform.AbsoluteOffset
92 +
new Point(width(leftFrame), buttonY);
94 ? SpriteEffects.FlipHorizontally
95 : SpriteEffects.None);
97 rightFrame.RectTransform.AbsoluteOffset =
new Point((
int)(width(container) + width(rightFrame) * (rightAnimState-1f)), 0);
98 rightButton.RectTransform.AbsoluteOffset = rightFrame.RectTransform.AbsoluteOffset
99 +
new Point(-width(rightButton), buttonY);
102 : SpriteEffects.FlipHorizontally);
104 middleFrame.RectTransform.AbsoluteOffset =
new Point(
105 leftButton.RectTransform.AbsoluteOffset.X + width(leftButton),
107 middleFrame.RectTransform.NonScaledSize =
new Point(
108 rightButton.RectTransform.AbsoluteOffset.X - middleFrame.RectTransform.AbsoluteOffset.X,
IEnumerable< GUIComponent > GetAllChildren()
Returns all child elements in the hierarchy.
RectTransform RectTransform
SpriteEffects SpriteEffects
PanelAnimator(RectTransform rectTransform, GUIFrame leftFrame, GUIComponent middleFrame, GUIFrame rightFrame)