diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4c7c28a1e..d71ed5b5c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -92,6 +92,9 @@ Other Changes: buffer on the IsItemDeactivatedAfterEdit() frame. This could create issues when using the idiom of not applying edits before IsItemDeactivatedAfterEdit(). (#9308, #8915, #8273) +- Tables: + - Fixed dragging a header to reorder outside of visible bounds (due to horizontal scrolling) + from losing active id. - Style: - Border sizes are now scaled (and rounded) by ScaleAllSizes(). - When using large values with ScallAllSizes(), the following items thickness diff --git a/imgui_internal.h b/imgui_internal.h index 4d5a119ab..dc1c4baf5 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -3044,6 +3044,7 @@ struct IMGUI_API ImGuiTable ImGuiTableColumnIdx ResizedColumn; // Index of column being resized. Reset when InstanceCurrent==0. ImGuiTableColumnIdx LastResizedColumn; // Index of column being resized from previous frame. ImGuiTableColumnIdx HeldHeaderColumn; // Index of column header being held. + ImGuiTableColumnIdx LastHeldHeaderColumn; // Index of column header being held from previous frame. ImGuiTableColumnIdx ReorderColumn; // Index of column being reordered. (not cleared) ImGuiTableColumnIdx ReorderColumnDstOrder; // Requested display order of column being reordered. ImGuiTableColumnIdx LeftMostEnabledColumn; // Index of left-most non-hidden column. diff --git a/imgui_tables.cpp b/imgui_tables.cpp index ad0540cc9..a64f4c053 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -702,6 +702,7 @@ void ImGui::TableBeginApplyRequests(ImGuiTable* table) // Note: we don't clear ReorderColumn after handling the request (FIXME: clarify why or add a test). if (table->InstanceCurrent == 0) { + table->LastHeldHeaderColumn = table->HeldHeaderColumn; table->HeldHeaderColumn = -1; if (table->ReorderColumn != -1 && table->ReorderColumnDstOrder != -1) { @@ -3136,7 +3137,7 @@ void ImGui::TableHeadersRow() const int columns_count = TableGetColumnCount(); for (int column_n = 0; column_n < columns_count; column_n++) { - if (!TableSetColumnIndex(column_n)) + if (!TableSetColumnIndex(column_n) && table->LastHeldHeaderColumn != column_n) continue; // Push an id to allow empty/unnamed headers. This is also idiomatic as it ensure there is a consistent ID path to access columns (for e.g. automation) @@ -4064,7 +4065,7 @@ void ImGui::DebugNodeTable(ImGuiTable* table) BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", table->ColumnsGivenWidth, table->ColumnsAutoFitWidth, table->InnerWidth, table->InnerWidth == 0.0f ? " (auto)" : ""); BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX); BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder); - BulletText("ResizedColumn: %d, HeldHeaderColumn: %d, ReorderColumn: %d", table->ResizedColumn, table->HeldHeaderColumn, table->ReorderColumn); + BulletText("ResizedColumn: %d, HeldHeaderColumn: %d, ReorderColumn: %d", table->LastResizedColumn, table->LastHeldHeaderColumn, table->ReorderColumn); for (int n = 0; n < table->InstanceCurrent + 1; n++) { ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, n);