mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
RangeSelect/MultiSelect: Fix so that shift+arrow when landing on an item that doesn't hold multi-select data doesn't trigger an unbounded range-select that ends up selecting everything until the end.
This commit is contained in:
parent
1b069b5d32
commit
9b925d51bb
@ -1094,7 +1094,7 @@ struct ImGuiNextItemData
|
|||||||
ImGuiID FocusScopeId; // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging)
|
ImGuiID FocusScopeId; // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging)
|
||||||
ImGuiCond OpenCond;
|
ImGuiCond OpenCond;
|
||||||
bool OpenVal; // Set by SetNextItemOpen()
|
bool OpenVal; // Set by SetNextItemOpen()
|
||||||
bool MultiSelectDataIsSet;
|
ImGuiID MultiSelectScopeId;
|
||||||
void* MultiSelectData;
|
void* MultiSelectData;
|
||||||
|
|
||||||
ImGuiNextItemData() { memset(this, 0, sizeof(*this)); }
|
ImGuiNextItemData() { memset(this, 0, sizeof(*this)); }
|
||||||
|
@ -6363,6 +6363,9 @@ bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags
|
|||||||
// - MultiSelectItemHeader() [Internal]
|
// - MultiSelectItemHeader() [Internal]
|
||||||
// - MultiSelectItemFooter() [Internal]
|
// - MultiSelectItemFooter() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
// FIXME: Shift+click on an item that has no multi-select data could treat selection the same as the last item with such data?
|
||||||
|
// The problem is that this may conflict with other behaviors of those items?
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
ImGuiMultiSelectData* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, void* range_ref, bool range_ref_is_selected)
|
ImGuiMultiSelectData* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, void* range_ref, bool range_ref_is_selected)
|
||||||
{
|
{
|
||||||
@ -6429,8 +6432,9 @@ ImGuiMultiSelectData* ImGui::EndMultiSelect()
|
|||||||
void ImGui::SetNextItemMultiSelectData(void* item_data)
|
void ImGui::SetNextItemMultiSelectData(void* item_data)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
IM_ASSERT(g.MultiSelectScopeId != 0);
|
||||||
g.NextItemData.MultiSelectData = item_data;
|
g.NextItemData.MultiSelectData = item_data;
|
||||||
g.NextItemData.MultiSelectDataIsSet = true;
|
g.NextItemData.MultiSelectScopeId = g.MultiSelectScopeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::MultiSelectItemHeader(ImGuiID id, bool* p_selected)
|
void ImGui::MultiSelectItemHeader(ImGuiID id, bool* p_selected)
|
||||||
@ -6438,7 +6442,7 @@ void ImGui::MultiSelectItemHeader(ImGuiID id, bool* p_selected)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiMultiSelectState* state = &g.MultiSelectState;
|
ImGuiMultiSelectState* state = &g.MultiSelectState;
|
||||||
|
|
||||||
IM_ASSERT(g.NextItemData.MultiSelectDataIsSet && "Forgot to call SetNextItemMultiSelectData() prior to item, required in BeginMultiSelect()/EndMultiSelect() scope");
|
IM_ASSERT(g.NextItemData.MultiSelectScopeId == g.MultiSelectScopeId && "Forgot to call SetNextItemMultiSelectData() prior to item, required in BeginMultiSelect()/EndMultiSelect() scope");
|
||||||
void* item_data = g.NextItemData.MultiSelectData;
|
void* item_data = g.NextItemData.MultiSelectData;
|
||||||
|
|
||||||
// Apply Clear/SelectAll requests requested by BeginMultiSelect().
|
// Apply Clear/SelectAll requests requested by BeginMultiSelect().
|
||||||
@ -6479,7 +6483,7 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
|
|||||||
ImGuiMultiSelectState* state = &g.MultiSelectState;
|
ImGuiMultiSelectState* state = &g.MultiSelectState;
|
||||||
|
|
||||||
void* item_data = g.NextItemData.MultiSelectData;
|
void* item_data = g.NextItemData.MultiSelectData;
|
||||||
g.NextItemData.MultiSelectDataIsSet = false;
|
g.NextItemData.MultiSelectScopeId = 0;
|
||||||
|
|
||||||
bool selected = *p_selected;
|
bool selected = *p_selected;
|
||||||
bool pressed = *p_pressed;
|
bool pressed = *p_pressed;
|
||||||
|
Loading…
Reference in New Issue
Block a user