From a856c670c17fe70d61e519bf74ccb2559915a2ff Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 21 Aug 2019 23:05:46 +0200 Subject: [PATCH] TabBar: fixed single-tab not shrinking their width down. + minor typo fixes (#2738) --- docs/CHANGELOG.txt | 1 + examples/imgui_impl_opengl2.cpp | 2 +- imgui.cpp | 2 +- imgui_widgets.cpp | 8 ++++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8b4659e27..630330427 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -38,6 +38,7 @@ Other Changes: Note that some elements won't accurately fade down with the same intensity, and the color wheel when enabled will have small overlap glitches with (style.Alpha < 1.0). - TabBar: fixed ScrollToBar request creating bouncing loop when tab is larger than available space. +- TabBar: fixed single-tab not shrinking their width down. - Backends: DX11: Fixed GSGetShader() call not passing an initialized instance count, would generally make the debug layer complain (Added in 1.72). - Backends: Vulkan: Added support for specifying multisample count. diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp index 95720ff3c..fbe278c7f 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/examples/imgui_impl_opengl2.cpp @@ -24,7 +24,7 @@ // 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications. // 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples. // 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL2_RenderDrawData() in the .h file so you can call it yourself. +// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplOpenGL2_RenderDrawData() in the .h file so you can call it yourself. // 2017-09-01: OpenGL: Save and restore current polygon mode. // 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal). // 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle. diff --git a/imgui.cpp b/imgui.cpp index 361213986..374efe2a6 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -638,7 +638,7 @@ CODE - In the examples/ bindings, for each graphics API binding we decided on a type that is likely to be a good representation for specifying an image from the end-user perspective. This is what the _examples_ rendering functions are using: - OpenGL: ImTextureID = GLuint (see ImGui_ImplGlfwGL3_RenderDrawData() function in imgui_impl_glfw_gl3.cpp) + OpenGL: ImTextureID = GLuint (see ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_glfw_gl3.cpp) DirectX9: ImTextureID = LPDIRECT3DTEXTURE9 (see ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp) DirectX11: ImTextureID = ID3D11ShaderResourceView* (see ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp) DirectX12: ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE (see ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 3e4f08a9e..89e6ca0b3 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1361,8 +1361,12 @@ static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs) // Shrink excess width from a set of item, by removing width from the larger items first. void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess) { - if (count > 1) - ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); + if (count == 1) + { + items[0].Width -= width_excess; + return; + } + ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); int count_same_width = 1; while (width_excess > 0.0f && count_same_width < count) {