#pragma once
#include "../Window/Window.h"

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

namespace quokka_gfx
{
//--------------------------------------------------------------
class WindowManager
{
  friend class Application;
  friend class EventManager;

  public:
  using WindowList = std::vector<Window *>;     // Vector to store pointers to Window instances

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

  void RegisterWindow(Window *window);     // Register an existing window with the WindowManager
  void CloseWindow(uint32_t windowId);     // Close a window by its SDL window ID
  void CloseWindow(Window *window);        // Close a window by its pointer

  [[nodiscard]] const WindowList &GetWindows() const noexcept;       // Get the vector of windows instances
  [[nodiscard]] bool              HasAnyWindow() const noexcept;     // Check if there are any windows managed by the WindowManager

  protected:
  WindowList m_windows;     // Vector to store unique pointers to windows

  void OnEvent(SDL_Event *event);     // Handle event for all windows
  void Update(float dt) const;        // Update all windows
  void Render() const;                // Render all windows
};
//--------------------------------------------------------------
}     // namespace quokka_gfx
