Tables: activating an ID (e.g. clicking button inside) column doesn't prevent columns output flags from having ImGuiTableColumnFlags_IsHovered set. (#2957)

This commit is contained in:
ocornut 2022-10-13 15:15:42 +02:00
parent 3e8d198133
commit b15347cb7d
3 changed files with 11 additions and 1 deletions

View File

@ -124,6 +124,8 @@ Other Changes:
io.HoverDelayNormal (default to 0.30f) and io.HoverDelayFast (default to 0.10f). (#1485) io.HoverDelayNormal (default to 0.30f) and io.HoverDelayFast (default to 0.10f). (#1485)
- IsItemHovered: Added ImGuiHoveredFlags_NoSharedDelay to disable sharing delays between itemm, - IsItemHovered: Added ImGuiHoveredFlags_NoSharedDelay to disable sharing delays between itemm,
so moving from one item to a nearby one will requires delay to elapse again. (#1485) so moving from one item to a nearby one will requires delay to elapse again. (#1485)
- Tables: activating an ID (e.g. clicking button inside) column doesn't prevent columns
output flags from having ImGuiTableColumnFlags_IsHovered set. (#2957)
- Tables,Columns: fixed a layout issue where SameLine() prior to a row change would set the - Tables,Columns: fixed a layout issue where SameLine() prior to a row change would set the
next row in such state where subsequent SameLine() would move back to previous row. next row in such state where subsequent SameLine() would move back to previous row.
- Tabs: Fixed a crash when closing multiple windows (possible with docking only) with an - Tabs: Fixed a crash when closing multiple windows (possible with docking only) with an

View File

@ -23,7 +23,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
#define IMGUI_VERSION "1.89 WIP" #define IMGUI_VERSION "1.89 WIP"
#define IMGUI_VERSION_NUM 18830 #define IMGUI_VERSION_NUM 18831
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
/* /*

View File

@ -936,11 +936,19 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
width_remaining_for_stretched_columns -= 1.0f; width_remaining_for_stretched_columns -= 1.0f;
} }
// Determine if table is hovered which will be used to flag columns as hovered.
// - In principle we'd like to use the equivalent of IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
// but because our item is partially submitted at this point we use ItemHoverable() and a workaround (temporarily
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
table->HoveredColumnBody = -1; table->HoveredColumnBody = -1;
table->HoveredColumnBorder = -1; table->HoveredColumnBorder = -1;
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight)); const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
const ImGuiID backup_active_id = g.ActiveId;
g.ActiveId = 0;
const bool is_hovering_table = ItemHoverable(mouse_hit_rect, 0); const bool is_hovering_table = ItemHoverable(mouse_hit_rect, 0);
g.ActiveId = backup_active_id;
// [Part 6] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column // [Part 6] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column
// Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping. // Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping.