BsGUIDockSlider.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "BsGUIDockSlider.h"
  2. #include "BsGUIWidget.h"
  3. #include "BsGUISkin.h"
  4. #include "BsGUILayoutOptions.h"
  5. #include "BsGUIMouseEvent.h"
  6. #include "BsGUITabbedTitleBar.h"
  7. #include "BsCursor.h"
  8. #include "CmPlatform.h"
  9. using namespace CamelotFramework;
  10. using namespace BansheeEngine;
  11. namespace BansheeEditor
  12. {
  13. const String& GUIDockSlider::getGUITypeName()
  14. {
  15. static String name = "DockSlider";
  16. return name;
  17. }
  18. GUIDockSlider::GUIDockSlider(bool horizontal, const BS::GUIElementStyle* style, const BS::GUILayoutOptions& layoutOptions)
  19. :GUIButtonBase(style, GUIContent(HString(L"")), layoutOptions),
  20. mDragInProgress(false), mHorizontal(horizontal), mIsCursorSet(false)
  21. {
  22. }
  23. GUIDockSlider* GUIDockSlider::create(bool horizontal, const GUIElementStyle* style)
  24. {
  25. return new (cm_alloc<GUIDockSlider, PoolAlloc>()) GUIDockSlider(horizontal, style, GUILayoutOptions::create(style));
  26. }
  27. GUIDockSlider* GUIDockSlider::create(bool horizontal, const GUIOptions& layoutOptions, const BS::GUIElementStyle* style)
  28. {
  29. return new (cm_alloc<GUIDockSlider, PoolAlloc>()) GUIDockSlider(horizontal, style, GUILayoutOptions::create(layoutOptions, style));
  30. }
  31. bool GUIDockSlider::_hasCustomCursor(const CM::Vector2I position, CursorType& type) const
  32. {
  33. if(_isInBounds(position))
  34. {
  35. type = mHorizontal ? CursorType::SizeNS : CursorType::SizeWE;
  36. return true;
  37. }
  38. return false;
  39. }
  40. bool GUIDockSlider::mouseEvent(const GUIMouseEvent& ev)
  41. {
  42. bool processed = GUIButtonBase::mouseEvent(ev);
  43. if(ev.getType() == GUIMouseEventType::MouseDragStart)
  44. {
  45. mLastDragPosition = ev.getPosition();
  46. mDragInProgress = true;
  47. return true;
  48. }
  49. else if(ev.getType() == GUIMouseEventType::MouseDrag)
  50. {
  51. Vector2I delta = ev.getPosition() - mLastDragPosition;
  52. mLastDragPosition = ev.getPosition();
  53. if(!onDragged.empty())
  54. onDragged(delta);
  55. return true;
  56. }
  57. else if(ev.getType() == GUIMouseEventType::MouseDragEnd)
  58. {
  59. mDragInProgress = false;
  60. return true;
  61. }
  62. return processed;
  63. }
  64. }