BsGUIWindowDropArea.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "BsGUIWindowDropArea.h"
  2. #include "BsCoreApplication.h"
  3. #include "BsTexture.h"
  4. #include "BsGUIWidget.h"
  5. #include "BsGUISkin.h"
  6. #include "BsSpriteTexture.h"
  7. #include "BsGUIDimensions.h"
  8. #include "BsGUIMouseEvent.h"
  9. namespace BansheeEngine
  10. {
  11. const String& GUIWindowDropArea::getGUITypeName()
  12. {
  13. static String name = "WindowDropArea";
  14. return name;
  15. }
  16. GUIWindowDropArea::GUIWindowDropArea(const String& styleName, const GUIDimensions& dimensions)
  17. :GUITexture(styleName, HSpriteTexture(), GUIImageScaleMode::ScaleToFit, true, dimensions)
  18. { }
  19. GUIWindowDropArea::~GUIWindowDropArea()
  20. { }
  21. GUIWindowDropArea* GUIWindowDropArea::create(const String& styleName)
  22. {
  23. return new (bs_alloc<GUIWindowDropArea, PoolAlloc>())
  24. GUIWindowDropArea(getStyleName<GUIWindowDropArea>(styleName), GUIDimensions::create());
  25. }
  26. GUIWindowDropArea* GUIWindowDropArea::create(const GUIOptions& options, const String& styleName)
  27. {
  28. return new (bs_alloc<GUIWindowDropArea, PoolAlloc>())
  29. GUIWindowDropArea(getStyleName<GUIWindowDropArea>(styleName), GUIDimensions::create(options));
  30. }
  31. void GUIWindowDropArea::setFocused(bool focused)
  32. {
  33. if(focused)
  34. mActiveTexture = _getStyle()->focused.texture;
  35. else
  36. mActiveTexture = _getStyle()->normal.texture;
  37. _markContentAsDirty();
  38. }
  39. bool GUIWindowDropArea::_mouseEvent(const GUIMouseEvent& ev)
  40. {
  41. if(ev.getType() == GUIMouseEventType::MouseDragAndDropDropped)
  42. {
  43. if(!onDraggedItemDropped.empty())
  44. onDraggedItemDropped();
  45. return true;
  46. }
  47. return false;
  48. }
  49. }