#include "ImGui_Device.h"

ImGui_Device* ImGui_Device::ImGuiDevice = NULL;

// Functions
static const char* ImGui_DefaultImpl_GetClipboardText(void* data)
{
	if (ImGuiDevice)
		return ImGuiDevice->GetClipboardText(data);
	return NULL;
}

static void ImGui_DefaultImpl_SetClipboardText(void* data, const char* text)
{
	if (ImGuiDevice)
		ImGuiDevice->SetClipboardText(data, text);
}

static void ImGui_DefaultImpl_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{
	if (ImGuiDevice)
		ImGuiDevice->SetPlatformImeData(viewport, data);
}


ImGui_Device::ImGui_Device() {
	if (!ImGuiDevice) {
		IMGUI_CHECKVERSION();
		ImGui::CreateContext();

		ImGuiIO& io = ImGui::GetIO();
		io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;

		io.SetClipboardTextFn = ImGui_DefaultImpl_SetClipboardText;
		io.GetClipboardTextFn = ImGui_DefaultImpl_GetClipboardText;
		io.ClipboardUserData = nullptr;
		io.SetPlatformImeDataFn = ImGui_DefaultImpl_SetPlatformImeData;
	}
}
