BsGUIHoverHitBox.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "GUI/BsGUIHoverHitBox.h"
  4. #include "GUI/BsGUIMouseEvent.h"
  5. namespace bs
  6. {
  7. const String& GUIHoverHitBox::getGUITypeName()
  8. {
  9. static String name = "HoverHitBox";
  10. return name;
  11. }
  12. GUIHoverHitBox* GUIHoverHitBox::create()
  13. {
  14. return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create());
  15. }
  16. GUIHoverHitBox* GUIHoverHitBox::create(const GUIOptions& options)
  17. {
  18. return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create(options));
  19. }
  20. GUIHoverHitBox::GUIHoverHitBox(const GUIDimensions& dimensions)
  21. :GUIElementContainer(dimensions)
  22. {
  23. }
  24. void GUIHoverHitBox::updateClippedBounds()
  25. {
  26. mClippedBounds = mLayoutData.area;
  27. }
  28. bool GUIHoverHitBox::_mouseEvent(const GUIMouseEvent& ev)
  29. {
  30. bool processed = GUIElementContainer::_mouseEvent(ev);
  31. if (ev.getType() == GUIMouseEventType::MouseOver)
  32. {
  33. onHover();
  34. return false;
  35. }
  36. else if (ev.getType() == GUIMouseEventType::MouseOut)
  37. {
  38. onOut();
  39. return false;
  40. }
  41. return processed;
  42. }
  43. };