BsGUIInputSelection.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "BsGUIInputTool.h"
  4. #include "BsTextSprite.h"
  5. namespace BansheeEngine
  6. {
  7. enum class SelectionDir
  8. {
  9. Left,
  10. Right
  11. };
  12. class BS_EXPORT GUIInputSelection : public GUIInputTool
  13. {
  14. public:
  15. GUIInputSelection(const TEXT_SPRITE_DESC& textDesc, const CM::Int2& offset, const CM::Int2 clipOffset);
  16. ~GUIInputSelection();
  17. const CM::Vector<ImageSprite*>::type& getSprites() const { return mSprites; }
  18. CM::Int2 GUIInputSelection::getSelectionSpriteOffset(CM::UINT32 spriteIdx) const;
  19. CM::Rect GUIInputSelection::getSelectionSpriteClipRect(CM::UINT32 spriteIdx) const;
  20. void updateSprite();
  21. void showSelection(CM::UINT32 anchorCaretPos, SelectionDir dir);
  22. void clearSelection();
  23. void moveSelectionToCaret(CM::UINT32 caretPos);
  24. bool isSelectionEmpty() const;
  25. void selectAll();
  26. void selectionDragStart(CM::UINT32 caretPos);
  27. void selectionDragUpdate(CM::UINT32 caretPos);
  28. void selectionDragEnd();
  29. CM::UINT32 getSelectionStart() const { return mSelectionStart; }
  30. CM::UINT32 getSelectionEnd() const { return mSelectionEnd; }
  31. private:
  32. CM::UINT32 mSelectionStart;
  33. CM::UINT32 mSelectionEnd;
  34. CM::UINT32 mSelectionAnchor;
  35. CM::UINT32 mSelectionDragAnchor;
  36. CM::Vector<CM::Rect>::type mSelectionRects;
  37. CM::Vector<ImageSprite*>::type mSprites;
  38. CM::UINT32 caretPosToSelectionChar(CM::UINT32 caretPos, SelectionDir dir) const;
  39. CM::Vector<CM::Rect>::type getSelectionRects() const;
  40. bool isNewlineChar(CM::UINT32 charIdx) const;
  41. };
  42. }