BsGUIDropButton.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "GUI/BsGUIButtonBase.h"
  6. #include "GUI/BsGUIToggleGroup.h"
  7. #include "2D/BsImageSprite.h"
  8. #include "2D/BsTextSprite.h"
  9. #include "GUI/BsGUIContent.h"
  10. #include "Utility/BsEvent.h"
  11. namespace bs
  12. {
  13. /** @addtogroup GUI-Editor
  14. * @{
  15. */
  16. /**
  17. * GUI element that accepts a drag and drop operation of a specified type.
  18. *
  19. * @see DragAndDropManager
  20. */
  21. class BS_ED_EXPORT GUIDropButton : public GUIButtonBase
  22. {
  23. public:
  24. /** Returns type name of the GUI element used for finding GUI element styles. */
  25. static const String& getGUITypeName();
  26. /**
  27. * Creates a new GUI drop button element.
  28. *
  29. * @param[in] dragType Identifier of the drag operation to accept.
  30. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  31. * GUIWidget the element is used on. If not specified default style is used.
  32. */
  33. static GUIDropButton* create(UINT32 dragType, const String& styleName = StringUtil::BLANK);
  34. /**
  35. * Creates a new GUI drop button element.
  36. *
  37. * @param[in] dragType Identifier of the drag operation to accept.
  38. * @param[in] options Options that allow you to control how is the element positioned and sized. This will
  39. * override any similar options set by style.
  40. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  41. * GUIWidget the element is used on. If not specified default style is used.
  42. */
  43. static GUIDropButton* create(UINT32 dragType, const GUIOptions& options,
  44. const String& styleName = StringUtil::BLANK);
  45. /** Triggered when drag and drop operation finishes while over the button and is of the correct type. */
  46. Event<void(void*)> onDataDropped;
  47. protected:
  48. virtual ~GUIDropButton() = default;
  49. protected:
  50. GUIDropButton(UINT32 dragType, const String& styleName, const GUIDimensions& dimensions);
  51. /** @copydoc GUIButtonBase::_mouseEvent */
  52. bool _mouseEvent(const GUIMouseEvent& ev) override;
  53. /** @copydoc GUIButtonBase::_acceptDragAndDrop */
  54. bool _acceptDragAndDrop(const Vector2I position, UINT32 typeId) const override;
  55. UINT32 mDragType;
  56. };
  57. /** @} */
  58. }