BsGUIHoverHitBox.h 1.5 KB

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