GUIArea.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public sealed class GUIArea : ScriptObject
  6. {
  7. private GUILayout _layout;
  8. private GUIPanel parent;
  9. private bool isDestroyed;
  10. public GUILayout layout
  11. {
  12. get { return _layout;}
  13. }
  14. internal GUIArea()
  15. { }
  16. internal void SetParent(GUIPanel parent)
  17. {
  18. if (this.parent != null)
  19. this.parent.childAreas.Remove(this);
  20. this.parent = parent;
  21. parent.childAreas.Add(this);
  22. }
  23. internal static GUIArea Create(GUIPanel parent, int x, int y, int width, int height, short depth)
  24. {
  25. GUIArea newArea = new GUIArea();
  26. Internal_CreateInstance(newArea, parent, x, y, width, height, depth);
  27. newArea._layout = new GUILayoutX(newArea);
  28. return newArea;
  29. }
  30. internal static GUIArea CreateResizableX(GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop, int height, short depth)
  31. {
  32. GUIArea newArea = new GUIArea();
  33. Internal_CreateInstanceResizableX(newArea, parent, offsetLeft, offsetRight, offsetTop, height, depth);
  34. newArea._layout = new GUILayoutX(newArea);
  35. return newArea;
  36. }
  37. internal static GUIArea CreateResizableY(GUIPanel parent, int offsetTop, int offsetBottom, int offsetLeft, int width, short depth)
  38. {
  39. GUIArea newArea = new GUIArea();
  40. Internal_CreateInstanceResizableY(newArea, parent, offsetTop, offsetBottom, offsetLeft, width, depth);
  41. newArea._layout = new GUILayoutX(newArea);
  42. return newArea;
  43. }
  44. internal static GUIArea CreateResizableXY(GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, short depth)
  45. {
  46. GUIArea newArea = new GUIArea();
  47. Internal_CreateInstanceResizableXY(newArea, parent, offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
  48. newArea._layout = new GUILayoutX(newArea);
  49. return newArea;
  50. }
  51. public void SetArea(int x, int y, int width, int height, short depth = 0)
  52. {
  53. // TODO
  54. }
  55. public void SetVisible(bool visible)
  56. {
  57. Internal_SetVisible(mCachedPtr, visible);
  58. }
  59. public bool IsDestroyed()
  60. {
  61. return isDestroyed;
  62. }
  63. public void Destroy()
  64. {
  65. SetParent(null);
  66. _layout.Destroy();
  67. isDestroyed = true;
  68. Internal_Destroy(mCachedPtr);
  69. }
  70. [MethodImpl(MethodImplOptions.InternalCall)]
  71. private static extern void Internal_CreateInstance(GUIArea instance, GUIPanel parent, int x, int y, int width, int height, short depth);
  72. [MethodImpl(MethodImplOptions.InternalCall)]
  73. private static extern void Internal_CreateInstanceResizableX(GUIArea instance, GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop,
  74. int height, short depth);
  75. [MethodImpl(MethodImplOptions.InternalCall)]
  76. private static extern void Internal_CreateInstanceResizableY(GUIArea instance, GUIPanel parent, int offsetTop, int offsetBottom, int offsetLeft,
  77. int width, short depth);
  78. [MethodImpl(MethodImplOptions.InternalCall)]
  79. private static extern void Internal_CreateInstanceResizableXY(GUIArea instance, GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop,
  80. int offsetBottom, short depth);
  81. [MethodImpl(MethodImplOptions.InternalCall)]
  82. private static extern void Internal_Destroy(IntPtr nativeInstance);
  83. [MethodImpl(MethodImplOptions.InternalCall)]
  84. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  85. }
  86. }