BsGUIHoverHitBox.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIElementContainer.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * Helper class used for detecting when mousing over a certain
  8. * and getting notified when that state changes.
  9. */
  10. class BS_ED_EXPORT GUIHoverHitBox : public GUIElementContainer
  11. {
  12. public:
  13. /**
  14. * Returns type name of the GUI element used for finding GUI element styles.
  15. */
  16. static const String& getGUITypeName();
  17. /**
  18. * Creates a new hover hit box that will detect mouse hover/out events over certain area.
  19. */
  20. static GUIHoverHitBox* create();
  21. /**
  22. * Creates a new hover hit box that will detect mouse hover/out events over certain area.
  23. */
  24. static GUIHoverHitBox* create(const GUIOptions& options);
  25. /**
  26. * @brief Triggered when pointer hovers over the hit box.
  27. */
  28. Event<void()> onHover;
  29. /**
  30. * @brief Triggered when pointer that was previously hovering leaves the hit box.
  31. */
  32. Event<void()> onOut;
  33. private:
  34. GUIHoverHitBox(const GUIDimensions& dimensions);
  35. /**
  36. * @copydoc GUIElementContainer::updateClippedBounds
  37. */
  38. void updateClippedBounds() override;
  39. /**
  40. * @copydoc GUIElementContainer::_mouseEvent
  41. */
  42. virtual bool _mouseEvent(const GUIMouseEvent& ev) override;
  43. };
  44. }