Skip to content

Commit 582d725

Browse files
committed
imgui v1.90.5-docking source
1 parent c2d5314 commit 582d725

File tree

10 files changed

+7158
-256
lines changed

10 files changed

+7158
-256
lines changed

imgui/src/imgui/imgui.cpp

Lines changed: 6019 additions & 185 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui.h

Lines changed: 279 additions & 14 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui_demo.cpp

Lines changed: 307 additions & 8 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui_draw.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
215215
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
216216
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
217217
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
218+
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
219+
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
218220
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
219221
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
220222
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@@ -275,6 +277,8 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
275277
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
276278
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
277279
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
280+
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
281+
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
278282
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
279283
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
280284
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@@ -336,6 +340,8 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
336340
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
337341
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
338342
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
343+
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
344+
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
339345
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
340346
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
341347
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@@ -4192,6 +4198,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
41924198
// - RenderArrow()
41934199
// - RenderBullet()
41944200
// - RenderCheckMark()
4201+
// - RenderArrowDockMenu()
41954202
// - RenderArrowPointingAt()
41964203
// - RenderRectFilledRangeH()
41974204
// - RenderRectFilledWithHole()
@@ -4266,6 +4273,14 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
42664273
}
42674274
}
42684275

4276+
// This is less wide than RenderArrow() and we use in dock nodes instead of the regular RenderArrow() to denote a change of functionality,
4277+
// and because the saved space means that the left-most tab label can stay at exactly the same position as the label of a loose window.
4278+
void ImGui::RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col)
4279+
{
4280+
draw_list->AddRectFilled(p_min + ImVec2(sz * 0.20f, sz * 0.15f), p_min + ImVec2(sz * 0.80f, sz * 0.30f), col);
4281+
RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.50f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
4282+
}
4283+
42694284
static inline float ImAcos01(float x)
42704285
{
42714286
if (x <= 0.0f) return IM_PI * 0.5f;
@@ -4351,6 +4366,17 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer,
43514366
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
43524367
}
43534368

4369+
ImDrawFlags ImGui::CalcRoundingFlagsForRectInRect(const ImRect& r_in, const ImRect& r_outer, float threshold)
4370+
{
4371+
bool round_l = r_in.Min.x <= r_outer.Min.x + threshold;
4372+
bool round_r = r_in.Max.x >= r_outer.Max.x - threshold;
4373+
bool round_t = r_in.Min.y <= r_outer.Min.y + threshold;
4374+
bool round_b = r_in.Max.y >= r_outer.Max.y - threshold;
4375+
return ImDrawFlags_RoundCornersNone
4376+
| ((round_t && round_l) ? ImDrawFlags_RoundCornersTopLeft : 0) | ((round_t && round_r) ? ImDrawFlags_RoundCornersTopRight : 0)
4377+
| ((round_b && round_l) ? ImDrawFlags_RoundCornersBottomLeft : 0) | ((round_b && round_r) ? ImDrawFlags_RoundCornersBottomRight : 0);
4378+
}
4379+
43544380
// Helper for ColorPicker4()
43554381
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
43564382
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.

imgui/src/imgui/imgui_impl_android.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// [ ] Platform: Clipboard support.
99
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
1010
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
11+
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
1112
// Important:
1213
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
1314
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)

imgui/src/imgui/imgui_impl_android.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// [ ] Platform: Clipboard support.
99
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
1010
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
11+
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
1112
// Important:
1213
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
1314
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)

imgui/src/imgui/imgui_impl_opengl3.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
// Implemented features:
77
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8-
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
8+
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
9+
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
910

1011
// About WebGL/ES:
1112
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
@@ -22,6 +23,7 @@
2223

2324
// CHANGELOG
2425
// (minor and older changes stripped away, please see git history for details)
26+
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
2527
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
2628
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
2729
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
@@ -243,6 +245,10 @@ static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
243245
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
244246
}
245247

248+
// Forward Declarations
249+
static void ImGui_ImplOpenGL3_InitPlatformInterface();
250+
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface();
251+
246252
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
247253
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
248254
struct ImGui_ImplOpenGL3_VtxAttribState
@@ -334,6 +340,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
334340
if (bd->GlVersion >= 320)
335341
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
336342
#endif
343+
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
337344

338345
// Store GLSL version string so we can refer to it later in case we recreate shaders.
339346
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
@@ -371,6 +378,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
371378
}
372379
#endif
373380

381+
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
382+
ImGui_ImplOpenGL3_InitPlatformInterface();
383+
374384
return true;
375385
}
376386

@@ -380,10 +390,11 @@ void ImGui_ImplOpenGL3_Shutdown()
380390
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
381391
ImGuiIO& io = ImGui::GetIO();
382392

393+
ImGui_ImplOpenGL3_ShutdownPlatformInterface();
383394
ImGui_ImplOpenGL3_DestroyDeviceObjects();
384395
io.BackendRendererName = nullptr;
385396
io.BackendRendererUserData = nullptr;
386-
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
397+
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
387398
IM_DELETE(bd);
388399
}
389400

@@ -944,6 +955,34 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
944955
ImGui_ImplOpenGL3_DestroyFontsTexture();
945956
}
946957

958+
//--------------------------------------------------------------------------------------------------------
959+
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
960+
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
961+
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
962+
//--------------------------------------------------------------------------------------------------------
963+
964+
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*)
965+
{
966+
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
967+
{
968+
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
969+
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
970+
glClear(GL_COLOR_BUFFER_BIT);
971+
}
972+
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
973+
}
974+
975+
static void ImGui_ImplOpenGL3_InitPlatformInterface()
976+
{
977+
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
978+
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
979+
}
980+
981+
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
982+
{
983+
ImGui::DestroyPlatformWindows();
984+
}
985+
947986
//-----------------------------------------------------------------------------
948987

949988
#if defined(__GNUC__)

imgui/src/imgui/imgui_impl_opengl3.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
// Implemented features:
77
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8-
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
8+
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
9+
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
910

1011
// About WebGL/ES:
1112
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.

0 commit comments

Comments
 (0)