InterfaceEventDispatcher.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * CGuiHandler.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. VCMI_LIB_NAMESPACE_BEGIN
  12. class Point;
  13. VCMI_LIB_NAMESPACE_END
  14. class AEventsReceiver;
  15. enum class MouseButton;
  16. enum class EShortcut;
  17. class InterfaceEventDispatcher
  18. {
  19. using CIntObjectList = std::list<AEventsReceiver *>;
  20. //active GUI elements (listening for events
  21. CIntObjectList lclickable;
  22. CIntObjectList rclickable;
  23. CIntObjectList mclickable;
  24. CIntObjectList hoverable;
  25. CIntObjectList keyinterested;
  26. CIntObjectList motioninterested;
  27. CIntObjectList timeinterested;
  28. CIntObjectList wheelInterested;
  29. CIntObjectList doubleClickInterested;
  30. CIntObjectList textInterested;
  31. CIntObjectList & getListForMouseButton(MouseButton button);
  32. void handleMouseButtonClick(CIntObjectList & interestedObjs, MouseButton btn, bool isPressed);
  33. void processList(const ui16 mask, const ui16 flag, CIntObjectList * lst, std::function<void(CIntObjectList *)> cb);
  34. void processLists(ui16 activityFlag, std::function<void(CIntObjectList *)> cb);
  35. public:
  36. void handleElementActivate(AEventsReceiver * elem, ui16 activityFlag);
  37. void handleElementDeActivate(AEventsReceiver * elem, ui16 activityFlag);
  38. void updateTime(uint32_t msPassed); //handles timeInterested
  39. void dispatchShortcutPressed(const std::vector<EShortcut> & shortcuts);
  40. void dispatchShortcutReleased(const std::vector<EShortcut> & shortcuts);
  41. void dispatchMouseButtonPressed(const MouseButton & button, const Point & position);
  42. void dispatchMouseButtonReleased(const MouseButton & button, const Point & position);
  43. void dispatchMouseScrolled(const Point & distance, const Point & position);
  44. void dispatchMouseMoved(const Point & position);
  45. void dispatchTextInput(const std::string & text);
  46. void dispatchTextEditing(const std::string & text);
  47. };