GUIArea.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 GUIBase parent;
  9. private bool isDestroyed;
  10. public GUILayout layout
  11. {
  12. get { return _layout;}
  13. }
  14. internal GUIArea()
  15. { }
  16. internal void SetParent(GUIBase 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(GUIBase 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(GUIBase 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(GUIBase 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(GUIBase 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 SetVisible(bool visible)
  52. {
  53. Internal_SetVisible(mCachedPtr, visible);
  54. }
  55. public bool IsDestroyed()
  56. {
  57. return isDestroyed;
  58. }
  59. public void Destroy()
  60. {
  61. SetParent(null);
  62. _layout.Destroy();
  63. isDestroyed = true;
  64. Internal_Destroy(mCachedPtr);
  65. }
  66. [MethodImpl(MethodImplOptions.InternalCall)]
  67. private static extern void Internal_CreateInstance(GUIArea instance, GUIBase parent, int x, int y, int width, int height, short depth);
  68. [MethodImpl(MethodImplOptions.InternalCall)]
  69. private static extern void Internal_CreateInstanceResizableX(GUIArea instance, GUIBase parent, int offsetLeft, int offsetRight, int offsetTop,
  70. int height, short depth);
  71. [MethodImpl(MethodImplOptions.InternalCall)]
  72. private static extern void Internal_CreateInstanceResizableY(GUIArea instance, GUIBase parent, int offsetTop, int offsetBottom, int offsetLeft,
  73. int width, short depth);
  74. [MethodImpl(MethodImplOptions.InternalCall)]
  75. private static extern void Internal_CreateInstanceResizableXY(GUIArea instance, GUIBase parent, int offsetLeft, int offsetRight, int offsetTop,
  76. int offsetBottom, short depth);
  77. [MethodImpl(MethodImplOptions.InternalCall)]
  78. private static extern void Internal_Destroy(IntPtr nativeInstance);
  79. [MethodImpl(MethodImplOptions.InternalCall)]
  80. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  81. }
  82. }