//
// Created by sfd on 25-5-12.
//

#ifndef ORTHOGRAPHICCAMERACONTROLLER_H
#define ORTHOGRAPHICCAMERACONTROLLER_H

#include <SDL3/SDL_events.h>

#include "Hazel/Core/Core.h"
#include "Hazel/Core/TimeStep.h"
#include "Hazel/Renderer/OrthographicCamera.h"



namespace Hazel
{

    struct OrthographicCameraBounds
    {
        float left, right, bottom, top;
        float GetWidth() const { return right - left; }
        float GetHeight() const { return top - bottom; }
    };

    class HAZEL_API OrthographicCameraController
    {
    public:
        OrthographicCameraController(float aspectRatio, bool isRotation = false);
        void SetProjection(float left, float right, float bottom, float top);

        void OnResize(const float width, const float height);

        void OnUpdate(TimeStep ts);
        void OnEvent(SDL_Event& e);

        void CalculateView();

        void SetZoomLevel(const float level) {m_ZoomLevel = level; CalculateView();}
        float GetZoomLevel() const {return m_ZoomLevel;}

        OrthographicCamera& GetCamera() {return m_Camera;}
        const OrthographicCamera& GetCamera() const {return m_Camera;}

        const OrthographicCameraBounds& GetBounds() const {return m_Bounds;}

    private:
        bool OnMouseScrolled(SDL_Event& e);
        bool OnWindowResized(SDL_Event& e);

    private:
        float m_AspectRatio;
        float m_ZoomLevel = 1.0f;
        bool m_isRotation;

        OrthographicCameraBounds m_Bounds;
        OrthographicCamera m_Camera;

        glm::vec3 m_CameraPosition = { 0.0f, 0.0f, 0.0f };
        float m_CameraRotation = 0.0f;
        float m_CameraTranslationSpeed = 20.0f, m_CameraRotationSpeed = 30.0f;
    };
}


#endif //ORTHOGRAPHICCAMERACONTROLLER_H
