BsPlatform.cpp 1.3 KB

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