BsGUIDropButton.h 2.5 KB

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