GUIScrollArea.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, string scrollBarStyle,
  33. string scrollAreaStyle, params GUIOption[] options)
  34. {
  35. Internal_CreateInstance(this, vertBarType, horzBarType, scrollBarStyle, scrollAreaStyle, options);
  36. _mainLayout = new GUILayoutY(this);
  37. }
  38. public GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, string style, params GUIOption[] options)
  39. {
  40. Internal_CreateInstance(this, vertBarType, horzBarType, "", style, options);
  41. _mainLayout = new GUILayoutY(this);
  42. }
  43. public GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, params GUIOption[] options)
  44. {
  45. Internal_CreateInstance(this, vertBarType, horzBarType, "", "", options);
  46. _mainLayout = new GUILayoutY(this);
  47. }
  48. public GUIScrollArea(string style, params GUIOption[] options)
  49. {
  50. Internal_CreateInstance(this, ScrollBarType.ShowIfDoesntFit, ScrollBarType.ShowIfDoesntFit, "", style, options);
  51. _mainLayout = new GUILayoutY(this);
  52. }
  53. public GUIScrollArea(params GUIOption[] options)
  54. {
  55. Internal_CreateInstance(this, ScrollBarType.ShowIfDoesntFit, ScrollBarType.ShowIfDoesntFit, "", "", options);
  56. _mainLayout = new GUILayoutY(this);
  57. }
  58. public GUIScrollArea(string scrollBarStyle, string scrollAreaStyle, params GUIOption[] options)
  59. {
  60. Internal_CreateInstance(this, ScrollBarType.ShowIfDoesntFit, ScrollBarType.ShowIfDoesntFit, scrollBarStyle, scrollAreaStyle, options);
  61. _mainLayout = new GUILayoutY(this);
  62. }
  63. public override void Destroy()
  64. {
  65. _mainLayout.Destroy();
  66. base.Destroy();
  67. }
  68. [MethodImpl(MethodImplOptions.InternalCall)]
  69. private static extern void Internal_CreateInstance(GUIScrollArea instance, ScrollBarType vertBarType, ScrollBarType horzBarType,
  70. string scrollBarStyle, string scrollAreaStyle, params GUIOption[] options);
  71. [MethodImpl(MethodImplOptions.InternalCall)]
  72. private static extern Rect2I Internal_GetContentBounds(IntPtr nativeInstance);
  73. [MethodImpl(MethodImplOptions.InternalCall)]
  74. private static extern float Internal_GetHorzScroll(IntPtr nativeInstance);
  75. [MethodImpl(MethodImplOptions.InternalCall)]
  76. private static extern void Internal_SetHorzScroll(IntPtr nativeInstance, float value);
  77. [MethodImpl(MethodImplOptions.InternalCall)]
  78. private static extern float Internal_GetVertScroll(IntPtr nativeInstance);
  79. [MethodImpl(MethodImplOptions.InternalCall)]
  80. private static extern void Internal_SetVertScroll(IntPtr nativeInstance, float value);
  81. }
  82. }