/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <ox/claw/claw.hpp>
#include <ox/event/signal.hpp>
#include <ox/std/string.hpp>

#include <studio/itemmaker.hpp>
#include <studio/popup.hpp>

namespace studio {

class NewProject: public Popup {
	public:
		enum class Stage {
			Closed,
			Opening,
			NewItemName,
		};

		// emits path parameter
		ox::Signal<ox::Error(ox::StringView)> finished;

	private:
		Stage m_stage = Stage::Closed;
		ox::String const m_projectDataDir;
		ox::String m_projectPath;
		ox::IString<255> m_projectName;
		ox::Vector<ox::UPtr<studio::ItemMaker>> m_types;
		bool m_open = false;

	public:
		NewProject(ox::StringParam projectDatadir) noexcept;

		void open() noexcept override;

		void close() noexcept override;

		[[nodiscard]]
		bool isOpen() const noexcept override;

		void draw(studio::Context &ctx) noexcept override;

	private:
		void drawNewProjectName(studio::Context &ctx) noexcept;

		void drawLastPageButtons(studio::Context &ctx) noexcept;

		void finish() noexcept;

};

}
