mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-17 19:09:27 +01:00
MultiSelect: removed seemingly unnecessary block in BeginMultiSelect().
- EndIO.RangeSelected always set along with EndIO.RequestSetRange - Trying to assert for the assignment making a difference when EndIO.RequestSetRange is already set couldn't find a case (tests passing).
This commit is contained in:
parent
88df590145
commit
2765fdb43e
2
imgui.h
2
imgui.h
@ -2795,7 +2795,7 @@ struct ImGuiMultiSelectIO
|
|||||||
bool RequestSelectAll; // ms:w, app:r / ms:w, app:r // 2. Request app/user to select all.
|
bool RequestSelectAll; // ms:w, app:r / ms:w, app:r // 2. Request app/user to select all.
|
||||||
bool RequestSetRange; // / ms:w, app:r // 3. Request app/user to select/unselect [RangeFirstItem..RangeLastItem] items based on 'bool RangeSelected'. Only EndMultiSelect() request this, app code can read after BeginMultiSelect() and it will always be false.
|
bool RequestSetRange; // / ms:w, app:r // 3. Request app/user to select/unselect [RangeFirstItem..RangeLastItem] items based on 'bool RangeSelected'. Only EndMultiSelect() request this, app code can read after BeginMultiSelect() and it will always be false.
|
||||||
// STATE/ARGUMENTS -------------------------// BEGIN / END
|
// STATE/ARGUMENTS -------------------------// BEGIN / END
|
||||||
ImGuiSelectionUserData RangeSrcItem; // ms:w app:r / // (If using clipper) Begin: Source item (generally the first selected item when multi-selecting, which is used as a reference point) must never be cliped!
|
ImGuiSelectionUserData RangeSrcItem; // ms:w app:r / // (If using clipper) Begin: Source item (generally the first selected item when multi-selecting, which is used as a reference point) must never be clipped!
|
||||||
ImGuiSelectionUserData RangeFirstItem; // / ms:w, app:r // End: parameter for RequestSetRange request (this is generally == RangeSrcItem when shift selecting from top to bottom)
|
ImGuiSelectionUserData RangeFirstItem; // / ms:w, app:r // End: parameter for RequestSetRange request (this is generally == RangeSrcItem when shift selecting from top to bottom)
|
||||||
ImGuiSelectionUserData RangeLastItem; // / ms:w, app:r // End: parameter for RequestSetRange request (this is generally == RangeSrcItem when shift selecting from bottom to top)
|
ImGuiSelectionUserData RangeLastItem; // / ms:w, app:r // End: parameter for RequestSetRange request (this is generally == RangeSrcItem when shift selecting from bottom to top)
|
||||||
bool RangeSelected; // / ms:w, app:r // End: parameter for RequestSetRange request. true = Select Range, false = Unselect Range.
|
bool RangeSelected; // / ms:w, app:r // End: parameter for RequestSetRange request. true = Select Range, false = Unselect Range.
|
||||||
|
@ -7109,12 +7109,12 @@ void ImGui::DebugNodeTypingSelectState(ImGuiTypingSelectState* data)
|
|||||||
// - DebugNodeMultiSelectState() [Internal]
|
// - DebugNodeMultiSelectState() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
static void DebugLogMultiSelectRequests(const char* function, const ImGuiMultiSelectIO* data)
|
static void DebugLogMultiSelectRequests(const char* function, const ImGuiMultiSelectIO* io)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (data->RequestClear) IMGUI_DEBUG_LOG_SELECTION("[selection] %s: RequestClear\n", function);
|
if (io->RequestClear) IMGUI_DEBUG_LOG_SELECTION("[selection] %s: RequestClear\n", function);
|
||||||
if (data->RequestSelectAll) IMGUI_DEBUG_LOG_SELECTION("[selection] %s: RequestSelectAll\n", function);
|
if (io->RequestSelectAll) IMGUI_DEBUG_LOG_SELECTION("[selection] %s: RequestSelectAll\n", function);
|
||||||
if (data->RequestSetRange) IMGUI_DEBUG_LOG_SELECTION("[selection] %s: RequestSetRange %" IM_PRId64 "..%" IM_PRId64 " (0x%" IM_PRIX64 "..0x%" IM_PRIX64 ") = %d\n", function, data->RangeFirstItem, data->RangeLastItem, data->RangeFirstItem, data->RangeLastItem, data->RangeSelected);
|
if (io->RequestSetRange) IMGUI_DEBUG_LOG_SELECTION("[selection] %s: RequestSetRange %" IM_PRId64 "..%" IM_PRId64 " (0x%" IM_PRIX64 "..0x%" IM_PRIX64 ") = %d\n", function, io->RangeFirstItem, io->RangeLastItem, io->RangeFirstItem, io->RangeLastItem, io->RangeSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return ImGuiMultiSelectIO structure. Lifetime: valid until corresponding call to EndMultiSelect().
|
// Return ImGuiMultiSelectIO structure. Lifetime: valid until corresponding call to EndMultiSelect().
|
||||||
@ -7169,17 +7169,17 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags)
|
|||||||
|
|
||||||
if (ms->IsFocused)
|
if (ms->IsFocused)
|
||||||
{
|
{
|
||||||
// Shortcut: Select all (CTRL+A)
|
|
||||||
if (!(flags & ImGuiMultiSelectFlags_SingleSelect) && !(flags & ImGuiMultiSelectFlags_NoSelectAll))
|
|
||||||
if (Shortcut(ImGuiMod_Ctrl | ImGuiKey_A))
|
|
||||||
ms->BeginIO.RequestSelectAll = true;
|
|
||||||
|
|
||||||
// Shortcut: Clear selection (Escape)
|
// Shortcut: Clear selection (Escape)
|
||||||
// FIXME-MULTISELECT: Only hog shortcut if selection is not null, meaning we need "has selection or "selection size" data here.
|
// FIXME-MULTISELECT: Only hog shortcut if selection is not null, meaning we need "has selection or "selection size" data here.
|
||||||
// Otherwise may be done by caller but it means Shortcut() needs to be exposed.
|
// Otherwise may be done by caller but it means Shortcut() needs to be exposed.
|
||||||
if (flags & ImGuiMultiSelectFlags_ClearOnEscape)
|
if (flags & ImGuiMultiSelectFlags_ClearOnEscape)
|
||||||
if (Shortcut(ImGuiKey_Escape))
|
if (Shortcut(ImGuiKey_Escape))
|
||||||
ms->BeginIO.RequestClear = true;
|
ms->BeginIO.RequestClear = true;
|
||||||
|
|
||||||
|
// Shortcut: Select all (CTRL+A)
|
||||||
|
if (!(flags & ImGuiMultiSelectFlags_SingleSelect) && !(flags & ImGuiMultiSelectFlags_NoSelectAll))
|
||||||
|
if (Shortcut(ImGuiMod_Ctrl | ImGuiKey_A))
|
||||||
|
ms->BeginIO.RequestSelectAll = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)
|
if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)
|
||||||
@ -7428,12 +7428,6 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
|
|||||||
// Update/store the selection state of the Source item (used by CTRL+SHIFT, when Source is unselected we perform a range unselect)
|
// Update/store the selection state of the Source item (used by CTRL+SHIFT, when Source is unselected we perform a range unselect)
|
||||||
if (storage->RangeSrcItem == item_data)
|
if (storage->RangeSrcItem == item_data)
|
||||||
storage->RangeSelected = selected ? 1 : 0;
|
storage->RangeSelected = selected ? 1 : 0;
|
||||||
if (ms->EndIO.RangeSrcItem == item_data && is_ctrl && is_shift && is_multiselect)
|
|
||||||
{
|
|
||||||
if (ms->EndIO.RequestSetRange)
|
|
||||||
IM_ASSERT(storage->RangeSrcItem == ms->EndIO.RangeSrcItem);
|
|
||||||
ms->EndIO.RangeSelected = selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update/store the selection state of focused item
|
// Update/store the selection state of focused item
|
||||||
if (g.NavId == id)
|
if (g.NavId == id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user