mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-27 19:15:24 +08:00
Multi-Select: Box-Select+Tables: fixed Column return value when UnClipRect is active. (#7994, #8250)
Amend6ce4b44+bbd0af7. This probably should be redesigned to be more generic, e.g. move UnclipRect concept outside of Boxselect.
This commit is contained in:
@@ -3544,6 +3544,7 @@ namespace ImGui
|
|||||||
IMGUI_API void TableUpdateLayout(ImGuiTable* table);
|
IMGUI_API void TableUpdateLayout(ImGuiTable* table);
|
||||||
IMGUI_API void TableUpdateBorders(ImGuiTable* table);
|
IMGUI_API void TableUpdateBorders(ImGuiTable* table);
|
||||||
IMGUI_API void TableUpdateColumnsWeightFromWidth(ImGuiTable* table);
|
IMGUI_API void TableUpdateColumnsWeightFromWidth(ImGuiTable* table);
|
||||||
|
IMGUI_API void TableApplyExternalUnclipRect(ImGuiTable* table, ImRect& rect);
|
||||||
IMGUI_API void TableDrawBorders(ImGuiTable* table);
|
IMGUI_API void TableDrawBorders(ImGuiTable* table);
|
||||||
IMGUI_API void TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags_for_section_to_display);
|
IMGUI_API void TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags_for_section_to_display);
|
||||||
IMGUI_API bool TableBeginContextMenuPopup(ImGuiTable* table);
|
IMGUI_API bool TableBeginContextMenuPopup(ImGuiTable* table);
|
||||||
|
|||||||
+17
-5
@@ -1152,7 +1152,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
column->ClipRect.Min.y = work_rect.Min.y;
|
column->ClipRect.Min.y = work_rect.Min.y;
|
||||||
column->ClipRect.Max.x = column->MaxX; //column->WorkMaxX;
|
column->ClipRect.Max.x = column->MaxX; //column->WorkMaxX;
|
||||||
column->ClipRect.Max.y = FLT_MAX;
|
column->ClipRect.Max.y = FLT_MAX;
|
||||||
ImRect clip_rect_unclipped = column->ClipRect;
|
|
||||||
column->ClipRect.ClipWithFull(host_clip_rect);
|
column->ClipRect.ClipWithFull(host_clip_rect);
|
||||||
|
|
||||||
// Mark column as Clipped (not in sight)
|
// Mark column as Clipped (not in sight)
|
||||||
@@ -1170,9 +1169,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
|
|
||||||
// Mark column as requesting output from user. Note that fixed + non-resizable sets are auto-fitting at all times and therefore always request output.
|
// Mark column as requesting output from user. Note that fixed + non-resizable sets are auto-fitting at all times and therefore always request output.
|
||||||
column->IsRequestOutput = is_visible || column->AutoFitQueue != 0 || column->CannotSkipItemsQueue != 0;
|
column->IsRequestOutput = is_visible || column->AutoFitQueue != 0 || column->CannotSkipItemsQueue != 0;
|
||||||
ImGuiBoxSelectState* bs = &g.BoxSelectState;
|
|
||||||
if (!column->IsRequestOutput && bs->UnclipMode && bs->UnclipRect.Overlaps(clip_rect_unclipped))
|
|
||||||
column->IsRequestOutput = true;
|
|
||||||
|
|
||||||
// Mark column as SkipItems (ignoring all items/layout)
|
// Mark column as SkipItems (ignoring all items/layout)
|
||||||
// (table->HostSkipItems is a copy of inner_window->SkipItems before we cleared it above in Part 2)
|
// (table->HostSkipItems is a copy of inner_window->SkipItems before we cleared it above in Part 2)
|
||||||
@@ -1319,14 +1315,30 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
table->InnerWindow->DecoInnerSizeY1 = table_instance->LastFrozenHeight;
|
table->InnerWindow->DecoInnerSizeY1 = table_instance->LastFrozenHeight;
|
||||||
table_instance->LastFrozenHeight = 0.0f;
|
table_instance->LastFrozenHeight = 0.0f;
|
||||||
|
|
||||||
// Initial state
|
|
||||||
ImGuiWindow* inner_window = table->InnerWindow;
|
ImGuiWindow* inner_window = table->InnerWindow;
|
||||||
|
ImGuiBoxSelectState* bs = &g.BoxSelectState;
|
||||||
|
if (bs->Window == inner_window && bs->UnclipMode)
|
||||||
|
TableApplyExternalUnclipRect(table, bs->UnclipRect);
|
||||||
|
|
||||||
|
// Initial state
|
||||||
if (table->Flags & ImGuiTableFlags_NoClip)
|
if (table->Flags & ImGuiTableFlags_NoClip)
|
||||||
table->DrawSplitter->SetCurrentChannel(inner_window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP);
|
table->DrawSplitter->SetCurrentChannel(inner_window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP);
|
||||||
else
|
else
|
||||||
inner_window->DrawList->PushClipRect(inner_window->InnerClipRect.Min, inner_window->InnerClipRect.Max, false); // FIXME: use table->InnerClipRect?
|
inner_window->DrawList->PushClipRect(inner_window->InnerClipRect.Min, inner_window->InnerClipRect.Max, false); // FIXME: use table->InnerClipRect?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When starting a BeginMultiSelect() after table has been layout we update IsRequestOutput fields.
|
||||||
|
void ImGui::TableApplyExternalUnclipRect(ImGuiTable* table, ImRect& rect)
|
||||||
|
{
|
||||||
|
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||||
|
{
|
||||||
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
|
if (!column->IsRequestOutput)
|
||||||
|
if (rect.Overlaps(ImRect(column->MinX, table->WorkRect.Min.y, column->MaxX, FLT_MAX)))
|
||||||
|
column->IsRequestOutput = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process hit-testing on resizing borders. Actual size change will be applied in EndTable()
|
// Process hit-testing on resizing borders. Actual size change will be applied in EndTable()
|
||||||
// - Set table->HoveredColumnBorder with a short delay/timer to reduce visual feedback noise.
|
// - Set table->HoveredColumnBorder with a short delay/timer to reduce visual feedback noise.
|
||||||
void ImGui::TableUpdateBorders(ImGuiTable* table)
|
void ImGui::TableUpdateBorders(ImGuiTable* table)
|
||||||
|
|||||||
@@ -7848,6 +7848,8 @@ bool ImGui::BeginBoxSelect(const ImRect& scope_rect, ImGuiWindow* window, ImGuiI
|
|||||||
bs->UnclipRect = bs->BoxSelectRectPrev; // FIXME-OPT: UnclipRect X coordinates could be intersection of Prev and Curr rect on X axis.
|
bs->UnclipRect = bs->BoxSelectRectPrev; // FIXME-OPT: UnclipRect X coordinates could be intersection of Prev and Curr rect on X axis.
|
||||||
bs->UnclipRect.Add(bs->BoxSelectRectCurr);
|
bs->UnclipRect.Add(bs->BoxSelectRectCurr);
|
||||||
}
|
}
|
||||||
|
if (bs->UnclipMode && g.CurrentTable != NULL)
|
||||||
|
TableApplyExternalUnclipRect(g.CurrentTable, bs->UnclipRect);
|
||||||
|
|
||||||
#ifdef IMGUI_DEBUG_BOXSELECT
|
#ifdef IMGUI_DEBUG_BOXSELECT
|
||||||
if (ms_flags & ImGuiMultiSelectFlags_BoxSelect2d)
|
if (ms_flags & ImGuiMultiSelectFlags_BoxSelect2d)
|
||||||
|
|||||||
Reference in New Issue
Block a user