ModalWindow.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. public class ModalWindow : ScriptObject
  8. {
  9. public int Width
  10. {
  11. get { return Internal_GetWidth(mCachedPtr); }
  12. set { Internal_SetWidth(mCachedPtr, value); }
  13. }
  14. public int Height
  15. {
  16. get { return Internal_GetHeight(mCachedPtr); }
  17. set { Internal_SetHeight(mCachedPtr, value); }
  18. }
  19. protected GUIPanel GUI;
  20. protected ModalWindow()
  21. {
  22. Internal_CreateInstance(this, false);
  23. }
  24. protected ModalWindow(bool allowCloseButton)
  25. {
  26. Internal_CreateInstance(this, allowCloseButton);
  27. }
  28. protected Vector2I ScreenToWindowPos(Vector2I screenPos)
  29. {
  30. Vector2I windowPos;
  31. Internal_ScreenToWindowPos(mCachedPtr, screenPos, out windowPos);
  32. return windowPos;
  33. }
  34. protected Vector2I WindowToScreenPos(Vector2I windowPos)
  35. {
  36. Vector2I screenPos;
  37. Internal_WindowToScreenPos(mCachedPtr, windowPos, out screenPos);
  38. return screenPos;
  39. }
  40. private void OnInitializeInternal()
  41. {
  42. GUI = new GUIPanel();
  43. Internal_InitializeGUIPanel(mCachedPtr, GUI);
  44. GUI.Initialize();
  45. GUI.SetArea(0, 0, Width, Height);
  46. }
  47. private void OnDestroyInternal()
  48. {
  49. GUI.Destroy();
  50. }
  51. protected virtual void OnWindowResized(int width, int height)
  52. {
  53. GUI.SetArea(0, 0, width, height);
  54. }
  55. protected void Close()
  56. {
  57. Internal_Close(mCachedPtr);
  58. }
  59. public LocString Title
  60. {
  61. set { Internal_SetTitle(mCachedPtr, value); }
  62. }
  63. [MethodImpl(MethodImplOptions.InternalCall)]
  64. private static extern void Internal_CreateInstance(ModalWindow instance, bool allowCloseButton);
  65. [MethodImpl(MethodImplOptions.InternalCall)]
  66. private static extern void Internal_Close(IntPtr nativeInstance);
  67. [MethodImpl(MethodImplOptions.InternalCall)]
  68. private static extern void Internal_SetTitle(IntPtr nativeInstance, LocString title);
  69. [MethodImpl(MethodImplOptions.InternalCall)]
  70. private static extern void Internal_InitializeGUIPanel(IntPtr nativeInstance, GUIPanel panel);
  71. [MethodImpl(MethodImplOptions.InternalCall)]
  72. private static extern int Internal_GetWidth(IntPtr nativeInstance);
  73. [MethodImpl(MethodImplOptions.InternalCall)]
  74. private static extern int Internal_SetWidth(IntPtr nativeInstance, int value);
  75. [MethodImpl(MethodImplOptions.InternalCall)]
  76. private static extern int Internal_GetHeight(IntPtr nativeInstance);
  77. [MethodImpl(MethodImplOptions.InternalCall)]
  78. private static extern int Internal_SetHeight(IntPtr nativeInstance, int value);
  79. [MethodImpl(MethodImplOptions.InternalCall)]
  80. private static extern void Internal_ScreenToWindowPos(IntPtr nativeInstance, Vector2I position, out Vector2I windowPos);
  81. [MethodImpl(MethodImplOptions.InternalCall)]
  82. private static extern void Internal_WindowToScreenPos(IntPtr nativeInstance, Vector2I position, out Vector2I screenPos);
  83. }
  84. }