ColorEdit, ColorPicker: Manipulating options popup don't mark item as edited. (#6722)

This commit is contained in:
ocornut 2023-08-25 22:48:16 +02:00
parent f617fe7890
commit 33ea1e8b78
4 changed files with 10 additions and 0 deletions

View File

@ -58,6 +58,8 @@ Other changes:
setting large values. (#6749) setting large values. (#6749)
- InputFloat, SliderFloat, DragFloat: always turn both '.' and ',' into the current decimal - InputFloat, SliderFloat, DragFloat: always turn both '.' and ',' into the current decimal
point character when using Decimal/Scientific character filter. (#6719, #2278) [@adamsepp] point character when using Decimal/Scientific character filter. (#6719, #2278) [@adamsepp]
- ColorEdit, ColorPicker: Manipulating options popup don't mark item as edited. (#6722)
(Note that they may still be marked as Active/Hovered.)
- Clipper: Added IncludeItemByIndex() helper to include a single item. (#6424, #3841) - Clipper: Added IncludeItemByIndex() helper to include a single item. (#6424, #3841)
- ImDrawData: Fixed an issue where TotalVtxCount/TotalIdxCount does not match the sum - ImDrawData: Fixed an issue where TotalVtxCount/TotalIdxCount does not match the sum
of individual ImDrawList's buffer sizes when a dimming/modal background is rendered. (#6716) of individual ImDrawList's buffer sizes when a dimming/modal background is rendered. (#6716)

View File

@ -3940,6 +3940,8 @@ void ImGui::MarkItemEdited(ImGuiID id)
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit(). // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need to fill the data. // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need to fill the data.
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.LockMarkEdited > 0)
return;
if (g.ActiveId == id || g.ActiveId == 0) if (g.ActiveId == id || g.ActiveId == 0)
{ {
g.ActiveIdHasBeenEditedThisFrame = true; g.ActiveIdHasBeenEditedThisFrame = true;

View File

@ -2014,6 +2014,7 @@ struct ImGuiContext
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage? float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
float DisabledAlphaBackup; // Backup for style.Alpha for BeginDisabled() float DisabledAlphaBackup; // Backup for style.Alpha for BeginDisabled()
short DisabledStackSize; short DisabledStackSize;
short LockMarkEdited;
short TooltipOverrideCount; short TooltipOverrideCount;
ImVector<char> ClipboardHandlerData; // If no custom clipboard handler is defined ImVector<char> ClipboardHandlerData; // If no custom clipboard handler is defined
ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
@ -2207,6 +2208,7 @@ struct ImGuiContext
ScrollbarClickDeltaToGrabCenter = 0.0f; ScrollbarClickDeltaToGrabCenter = 0.0f;
DisabledAlphaBackup = 0.0f; DisabledAlphaBackup = 0.0f;
DisabledStackSize = 0; DisabledStackSize = 0;
LockMarkEdited = 0;
TooltipOverrideCount = 0; TooltipOverrideCount = 0;
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f); PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);

View File

@ -5884,6 +5884,7 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context")) if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context"))
return; return;
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
g.LockMarkEdited++;
ImGuiColorEditFlags opts = g.ColorEditOptions; ImGuiColorEditFlags opts = g.ColorEditOptions;
if (allow_opt_inputs) if (allow_opt_inputs)
{ {
@ -5926,6 +5927,7 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
g.ColorEditOptions = opts; g.ColorEditOptions = opts;
EndPopup(); EndPopup();
g.LockMarkEdited--;
} }
void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags) void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags)
@ -5935,6 +5937,7 @@ void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags fl
if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context")) if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context"))
return; return;
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
g.LockMarkEdited++;
if (allow_opt_picker) if (allow_opt_picker)
{ {
ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function
@ -5964,6 +5967,7 @@ void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags fl
CheckboxFlags("Alpha Bar", &g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar); CheckboxFlags("Alpha Bar", &g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar);
} }
EndPopup(); EndPopup();
g.LockMarkEdited--;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------