GUIArea.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. if(parent != null)
  22. parent.childAreas.Add(this);
  23. }
  24. internal static GUIArea Create(GUIPanel parent, int x, int y, int width, int height, short depth)
  25. {
  26. GUIArea newArea = new GUIArea();
  27. Internal_CreateInstance(newArea, parent, x, y, width, height, depth);
  28. newArea._layout = new GUILayoutX(newArea);
  29. return newArea;
  30. }
  31. public void SetArea(int x, int y, int width, int height, short depth = 0)
  32. {
  33. Internal_SetArea(mCachedPtr, x, y, width, height, depth);
  34. }
  35. public void SetVisible(bool visible)
  36. {
  37. Internal_SetVisible(mCachedPtr, visible);
  38. }
  39. public bool IsDestroyed()
  40. {
  41. return isDestroyed;
  42. }
  43. public void Destroy()
  44. {
  45. SetParent(null);
  46. _layout.Destroy();
  47. isDestroyed = true;
  48. Internal_Destroy(mCachedPtr);
  49. }
  50. [MethodImpl(MethodImplOptions.InternalCall)]
  51. private static extern void Internal_CreateInstance(GUIArea instance, GUIPanel parent, int x, int y, int width, int height, short depth);
  52. [MethodImpl(MethodImplOptions.InternalCall)]
  53. private static extern void Internal_SetArea(IntPtr nativeInstance, int x, int y, int width, int height, short depth);
  54. [MethodImpl(MethodImplOptions.InternalCall)]
  55. private static extern void Internal_Destroy(IntPtr nativeInstance);
  56. [MethodImpl(MethodImplOptions.InternalCall)]
  57. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  58. }
  59. }