From 9d444062f974b21f1fc09b7e85479fff3e0789c2 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 17 Dec 2019 13:25:46 +0100 Subject: [PATCH] Limiting Columns()/BeginColumns() api to 64 columns (#125) While the current code technically supports it, future code may not so we're putting the restriction ahead. --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 1 + imgui.h | 1 + imgui_widgets.cpp | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 13e3cec7a..c9ff9b2d4 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -55,6 +55,8 @@ Breaking Changes: documented (can only unreserve from the last reserve call). If you suspect you ever used that feature before, #define IMGUI_DEBUG_PARANOID in imconfig.h to catch existing calls. [@ShironekoBen] +- Limiting Columns()/BeginColumns() api to 64 columns with an assert. While the current code + technically supports it, future code may not so we're putting the restriction ahead. - imgui_internal.h: changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value. diff --git a/imgui.cpp b/imgui.cpp index 309578495..dff12b624 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -353,6 +353,7 @@ CODE When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. + - 2019/12/17 (1.75) - made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead. - 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value. - 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017): - ShowTestWindow() -> use ShowDemoWindow() diff --git a/imgui.h b/imgui.h index 13150f146..704a7211e 100644 --- a/imgui.h +++ b/imgui.h @@ -584,6 +584,7 @@ namespace ImGui // Columns // - You can also use SameLine(pos_x) to mimic simplified columns. // - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!) + // - There is a maximum of 64 columns. // - By end of the 2019 we will expose a new 'Table' api which will replace columns. IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index d605e2d73..684dbe556 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7411,8 +7411,8 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); - IM_ASSERT(columns_count >= 1); - IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported + IM_ASSERT(columns_count >= 1 && columns_count <= 64); // Maximum 64 columns + IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported // Acquire storage for the columns set ImGuiID id = GetColumnsID(str_id, columns_count);