/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

#include "RenderPass.hpp"
#include "Base/UI/IWindow.hpp"
#include "Scene/UI/UI.hpp"
#include <vulkan/vulkan.hpp>

namespace OpenVulkano::Vulkan
{
	class Context;

	class UiRenderer
	{
		vk::Device device;
		RenderPass uiRenderPass;
		vk::DescriptorPool descriptorPool;
		Scene::UI::Ui* ui;
		IWindow* window = nullptr;
		bool uiInitialized = false;

	public:
		UiRenderer() = default;

		UiRenderer(Context* context) { Init(context); }

		~UiRenderer() { if (uiInitialized) Close(); }

		void Init(Context* context);

		void BeginUiFrame() const;

		void DrawUiFrame(vk::CommandBuffer& cmdBuffer);

		void Close();

		void SetActiveUi(Scene::UI::Ui* ui);

		Scene::UI::Ui* GetActiveUi() { return ui; }
	};
}