BsGUIWindowDropArea.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
  19. :GUITexture(style, HSpriteTexture(), GUIImageScaleMode::ScaleToFit, layoutOptions)
  20. { }
  21. GUIWindowDropArea::~GUIWindowDropArea()
  22. { }
  23. GUIWindowDropArea* GUIWindowDropArea::create(const GUIElementStyle* style)
  24. {
  25. return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(style, GUILayoutOptions::create(style));
  26. }
  27. GUIWindowDropArea* GUIWindowDropArea::create(const GUIOptions& layoutOptions, const GUIElementStyle* style)
  28. {
  29. return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(style, GUILayoutOptions::create(layoutOptions, style));
  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. }