BsGUIScrollArea.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "BsGUIElement.h"
  4. namespace BansheeEngine
  5. {
  6. enum class ScrollBarType
  7. {
  8. ShowIfDoesntFit,
  9. AlwaysShow,
  10. NeverShow
  11. };
  12. class BS_EXPORT GUIScrollArea : public GUIElement
  13. {
  14. public:
  15. static const CM::String& getGUITypeName();
  16. static GUIScrollArea* create(GUIWidget& parent, ScrollBarType vertBarType, ScrollBarType horzBarType,
  17. const GUIElementStyle* scrollBarStyle = nullptr, const GUIElementStyle* scrollAreaStyle = nullptr);
  18. static GUIScrollArea* create(GUIWidget& parent, ScrollBarType vertBarType, ScrollBarType horzBarType,
  19. const GUIOptions& layoutOptions, const GUIElementStyle* scrollBarStyle = nullptr,
  20. const GUIElementStyle* scrollAreaStyle = nullptr);
  21. static GUIScrollArea* create(GUIWidget& parent, const GUIElementStyle* scrollBarStyle = nullptr, const GUIElementStyle* scrollAreaStyle = nullptr);
  22. static GUIScrollArea* create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* scrollBarStyle = nullptr,
  23. const GUIElementStyle* scrollAreaStyle = nullptr);
  24. GUILayout& getLayout() const { return *mContentLayout; }
  25. virtual CM::Vector2I _getOptimalSize() const;
  26. protected:
  27. ~GUIScrollArea();
  28. /**
  29. * @copydoc GUIElement::getNumRenderElements()
  30. */
  31. virtual CM::UINT32 getNumRenderElements() const;
  32. /**
  33. * @copydoc GUIElement::getMaterial()
  34. */
  35. virtual const GUIMaterialInfo& getMaterial(CM::UINT32 renderElementIdx) const;
  36. /**
  37. * @copydoc GUIElement::getNumQuads()
  38. */
  39. virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
  40. /**
  41. * @copydoc GUIElement::fillBuffer()
  42. */
  43. virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad,
  44. CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
  45. /**
  46. * @copydoc GUIElement::updateBounds()
  47. */
  48. virtual void updateClippedBounds();
  49. private:
  50. GUIScrollArea(GUIWidget& parent, ScrollBarType vertBarType, ScrollBarType horzBarType,
  51. const GUIElementStyle* scrollBarStyle, const GUIElementStyle* scrollAreaStyle, const GUILayoutOptions& layoutOptions);
  52. ScrollBarType mVertBarType;
  53. ScrollBarType mHorzBarType;
  54. const GUIElementStyle* mScrollBarStyle;
  55. GUILayout* mContentLayout;
  56. GUIScrollBarVert* mVertScroll;
  57. GUIScrollBarHorz* mHorzScroll;
  58. float mVertOffset;
  59. float mHorzOffset;
  60. CM::UINT32 mClippedContentWidth, mClippedContentHeight;
  61. CM::UINT32 mContentWidth, mContentHeight;
  62. static const CM::UINT32 ScrollBarWidth;
  63. static const CM::UINT32 MinHandleSize;
  64. static const CM::UINT32 WheelScrollAmount;
  65. virtual bool mouseEvent(const GUIMouseEvent& ev);
  66. void vertScrollUpdate(float pct);
  67. void horzScrollUpdate(float pct);
  68. void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
  69. CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
  70. virtual void _changeParentWidget(GUIWidget* widget);
  71. };
  72. }