BsPlatform.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Platform/BsPlatform.h"
  4. namespace bs
  5. {
  6. OSDropTarget::OSDropTarget(const RenderWindow* ownerWindow, INT32 x, INT32 y, UINT32 width, UINT32 height)
  7. :mX(x), mY(y), mWidth(width), mHeight(height), mActive(false), mOwnerWindow(ownerWindow),
  8. mDropType(OSDropType::None), mFileList(nullptr)
  9. {
  10. }
  11. OSDropTarget::~OSDropTarget()
  12. {
  13. _clear();
  14. }
  15. void OSDropTarget::setArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
  16. {
  17. mX = x;
  18. mY = y;
  19. mWidth = width;
  20. mHeight = height;
  21. }
  22. void OSDropTarget::_clear()
  23. {
  24. if(mFileList != nullptr)
  25. {
  26. bs_delete(mFileList);
  27. mFileList = nullptr;
  28. }
  29. }
  30. bool OSDropTarget::_isInside(const Vector2I& pos) const
  31. {
  32. INT32 right = mX + mWidth;
  33. INT32 bottom = mY + mHeight;
  34. return (pos.x >= mX && pos.x < right && pos.y >= mY && pos.y < bottom);
  35. }
  36. void OSDropTarget::_setFileList(const Vector<WString>& fileList)
  37. {
  38. _clear();
  39. mDropType = OSDropType::FileList;
  40. mFileList = bs_new<Vector<WString>>();
  41. *mFileList = fileList;
  42. }
  43. }