BsGUIDropButton.h 2.2 KB

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