public override Vector2 GetPosition(GuiControl g) { var basepos = TotalDisplacement; var i = 0; var curctrl = Children[i]; while (g != curctrl && i < Children.Count) { if (Direction == Direction.Vertical) { basepos.Y += Children[i].Size.Y; } else { basepos.X += Children[i].Size.X; } i++; curctrl = Children[i]; } if (Direction == Direction.Vertical) { return(basepos + new Vector2(Padding.X, i * Padding.Y)); } else { return(basepos + new Vector2(i * Padding.X, Padding.Y)); } }
public override Vector2 GetPosition(GuiControl g) { var basepos = TotalDisplacement; var index = Children.IndexOf(g); var row = (int)Math.Ceiling((index + 1) / (float)Columns); var column = (index + 1) % Columns; var x = MathHelper.Lerp(Padding.X + basepos.X, basepos.X + Size.X - Padding.X, (float)column / (Columns)); var y = MathHelper.Lerp(Padding.Y + basepos.Y, basepos.Y + Size.Y - Padding.Y, (float)(row - 1) / (Rows)); return(new Vector2(x, y)); }
public override Vector2 GetPosition(GuiControl g) { var pos = TotalDisplacement; var alignment = (Alignment)g.LocationDescription.GetDescription(); switch (alignment) { case Alignment.BottomLeft: return((pos + new Vector2(0, Size.Y - g.Size.Y)) + new Vector2(g.Position.X, -g.Position.Y)); case Alignment.BottomMiddle: return((pos + new Vector2((Size.X / 2) - (g.Size.X / 2), Size.Y - g.Size.Y)) + new Vector2(g.Position.X, -g.Position.Y)); case Alignment.BottomRight: return((pos + new Vector2(Size.X - g.Size.X, Size.Y - g.Size.Y)) + new Vector2(-g.Position.X, -g.Position.Y)); case Alignment.Left: return((pos + new Vector2(0, (Size.Y / 2) - (g.Size.Y / 2))) + g.Position); case Alignment.Middle: return((pos + new Vector2((Size.X / 2) - (g.Size.X / 2), (Size.Y / 2) - (g.Size.Y / 2))) + g.Position); case Alignment.Right: return((pos + new Vector2(Size.X - g.Size.X, Size.Y / 2 - (g.Size.Y / 2))) + new Vector2(-g.Position.X, g.Position.Y)); case Alignment.TopLeft: return(pos + new Vector2(g.Position.X, g.Position.Y)); case Alignment.TopMiddle: return((pos + new Vector2((Size.X / 2) - (g.Size.X / 2), 0)) + new Vector2(g.Position.X, g.Position.Y)); case Alignment.TopRight: return((pos + new Vector2(Size.X - g.Size.X, 0)) + new Vector2(-g.Position.X, g.Position.Y)); default: return(pos); } }
public override Vector2 GetPosition(GuiControl g) { if (g.GetType() == typeof(GuiScrollBar)) { return(TotalDisplacement + g.Position); } var basepanel = BasePanel; var basepos = TotalDisplacement; if (direction == Direction.Vertical) { var basespace = basepanel.Size.Y; if (basespace < Size.Y) { return(basepos); } else { return(basepos - new Vector2(0, MathHelper.Lerp(0, basepanel.Size.Y - Size.Y, scrollbarY.ScrollPercentage))); } } if (direction == Direction.Horizontal) { var basespace = basepanel.Size.X; if (basespace < Size.X) { return(basepos); } else { return(basepos - new Vector2(MathHelper.Lerp(0, basepanel.Size.X - Size.X, scrollbarX.ScrollPercentage), 0)); } } if (direction == Direction.Both) { float xpos, ypos; var basespacex = basepanel.Size.X; if (basespacex < Size.X) { xpos = basepos.X; } else { xpos = basepos.X - MathHelper.Lerp(0, basepanel.Size.X - Size.X, scrollbarX.ScrollPercentage); } var basespacey = basepanel.Size.Y; if (basespacey < Size.Y) { ypos = basepos.Y; } else { ypos = basepos.Y - MathHelper.Lerp(0, basepanel.Size.Y - Size.Y, scrollbarY.ScrollPercentage); } return(new Vector2(xpos, ypos)); } if (direction == Direction.Vertical) { return(TotalDisplacement + g.Position - new Vector2(0, scrollbarY.ScrollPosition)); } if (direction == Direction.Horizontal) { return(TotalDisplacement + g.Position - new Vector2(scrollbarX.ScrollPosition, 0)); } return(TotalDisplacement + g.Position); }
public override void AddChild(GuiControl c) { BasePanel.AddChild(c); }
public override void RemoveChild(GuiControl c) { BasePanel.RemoveChild(c); }