mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	Merge branch 'viewport' into docking
# Conflicts: # examples/example_allegro5/main.cpp # examples/example_win32_directx9/main.cpp
This commit is contained in:
		| @@ -55,6 +55,8 @@ Breaking Changes: | ||||
|  | ||||
| - Renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges and removed its [Beta] mark. | ||||
|   The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names. | ||||
| - Made it illegal to call Begin("") with an empty string. This somehow accidentally worked before but had various  | ||||
|   undesirable side-effect as the window would have ID zero. In particular it is causing problems in viewport/docking branches. | ||||
|  | ||||
| Other Changes: | ||||
| - Added BETA api for Tab Bar/Tabs widgets: (#261, #351) | ||||
|   | ||||
| @@ -29,14 +29,13 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;  // Enable Keyboard Controls | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;        // Enable Docking | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
| >>>>>>> viewport | ||||
|     ImGui_ImplAllegro5_Init(display); | ||||
|  | ||||
|     // Setup Style | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplAllegro5_Init(display); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -26,11 +26,9 @@ | ||||
|  | ||||
|         IMGUI_CHECKVERSION(); | ||||
|         ImGui::CreateContext(); | ||||
|         (void)ImGui::GetIO(); | ||||
|          | ||||
|         ImGui_ImplMetal_Init(_device); | ||||
|  | ||||
|         ImGui::StyleColorsDark(); | ||||
|  | ||||
|         ImGui_ImplMetal_Init(_device); | ||||
|     } | ||||
|  | ||||
|     return self; | ||||
|   | ||||
| @@ -244,14 +244,14 @@ | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;     // Enable Keyboard Controls | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;           // Enable Docking | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplOSX_Init(); | ||||
|     ImGui_ImplOpenGL2_Init(); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. | ||||
|   | ||||
| @@ -101,15 +101,15 @@ int main(int argc, char** argv) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;     // Enable Keyboard Controls | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;           // Enable Docking | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplFreeGLUT_Init(); | ||||
|     ImGui_ImplFreeGLUT_InstallFuncs(); | ||||
|     ImGui_ImplOpenGL2_Init(); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -47,14 +47,22 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplGlfw_InitForOpenGL(window, true); | ||||
|     ImGui_ImplOpenGL2_Init(); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
| @@ -141,9 +149,9 @@ int main(int, char**) | ||||
|         { | ||||
|             ImGui::UpdatePlatformWindows(); | ||||
|             ImGui::RenderPlatformWindowsDefault(); | ||||
|             glfwMakeContextCurrent(window); | ||||
|         } | ||||
|  | ||||
|         glfwMakeContextCurrent(window); | ||||
|         glfwSwapBuffers(window); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -93,17 +93,21 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplGlfw_InitForOpenGL(window, true); | ||||
|     ImGui_ImplOpenGL3_Init(glsl_version); | ||||
|  | ||||
|     // Setup Style | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     style.WindowRounding = 0.0f;                                // When viewports are enabled it is preferable to disable WinodwRounding | ||||
|     style.Colors[ImGuiCol_WindowBg].w = 1.0f;                   // When viewports are enabled it is preferable to disable WindowBg alpha | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplGlfw_InitForOpenGL(window, true); | ||||
|     ImGui_ImplOpenGL3_Init(glsl_version); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. | ||||
| @@ -179,7 +183,6 @@ int main(int, char**) | ||||
|         // Rendering | ||||
|         ImGui::Render(); | ||||
|         int display_w, display_h; | ||||
|         glfwMakeContextCurrent(window); | ||||
|         glfwGetFramebufferSize(window, &display_w, &display_h); | ||||
|         glViewport(0, 0, display_w, display_h); | ||||
|         glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); | ||||
| @@ -191,9 +194,9 @@ int main(int, char**) | ||||
|         { | ||||
|             ImGui::UpdatePlatformWindows(); | ||||
|             ImGui::RenderPlatformWindowsDefault(); | ||||
|             glfwMakeContextCurrent(window); | ||||
|         } | ||||
|  | ||||
|         glfwMakeContextCurrent(window); | ||||
|         glfwSwapBuffers(window); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -361,6 +361,18 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplGlfw_InitForVulkan(window, true); | ||||
|     ImGui_ImplVulkan_InitInfo init_info = {}; | ||||
| @@ -375,10 +387,6 @@ int main(int, char**) | ||||
|     init_info.CheckVkResultFn = check_vk_result; | ||||
|     ImGui_ImplVulkan_Init(&init_info, wd->RenderPass); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -23,13 +23,13 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;  // Enable Keyboard Controls | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;        // Enable Docking | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_Marmalade_Init(true); | ||||
|  | ||||
|     // Setup Style | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_Marmalade_Init(true); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -32,6 +32,7 @@ int main(int, char**) | ||||
|     SDL_GetCurrentDisplayMode(0, ¤t); | ||||
|     SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE); | ||||
|     SDL_GLContext gl_context = SDL_GL_CreateContext(window); | ||||
|     SDL_GL_MakeCurrent(window, gl_context); | ||||
|     SDL_GL_SetSwapInterval(1); // Enable vsync | ||||
|  | ||||
|     // Setup Dear ImGui context | ||||
| @@ -44,14 +45,22 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplSDL2_InitForOpenGL(window, gl_context); | ||||
|     ImGui_ImplOpenGL2_Init(); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
| @@ -143,9 +152,9 @@ int main(int, char**) | ||||
|         { | ||||
|             ImGui::UpdatePlatformWindows(); | ||||
|             ImGui::RenderPlatformWindowsDefault(); | ||||
|             SDL_GL_MakeCurrent(window, gl_context); | ||||
|         } | ||||
|  | ||||
|         SDL_GL_MakeCurrent(window, gl_context); | ||||
|         SDL_GL_SwapWindow(window); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -56,6 +56,7 @@ int main(int, char**) | ||||
|     SDL_GetCurrentDisplayMode(0, ¤t); | ||||
|     SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE); | ||||
|     SDL_GLContext gl_context = SDL_GL_CreateContext(window); | ||||
|     SDL_GL_MakeCurrent(window, gl_context); | ||||
|     SDL_GL_SetSwapInterval(1); // Enable vsync | ||||
|  | ||||
|     // Initialize OpenGL loader | ||||
| @@ -84,17 +85,21 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplSDL2_InitForOpenGL(window, gl_context); | ||||
|     ImGui_ImplOpenGL3_Init(glsl_version); | ||||
|  | ||||
|     // Setup Style | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     style.WindowRounding = 0.0f;                                // When viewports are enabled it is preferable to disable WinodwRounding | ||||
|     style.Colors[ImGuiCol_WindowBg].w = 1.0f;                   // When viewports are enabled it is preferable to disable WindowBg alpha | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplSDL2_InitForOpenGL(window, gl_context); | ||||
|     ImGui_ImplOpenGL3_Init(glsl_version); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
| @@ -178,7 +183,6 @@ int main(int, char**) | ||||
|  | ||||
|         // Rendering | ||||
|         ImGui::Render(); | ||||
|         SDL_GL_MakeCurrent(window, gl_context); | ||||
|         glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); | ||||
|         glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); | ||||
|         glClear(GL_COLOR_BUFFER_BIT); | ||||
| @@ -189,9 +193,9 @@ int main(int, char**) | ||||
|         { | ||||
|             ImGui::UpdatePlatformWindows(); | ||||
|             ImGui::RenderPlatformWindowsDefault(); | ||||
|             SDL_GL_MakeCurrent(window, gl_context); | ||||
|         } | ||||
|  | ||||
|         SDL_GL_MakeCurrent(window, gl_context); | ||||
|         SDL_GL_SwapWindow(window); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -342,6 +342,18 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplSDL2_InitForVulkan(window); | ||||
|     ImGui_ImplVulkan_InitInfo init_info = {}; | ||||
| @@ -356,10 +368,6 @@ int main(int, char**) | ||||
|     init_info.CheckVkResultFn = check_vk_result; | ||||
|     ImGui_ImplVulkan_Init(&init_info, wd->RenderPass); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -122,14 +122,22 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplWin32_Init(hwnd); | ||||
|     ImGui_ImplDX10_Init(g_pd3dDevice); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -141,17 +141,21 @@ int main(int, char**) | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports; // FIXME-DPI | ||||
|     io.ConfigDockingWithShift = true; | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplWin32_Init(hwnd); | ||||
|     ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); | ||||
|  | ||||
|     // Setup Style | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     style.WindowRounding = 0.0f;                                // When viewports are enabled it is preferable to disable WinodwRounding | ||||
|     style.Colors[ImGuiCol_WindowBg].w = 1.0f;                   // When viewports are enabled it is preferable to disable WindowBg alpha | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplWin32_Init(hwnd); | ||||
|     ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|   | ||||
| @@ -296,6 +296,18 @@ int main(int, char**) | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. | ||||
|     ImGuiStyle& style = ImGui::GetStyle(); | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         style.WindowRounding = 0.0f; | ||||
|         style.Colors[ImGuiCol_WindowBg].w = 1.0f; | ||||
|     } | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplWin32_Init(hwnd); | ||||
|     ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,  | ||||
| @@ -303,10 +315,6 @@ int main(int, char**) | ||||
|         g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),  | ||||
|         g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart()); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -80,19 +80,22 @@ int main(int, char**) | ||||
|     ImGui::CreateContext(); | ||||
|     ImGuiIO& io = ImGui::GetIO(); (void)io; | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;       // Enable Keyboard Controls | ||||
| <<<<<<< HEAD | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;           // Enable Docking | ||||
|     io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;         // Enable Multi-Viewport / Platform Windows | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; | ||||
|     //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; | ||||
| ======= | ||||
|  | ||||
|     // Setup Dear ImGui style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
| >>>>>>> viewport | ||||
|  | ||||
|     // Setup Platform/Renderer bindings | ||||
|     ImGui_ImplWin32_Init(hwnd); | ||||
|     ImGui_ImplDX9_Init(g_pd3dDevice); | ||||
|  | ||||
|     // Setup Style | ||||
|     ImGui::StyleColorsDark(); | ||||
|     //ImGui::StyleColorsClassic(); | ||||
|  | ||||
|     // Load Fonts | ||||
|     // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.  | ||||
|     // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.  | ||||
|   | ||||
| @@ -253,39 +253,39 @@ static void ImGui_ImplSDL2_UpdateMousePosAndButtons() | ||||
|     io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); | ||||
| #endif | ||||
|  | ||||
|     int mx, my; | ||||
|     Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my); | ||||
|     int mouse_x, mouse_y; | ||||
|     Uint32 mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y); // NB: We don't use the x/y results from SDL_GetMouseState() | ||||
|     SDL_GetGlobalMouseState(&mouse_x, &mouse_y); | ||||
|     io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;  // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. | ||||
|     io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0; | ||||
|     io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0; | ||||
|     g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false; | ||||
|  | ||||
| #if SDL_HAS_CAPTURE_MOUSE && !defined(__EMSCRIPTEN__) | ||||
|     SDL_Window* focused_window = SDL_GetKeyboardFocus(); | ||||
|     if (focused_window) | ||||
|     if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|     { | ||||
|         if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) | ||||
|         { | ||||
|             // Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor) | ||||
|             SDL_GetGlobalMouseState(&mx, &my); | ||||
|         // Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor) | ||||
|         if (SDL_Window* focused_window = SDL_GetKeyboardFocus()) | ||||
|             if (ImGui::FindViewportByPlatformHandle((void*)focused_window) != NULL) | ||||
|                 io.MousePos = ImVec2((float)mx, (float)my); | ||||
|         } | ||||
|         else | ||||
|                 io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); | ||||
|     } | ||||
|     else | ||||
| #endif | ||||
|     { | ||||
|         // Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window) | ||||
|         if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS) | ||||
|         { | ||||
|             // Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window) | ||||
|             if (focused_window == g_Window) | ||||
|                 io.MousePos = ImVec2((float)mx, (float)my); | ||||
|             int window_x, window_y; | ||||
|             SDL_GetWindowPosition(g_Window, &window_x, &window_y); | ||||
|             io.MousePos = ImVec2((float)(mouse_x - window_x), (float)(mouse_y - window_y)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // We already retrieve global mouse position, SDL_CaptureMouse() also let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't trigger the OS window resize cursor | ||||
|     // The function is only supported from SDL 2.0.4 (released Jan 2016) | ||||
| #if SDL_HAS_CAPTURE_MOUSE  | ||||
|     bool any_mouse_button_down = ImGui::IsAnyMouseDown(); | ||||
|     SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE); | ||||
| #else | ||||
|     if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS) | ||||
|         io.MousePos = ImVec2((float)mx, (float)my); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -3895,6 +3895,7 @@ void ImGui::EndFrame() | ||||
|             IM_ASSERT(viewport->Window != NULL); | ||||
|         g.PlatformIO.Viewports.push_back(viewport); | ||||
|     } | ||||
|     g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called | ||||
|  | ||||
|     // Sort the window list so that all child windows are after their parent | ||||
|     // We cannot do that on FocusWindow() because childs may not exist yet | ||||
| @@ -4959,7 +4960,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     const ImGuiStyle& style = g.Style; | ||||
|     IM_ASSERT(name != NULL);                        // Window name required | ||||
|     IM_ASSERT(name != NULL && name[0] != '\0');     // Window name required | ||||
|     IM_ASSERT(g.FrameScopeActive);                  // Forgot to call ImGui::NewFrame() | ||||
|     IM_ASSERT(g.FrameCountEnded != g.FrameCount);   // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet | ||||
|  | ||||
| @@ -8005,7 +8006,7 @@ void ImGui::UpdatePlatformWindows() | ||||
|         } | ||||
|  | ||||
|         // Clear request flags | ||||
|         viewport->PlatformRequestClose = viewport->PlatformRequestMove = viewport->PlatformRequestResize = false; | ||||
|         viewport->ClearRequestFlags(); | ||||
|     } | ||||
|  | ||||
|     // Update our implicit z-order knowledge of platform windows, which is used when the back-end cannot provide io.MouseHoveredViewport. | ||||
| @@ -8110,7 +8111,7 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) | ||||
|     viewport->PlatformHandle = NULL; | ||||
|     viewport->RendererUserData = viewport->PlatformHandle = NULL; | ||||
|     viewport->PlatformWindowCreated = false; | ||||
|     viewport->PlatformRequestClose = viewport->PlatformRequestMove = viewport->PlatformRequestResize = false; | ||||
|     viewport->ClearRequestFlags(); | ||||
| } | ||||
|  | ||||
| void ImGui::DestroyPlatformWindows() | ||||
|   | ||||
| @@ -690,10 +690,11 @@ struct ImGuiViewportP : public ImGuiViewport | ||||
|     ImVec2              LastPlatformSize; | ||||
|     ImVec2              LastRendererSize; | ||||
|  | ||||
|     ImGuiViewportP()         { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); } | ||||
|     ~ImGuiViewportP()        { if (OverlayDrawList) IM_DELETE(OverlayDrawList); } | ||||
|     ImRect  GetRect() const  { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } | ||||
|     ImVec2  GetCenter() const{ return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } | ||||
|     ImGuiViewportP()            { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); } | ||||
|     ~ImGuiViewportP()           { if (OverlayDrawList) IM_DELETE(OverlayDrawList); } | ||||
|     ImRect  GetRect() const     { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } | ||||
|     ImVec2  GetCenter() const   { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } | ||||
|     void    ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; } | ||||
| }; | ||||
|  | ||||
| struct ImGuiNavMoveResult | ||||
|   | ||||
		Reference in New Issue
	
	Block a user