From 4d00bf8add44155a4f6b489538bd77d6214a4432 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 12 Sep 2024 23:13:32 +0200 Subject: [PATCH] MultiSelect+Tables: fixed an issue where box-select would skip items while drag-scrolling in a table with outer borders. (#7970, #7821). See "widgets_multiselect_boxselect_2" test. --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2189f2584..903af40c3 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -63,6 +63,8 @@ Other changes: #6223, #6364, #6387, #6567, #6692, #6724, #6939, #6984, #7246, #7270, #7375, #7421, #7434, #7472, #7581, #7724, #7926, #7937 and probably more..) - Nav: pressing any keyboard key while holding Alt disable toggling nav layer on Alt release. (#4439) +- MultiSelect+Tables: fixed an issue where box-select would skip items while drag-scrolling + in a table with outer borders. (#7970, #7821). - InputText: internal refactoring to simplify and optimize the code. The ImWchar buffer has been removed. Simplifications allowed to implement new optimizations for handling very large text buffers (e.g. in our testing, handling of a 1 MB text buffer is now 3 times faster in VS2022 Debug build). diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 94e1abff6..14c5af3e4 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7403,6 +7403,7 @@ static void DebugLogMultiSelectRequests(const char* function, const ImGuiMultiSe static ImRect CalcScopeRect(ImGuiMultiSelectTempData* ms, ImGuiWindow* window) { + ImGuiContext& g = *GImGui; if (ms->Flags & ImGuiMultiSelectFlags_ScopeRect) { // Warning: this depends on CursorMaxPos so it means to be called by EndMultiSelect() only @@ -7410,8 +7411,12 @@ static ImRect CalcScopeRect(ImGuiMultiSelectTempData* ms, ImGuiWindow* window) } else { - // Add inner table decoration (#7821) // FIXME: Why not baking in InnerClipRect? + // When a table, pull HostClipRect, which allows us to predict ClipRect before first row/layout is performed. (#7970) ImRect scope_rect = window->InnerClipRect; + if (g.CurrentTable != NULL) + scope_rect = g.CurrentTable->HostClipRect; + + // Add inner table decoration (#7821) // FIXME: Why not baking in InnerClipRect? scope_rect.Min = ImMin(scope_rect.Min + ImVec2(window->DecoInnerSizeX1, window->DecoInnerSizeY1), scope_rect.Max); return scope_rect; }