GUILayoutUtility.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. namespace BansheeEngine
  7. {
  8. public class GUILayoutUtility
  9. {
  10. public static Vector2I CalculateOptimalSize(GUIElement element)
  11. {
  12. Vector2I output;
  13. Internal_CalculateOptimalSize(element.GetCachedPtr(), out output);
  14. return output;
  15. }
  16. public static Rect2I CalculateBounds(GUIElement element, GUIPanel relativeTo = null)
  17. {
  18. IntPtr relativeToNative = IntPtr.Zero;
  19. if (relativeTo != null)
  20. relativeToNative = relativeTo.GetCachedPtr();
  21. Rect2I output;
  22. Internal_CalculateBounds(element.GetCachedPtr(), relativeToNative, out output);
  23. return output;
  24. }
  25. [MethodImpl(MethodImplOptions.InternalCall)]
  26. private static extern void Internal_CalculateOptimalSize(IntPtr element, out Vector2I output);
  27. [MethodImpl(MethodImplOptions.InternalCall)]
  28. private static extern void Internal_CalculateBounds(IntPtr element, IntPtr relativeTo, out Rect2I output);
  29. }
  30. }