|
|
@@ -24,6 +24,50 @@ |
|
|
|
|
|
|
|
#include "DearImGui/imgui_impl_opengl2.h" |
|
|
|
|
|
|
|
static const char* GetClipboardTextFn(void*) |
|
|
|
{ |
|
|
|
return glfwGetClipboardString(nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
static void SetClipboardTextFn(void*, const char* const text) |
|
|
|
{ |
|
|
|
glfwSetClipboardString(nullptr, text); |
|
|
|
} |
|
|
|
|
|
|
|
static void setupIO() |
|
|
|
{ |
|
|
|
ImGuiIO& io(ImGui::GetIO()); |
|
|
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; |
|
|
|
io.IniFilename = nullptr; |
|
|
|
io.LogFilename = nullptr; |
|
|
|
|
|
|
|
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; |
|
|
|
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; |
|
|
|
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; |
|
|
|
io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; |
|
|
|
io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; |
|
|
|
io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; |
|
|
|
io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; |
|
|
|
io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; |
|
|
|
io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; |
|
|
|
io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; |
|
|
|
io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; |
|
|
|
io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; |
|
|
|
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; |
|
|
|
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; |
|
|
|
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; |
|
|
|
io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER; |
|
|
|
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; |
|
|
|
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; |
|
|
|
io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; |
|
|
|
io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; |
|
|
|
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; |
|
|
|
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; |
|
|
|
|
|
|
|
io.GetClipboardTextFn = GetClipboardTextFn; |
|
|
|
io.SetClipboardTextFn = SetClipboardTextFn; |
|
|
|
} |
|
|
|
|
|
|
|
struct ImGuiWidget::PrivateData { |
|
|
|
ImGuiContext* context = nullptr; |
|
|
|
bool created = false; |
|
|
@@ -32,52 +76,12 @@ struct ImGuiWidget::PrivateData { |
|
|
|
float originalScaleFactor = 0.0f; |
|
|
|
float scaleFactor = 0.0f; |
|
|
|
|
|
|
|
static const char* GetClipboardTextFn(void*) |
|
|
|
{ |
|
|
|
return glfwGetClipboardString(nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
static void SetClipboardTextFn(void*, const char* const text) |
|
|
|
{ |
|
|
|
glfwSetClipboardString(nullptr, text); |
|
|
|
} |
|
|
|
|
|
|
|
PrivateData() |
|
|
|
{ |
|
|
|
IMGUI_CHECKVERSION(); |
|
|
|
context = ImGui::CreateContext(); |
|
|
|
ImGui::SetCurrentContext(context); |
|
|
|
|
|
|
|
ImGuiIO& io(ImGui::GetIO()); |
|
|
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; |
|
|
|
io.IniFilename = nullptr; |
|
|
|
|
|
|
|
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; |
|
|
|
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; |
|
|
|
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; |
|
|
|
io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; |
|
|
|
io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; |
|
|
|
io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; |
|
|
|
io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; |
|
|
|
io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; |
|
|
|
io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; |
|
|
|
io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; |
|
|
|
io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; |
|
|
|
io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; |
|
|
|
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; |
|
|
|
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; |
|
|
|
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; |
|
|
|
io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER; |
|
|
|
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; |
|
|
|
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; |
|
|
|
io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; |
|
|
|
io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; |
|
|
|
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; |
|
|
|
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; |
|
|
|
|
|
|
|
io.GetClipboardTextFn = GetClipboardTextFn; |
|
|
|
io.SetClipboardTextFn = SetClipboardTextFn; |
|
|
|
io.ClipboardUserData = this; |
|
|
|
setupIO(); |
|
|
|
} |
|
|
|
|
|
|
|
~PrivateData() |
|
|
@@ -368,6 +372,8 @@ void ImGuiWidget::drawFramebufferForBrowserPreview() |
|
|
|
|
|
|
|
imData->context = ImGui::CreateContext(); |
|
|
|
ImGui::SetCurrentContext(imData->context); |
|
|
|
setupIO(); |
|
|
|
|
|
|
|
ImGui_ImplOpenGL2_Init(); |
|
|
|
imData->created = true; |
|
|
|
|
|
|
|