GUILayout.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. namespace BansheeEngine
  5. {
  6. public abstract class GUILayout : GUIElement
  7. {
  8. public void AddElement(GUIElement element)
  9. {
  10. if(element != null)
  11. Internal_AddElement(mCachedPtr, element.mCachedPtr);
  12. }
  13. public void InsertElement(int index, GUIElement element)
  14. {
  15. if (element != null)
  16. Internal_InsertElement(mCachedPtr, index, element.mCachedPtr);
  17. }
  18. public int GetNumChildren()
  19. {
  20. return Internal_GetChildCount(mCachedPtr);
  21. }
  22. public GUIElement GetChild(int index)
  23. {
  24. return Internal_GetChild(mCachedPtr, index);
  25. }
  26. public GUILayoutX AddLayoutX(params GUIOption[] options)
  27. {
  28. GUILayoutX layout = new GUILayoutX(options);
  29. AddElement(layout);
  30. return layout;
  31. }
  32. public GUILayoutY AddLayoutY(params GUIOption[] options)
  33. {
  34. GUILayoutY layout = new GUILayoutY(options);
  35. AddElement(layout);
  36. return layout;
  37. }
  38. public GUIPanel AddPanel(params GUIOption[] options)
  39. {
  40. GUIPanel layout = new GUIPanel(options);
  41. AddElement(layout);
  42. return layout;
  43. }
  44. public GUIPanel AddPanel(Int16 depth = 0, ushort depthRangeMin = ushort.MaxValue, ushort depthRangeMax = ushort.MaxValue, params GUIOption[] options)
  45. {
  46. GUIPanel layout = new GUIPanel(depth, depthRangeMin, depthRangeMax, options);
  47. AddElement(layout);
  48. return layout;
  49. }
  50. public GUIFlexibleSpace AddFlexibleSpace()
  51. {
  52. GUIFlexibleSpace space = new GUIFlexibleSpace();
  53. AddElement(space);
  54. return space;
  55. }
  56. public GUIFixedSpace AddSpace(int size)
  57. {
  58. GUIFixedSpace space = new GUIFixedSpace(size);
  59. AddElement(space);
  60. return space;
  61. }
  62. public GUILayoutX InsertLayoutX(int idx, params GUIOption[] options)
  63. {
  64. GUILayoutX layout = new GUILayoutX(options);
  65. InsertElement(idx, layout);
  66. return layout;
  67. }
  68. public GUILayoutY InsertLayoutY(int idx, params GUIOption[] options)
  69. {
  70. GUILayoutY layout = new GUILayoutY(options);
  71. InsertElement(idx, layout);
  72. return layout;
  73. }
  74. public GUIPanel InsertPanel(int idx, params GUIOption[] options)
  75. {
  76. GUIPanel layout = new GUIPanel(options);
  77. InsertElement(idx, layout);
  78. return layout;
  79. }
  80. public GUIPanel InsertPanel(int idx, Int16 depth = 0, ushort depthRangeMin = ushort.MaxValue,
  81. ushort depthRangeMax = ushort.MaxValue, params GUIOption[] options)
  82. {
  83. GUIPanel layout = new GUIPanel(depth, depthRangeMin, depthRangeMax, options);
  84. InsertElement(idx, layout);
  85. return layout;
  86. }
  87. public GUIFlexibleSpace InsertFlexibleSpace(int idx)
  88. {
  89. GUIFlexibleSpace space = new GUIFlexibleSpace();
  90. InsertElement(idx, space);
  91. return space;
  92. }
  93. public GUIFixedSpace InsertSpace(int idx, int size)
  94. {
  95. GUIFixedSpace space = new GUIFixedSpace(size);
  96. InsertElement(idx, space);
  97. return space;
  98. }
  99. [MethodImpl(MethodImplOptions.InternalCall)]
  100. protected static extern void Internal_CreateInstanceYFromScrollArea(GUILayout instance, GUIScrollArea parentArea);
  101. [MethodImpl(MethodImplOptions.InternalCall)]
  102. protected static extern void Internal_CreateInstanceX(GUILayout instance, GUIOption[] options);
  103. [MethodImpl(MethodImplOptions.InternalCall)]
  104. protected static extern void Internal_CreateInstanceY(GUILayout instance, GUIOption[] options);
  105. [MethodImpl(MethodImplOptions.InternalCall)]
  106. protected static extern void Internal_CreateInstancePanel(GUILayout instance, Int16 depth, ushort depthRangeMin, ushort depthRangeMax, GUIOption[] options);
  107. [MethodImpl(MethodImplOptions.InternalCall)]
  108. protected static extern void Internal_AddElement(IntPtr instance, IntPtr element);
  109. [MethodImpl(MethodImplOptions.InternalCall)]
  110. protected static extern void Internal_InsertElement(IntPtr instance, int index, IntPtr element);
  111. [MethodImpl(MethodImplOptions.InternalCall)]
  112. protected static extern int Internal_GetChildCount(IntPtr instance);
  113. [MethodImpl(MethodImplOptions.InternalCall)]
  114. protected static extern GUIElement Internal_GetChild(IntPtr instance, int index);
  115. }
  116. }