SplitBar.xaml.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Numerics;
  2. using Robust.Client.AutoGenerated;
  3. using Robust.Client.Graphics;
  4. using Robust.Client.UserInterface.Controls;
  5. using Robust.Client.UserInterface.XAML;
  6. namespace Content.Client.UserInterface.Controls
  7. {
  8. [GenerateTypedNameReferences]
  9. [Virtual]
  10. public partial class SplitBar : BoxContainer
  11. {
  12. public Vector2 MinBarSize = new(24, 0);
  13. public SplitBar()
  14. {
  15. RobustXamlLoader.Load(this);
  16. }
  17. public void Clear()
  18. {
  19. DisposeAllChildren();
  20. }
  21. public void AddEntry(float amount, Color color, string? tooltip = null)
  22. {
  23. AddChild(new PanelContainer
  24. {
  25. ToolTip = tooltip,
  26. HorizontalExpand = true,
  27. SizeFlagsStretchRatio = amount,
  28. MouseFilter = MouseFilterMode.Stop,
  29. PanelOverride = new StyleBoxFlat
  30. {
  31. BackgroundColor = color,
  32. PaddingLeft = 2f,
  33. PaddingRight = 2f,
  34. },
  35. MinSize = MinBarSize
  36. });
  37. }
  38. }
  39. }