BsGUIWindowDropArea.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
  19. :GUITexture(parent, style, nullptr, GUIImageScaleMode::ScaleToFit, layoutOptions)
  20. { }
  21. GUIWindowDropArea::~GUIWindowDropArea()
  22. { }
  23. GUIWindowDropArea* GUIWindowDropArea::create(GUIWidget& parent, const GUIElementStyle* style)
  24. {
  25. if(style == nullptr)
  26. {
  27. const GUISkin& skin = parent.getSkin();
  28. style = skin.getStyle(getGUITypeName());
  29. }
  30. return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(parent, style, getDefaultLayoutOptions(style));
  31. }
  32. GUIWindowDropArea* GUIWindowDropArea::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
  33. {
  34. if(style == nullptr)
  35. {
  36. const GUISkin& skin = parent.getSkin();
  37. style = skin.getStyle(getGUITypeName());
  38. }
  39. return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(parent, style, layoutOptions);
  40. }
  41. void GUIWindowDropArea::setFocused(bool focused)
  42. {
  43. if(focused)
  44. mDesc.texture = mStyle->focused.texture;
  45. else
  46. mDesc.texture = mStyle->normal.texture;
  47. markContentAsDirty();
  48. }
  49. bool GUIWindowDropArea::mouseEvent(const GUIMouseEvent& ev)
  50. {
  51. if(ev.getType() == GUIMouseEventType::MouseDragAndDropDropped)
  52. {
  53. if(!onDraggedItemDropped.empty())
  54. onDraggedItemDropped();
  55. return true;
  56. }
  57. return false;
  58. }
  59. }