GUIElement.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. namespace BansheeEngine
  5. {
  6. public abstract class GUIElement : ScriptObject
  7. {
  8. protected GUILayout parent;
  9. private bool isDestroyed;
  10. public Rect2I Bounds
  11. {
  12. get { return Internal_GetBounds(mCachedPtr); }
  13. set { Internal_SetBounds(mCachedPtr, value); }
  14. }
  15. public Rect2I VisualBounds
  16. {
  17. get { return Internal_GetVisualBounds(mCachedPtr); }
  18. }
  19. internal virtual void SetParent(GUILayout layout)
  20. {
  21. if (parent != null)
  22. parent.RemoveInternal(this);
  23. parent = layout;
  24. }
  25. internal virtual bool IsStatic()
  26. {
  27. return false;
  28. }
  29. public virtual void Destroy()
  30. {
  31. SetParent(null);
  32. Internal_Destroy(mCachedPtr);
  33. isDestroyed = true;
  34. }
  35. public bool IsDestroyed()
  36. {
  37. return isDestroyed;
  38. }
  39. public void SetVisible(bool visible)
  40. {
  41. Internal_SetVisible(mCachedPtr, visible);
  42. }
  43. public void SetLayoutOptions(params GUIOption[] options)
  44. {
  45. Internal_SetLayoutOptions(mCachedPtr, options);
  46. }
  47. [MethodImpl(MethodImplOptions.InternalCall)]
  48. private static extern void Internal_SetLayoutOptions(IntPtr nativeInstance, GUIOption[] options);
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern Rect2I Internal_GetBounds(IntPtr nativeInstance);
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. private static extern void Internal_SetBounds(IntPtr nativeInstance, Rect2I value);
  55. [MethodImpl(MethodImplOptions.InternalCall)]
  56. private static extern Rect2I Internal_GetVisualBounds(IntPtr nativeInstance);
  57. [MethodImpl(MethodImplOptions.InternalCall)]
  58. private static extern void Internal_Destroy(IntPtr nativeInstance);
  59. }
  60. }