EditorWindow.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. public class EditorWindow : ScriptObject
  8. {
  9. public int Width { get { return Internal_GetWidth(mCachedPtr); } }
  10. public int Height { get { return Internal_GetHeight(mCachedPtr); } }
  11. public bool HasFocus { get { return Internal_HasFocus(mCachedPtr); } }
  12. protected GUIPanel GUI;
  13. public static T OpenWindow<T>() where T : EditorWindow
  14. {
  15. return (T)Internal_CreateOrGetInstance(typeof(T).Namespace, typeof(T).Name);
  16. }
  17. public Vector2I ScreenToWindowPos(Vector2I screenPos)
  18. {
  19. Vector2I windowPos;
  20. Internal_ScreenToWindowPos(mCachedPtr, screenPos, out windowPos);
  21. return windowPos;
  22. }
  23. public Vector2I WindowToScreenPos(Vector2I windowPos)
  24. {
  25. Vector2I screenPos;
  26. Internal_WindowToScreenPos(mCachedPtr, windowPos, out screenPos);
  27. return screenPos;
  28. }
  29. protected virtual void WindowResized(int width, int height)
  30. {
  31. }
  32. protected virtual void FocusChanged(bool inFocus)
  33. {
  34. }
  35. [MethodImpl(MethodImplOptions.InternalCall)]
  36. private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
  37. [MethodImpl(MethodImplOptions.InternalCall)]
  38. private static extern int Internal_GetWidth(IntPtr nativeInstance);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern int Internal_GetHeight(IntPtr nativeInstance);
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern bool Internal_HasFocus(IntPtr nativeInstance);
  43. [MethodImpl(MethodImplOptions.InternalCall)]
  44. private static extern void Internal_ScreenToWindowPos(IntPtr nativeInstance, Vector2I position, out Vector2I windowPos);
  45. [MethodImpl(MethodImplOptions.InternalCall)]
  46. private static extern void Internal_WindowToScreenPos(IntPtr nativeInstance, Vector2I position, out Vector2I screenPos);
  47. }
  48. }