2
0

GUIBase.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. namespace BansheeEngine
  5. {
  6. public abstract class GUIBase : ScriptObject
  7. {
  8. private GUIArea mainArea;
  9. private GUILayout _mainLayout;
  10. internal List<GUIArea> childAreas = new List<GUIArea>();
  11. public GUILayout layout
  12. {
  13. get { return _mainLayout; }
  14. }
  15. public GUISkin skin; // TODO
  16. internal GUIBase()
  17. { }
  18. ~GUIBase()
  19. {
  20. GUIArea[] childArray = childAreas.ToArray(); // Iterating over it will modify it so make a copy
  21. for (int i = 0; i < childArray.Length; i++)
  22. childArray[i].Destroy();
  23. childAreas.Clear();
  24. }
  25. internal void Initialize()
  26. {
  27. mainArea = AddResizableAreaXY(0, 0, 0, 0);
  28. _mainLayout = mainArea.layout;
  29. }
  30. public GUIArea AddArea(int x, int y, int width = 0, int height = 0, short depth = 0)
  31. {
  32. GUIArea area = GUIArea.Create(this, x, y, width, height, depth);
  33. area.SetParent(this);
  34. return area;
  35. }
  36. public GUIArea AddResizableAreaX(int offsetLeft, int offsetRight, int offsetTop, int height, short depth = 0)
  37. {
  38. GUIArea area = GUIArea.CreateResizableX(this, offsetLeft, offsetRight, offsetTop, height, depth);
  39. area.SetParent(this);
  40. return area;
  41. }
  42. public GUIArea AddResizableAreaY(int offsetTop, int offsetBottom, int offsetLeft, int width, short depth = 0)
  43. {
  44. GUIArea area = GUIArea.CreateResizableY(this, offsetTop, offsetBottom, offsetLeft, width, depth);
  45. area.SetParent(this);
  46. return area;
  47. }
  48. public GUIArea AddResizableAreaXY(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, short depth = 0)
  49. {
  50. GUIArea area = GUIArea.CreateResizableXY(this, offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
  51. area.SetParent(this);
  52. return area;
  53. }
  54. }
  55. }