BsGUIHoverHitBox.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "BsGUIHoverHitBox.h"
  2. #include "BsGUIMouseEvent.h"
  3. namespace BansheeEngine
  4. {
  5. const String& GUIHoverHitBox::getGUITypeName()
  6. {
  7. static String name = "HoverHitBox";
  8. return name;
  9. }
  10. GUIHoverHitBox* GUIHoverHitBox::create()
  11. {
  12. return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create());
  13. }
  14. GUIHoverHitBox* GUIHoverHitBox::create(const GUIOptions& options)
  15. {
  16. return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create(options));
  17. }
  18. GUIHoverHitBox::GUIHoverHitBox(const GUIDimensions& dimensions)
  19. :GUIElementContainer(dimensions)
  20. {
  21. }
  22. void GUIHoverHitBox::updateClippedBounds()
  23. {
  24. mClippedBounds = mLayoutData.area;
  25. }
  26. bool GUIHoverHitBox::_mouseEvent(const GUIMouseEvent& ev)
  27. {
  28. bool processed = GUIElementContainer::_mouseEvent(ev);
  29. if (ev.getType() == GUIMouseEventType::MouseOver)
  30. {
  31. onHover();
  32. return false;
  33. }
  34. else if (ev.getType() == GUIMouseEventType::MouseOut)
  35. {
  36. onOut();
  37. return false;
  38. }
  39. return processed;
  40. }
  41. };