GUIScrollArea.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public enum ScrollBarType
  6. {
  7. ShowIfDoesntFit,
  8. AlwaysShow,
  9. NeverShow
  10. };
  11. public sealed class GUIScrollArea : GUIElement
  12. {
  13. private GUILayout _mainLayout;
  14. public GUILayout Layout
  15. {
  16. get { return _mainLayout; }
  17. }
  18. public float HorizontalScroll
  19. {
  20. get { return Internal_GetHorzScroll(mCachedPtr); }
  21. set { Internal_SetHorzScroll(mCachedPtr, value); }
  22. }
  23. public float VerticalScroll
  24. {
  25. get { return Internal_GetVertScroll(mCachedPtr); }
  26. set { Internal_SetVertScroll(mCachedPtr, value); }
  27. }
  28. public Rect2I ContentBounds
  29. {
  30. get { return Internal_GetContentBounds(mCachedPtr); }
  31. }
  32. public int ScrollBarWidth
  33. {
  34. get { return Internal_GetScrollBarWidth(mCachedPtr); }
  35. }
  36. public GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, string scrollBarStyle,
  37. string scrollAreaStyle, params GUIOption[] options)
  38. {
  39. Internal_CreateInstance(this, vertBarType, horzBarType, scrollBarStyle, scrollAreaStyle, options);
  40. _mainLayout = new GUILayoutY(this);
  41. }
  42. public GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, string style, params GUIOption[] options)
  43. {
  44. Internal_CreateInstance(this, vertBarType, horzBarType, "", style, options);
  45. _mainLayout = new GUILayoutY(this);
  46. }
  47. public GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, params GUIOption[] options)
  48. {
  49. Internal_CreateInstance(this, vertBarType, horzBarType, "", "", options);
  50. _mainLayout = new GUILayoutY(this);
  51. }
  52. public GUIScrollArea(string style, params GUIOption[] options)
  53. {
  54. Internal_CreateInstance(this, ScrollBarType.ShowIfDoesntFit, ScrollBarType.ShowIfDoesntFit, "", style, options);
  55. _mainLayout = new GUILayoutY(this);
  56. }
  57. public GUIScrollArea(params GUIOption[] options)
  58. {
  59. Internal_CreateInstance(this, ScrollBarType.ShowIfDoesntFit, ScrollBarType.ShowIfDoesntFit, "", "", options);
  60. _mainLayout = new GUILayoutY(this);
  61. }
  62. public GUIScrollArea(string scrollBarStyle, string scrollAreaStyle, params GUIOption[] options)
  63. {
  64. Internal_CreateInstance(this, ScrollBarType.ShowIfDoesntFit, ScrollBarType.ShowIfDoesntFit, scrollBarStyle, scrollAreaStyle, options);
  65. _mainLayout = new GUILayoutY(this);
  66. }
  67. public override void Destroy()
  68. {
  69. _mainLayout.Destroy();
  70. base.Destroy();
  71. }
  72. [MethodImpl(MethodImplOptions.InternalCall)]
  73. private static extern void Internal_CreateInstance(GUIScrollArea instance, ScrollBarType vertBarType, ScrollBarType horzBarType,
  74. string scrollBarStyle, string scrollAreaStyle, params GUIOption[] options);
  75. [MethodImpl(MethodImplOptions.InternalCall)]
  76. private static extern Rect2I Internal_GetContentBounds(IntPtr nativeInstance);
  77. [MethodImpl(MethodImplOptions.InternalCall)]
  78. private static extern float Internal_GetHorzScroll(IntPtr nativeInstance);
  79. [MethodImpl(MethodImplOptions.InternalCall)]
  80. private static extern void Internal_SetHorzScroll(IntPtr nativeInstance, float value);
  81. [MethodImpl(MethodImplOptions.InternalCall)]
  82. private static extern float Internal_GetVertScroll(IntPtr nativeInstance);
  83. [MethodImpl(MethodImplOptions.InternalCall)]
  84. private static extern void Internal_SetVertScroll(IntPtr nativeInstance, float value);
  85. [MethodImpl(MethodImplOptions.InternalCall)]
  86. private static extern int Internal_GetScrollBarWidth(IntPtr nativeInstance);
  87. }
  88. }