GUILayout.cs 5.0 KB

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