#pragma once

#include <SDL3/SDL.h>
#include <functional>

namespace quokka_gfx
{
class Application;
//--------------------------------------------------------------
class EventManager
{
  public:
  enum class PollingResult : uint8_t
  {
    Continue = 0,     // Continue processing the event in the next handler
    Quit,             // Quit the event loop, do not process it and stop further processing
  };

  enum class EventResult : uint8_t
  {
    Skip = 0,     // Skip the event, continue processing it in the next handler
    Veto,         // Veto the event, do not process it and stop further processing
  };
  using GlobalEventHandler = std::function<EventResult(SDL_Event &event)>;     // Function type for global event handlers

  public:
  EventManager()                                       = delete;      // Default constructor
  virtual ~EventManager()                              = default;     // Default destructor
  EventManager(const EventManager &obj)                = delete;      // Copy constructor
  EventManager(EventManager &&obj) noexcept            = delete;      // Move constructor
  EventManager &operator=(const EventManager &obj)     = delete;      // Copy assignment operator
  EventManager &operator=(EventManager &&obj) noexcept = delete;      // Move assignment operator

  explicit EventManager(Application &appManager);     // Constructor

  void SetGlobalEventHandler(const GlobalEventHandler &globalEventHandler);     // Set the global event handler function

  PollingResult ProcessEvents() const;     // Poll and process SDL events

  protected:
  Application &m_appManager;     // Reference to the Application instance

  GlobalEventHandler m_globalEventHandler;     // Global event handler function
};
//--------------------------------------------------------------
}     // namespace quokka_gfx
