GUIBase.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. for (int i = 0; i < childAreas.Count; i++)
  21. {
  22. childAreas[i].Destroy();
  23. }
  24. childAreas.Clear();
  25. }
  26. internal void Initialize()
  27. {
  28. mainArea = AddResizableAreaXY(0, 0, 0, 0);
  29. _mainLayout = mainArea.layout;
  30. }
  31. public GUIArea AddArea(int x, int y, int width = 0, int height = 0, short depth = 0)
  32. {
  33. GUIArea area = GUIArea.Create(this, x, y, width, height, depth);
  34. childAreas.Add(area);
  35. return area;
  36. }
  37. public GUIArea AddResizableAreaX(int offsetLeft, int offsetRight, int offsetTop, int height, short depth = 0)
  38. {
  39. GUIArea area = GUIArea.CreateResizableX(this, offsetLeft, offsetRight, offsetTop, height, depth);
  40. childAreas.Add(area);
  41. return area;
  42. }
  43. public GUIArea AddResizableAreaY(int offsetTop, int offsetBottom, int offsetLeft, int width, short depth = 0)
  44. {
  45. GUIArea area = GUIArea.CreateResizableY(this, offsetTop, offsetBottom, offsetLeft, width, depth);
  46. childAreas.Add(area);
  47. return area;
  48. }
  49. public GUIArea AddResizableAreaXY(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, short depth = 0)
  50. {
  51. GUIArea area = GUIArea.CreateResizableXY(this, offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
  52. childAreas.Add(area);
  53. return area;
  54. }
  55. }
  56. }