BsGUIHoverHitBox.cpp 1.1 KB

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