BsGUIWindowDropArea.cpp 1.7 KB

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