mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-26 14:51:46 +01:00
ColorEdit4: Made IsItemActive() return true when picker popup is active. (#1489)
This commit is contained in:
parent
c9f0275e22
commit
a8c7b1a2a2
10
imgui.cpp
10
imgui.cpp
@ -10036,7 +10036,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
PopItemWidth();
|
PopItemWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool picker_active = false;
|
ImGuiWindow* picker_active_window = NULL;
|
||||||
if (!(flags & ImGuiColorEditFlags_NoSmallPreview))
|
if (!(flags & ImGuiColorEditFlags_NoSmallPreview))
|
||||||
{
|
{
|
||||||
if (!(flags & ImGuiColorEditFlags_NoInputs))
|
if (!(flags & ImGuiColorEditFlags_NoInputs))
|
||||||
@ -10058,7 +10058,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
|
|
||||||
if (BeginPopup("picker"))
|
if (BeginPopup("picker"))
|
||||||
{
|
{
|
||||||
picker_active = true;
|
picker_active_window = g.CurrentWindow;
|
||||||
if (label != label_display_end)
|
if (label != label_display_end)
|
||||||
{
|
{
|
||||||
TextUnformatted(label, label_display_end);
|
TextUnformatted(label, label_display_end);
|
||||||
@ -10080,7 +10080,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert back
|
// Convert back
|
||||||
if (!picker_active)
|
if (picker_active_window == NULL)
|
||||||
{
|
{
|
||||||
if (!value_changed_as_float)
|
if (!value_changed_as_float)
|
||||||
for (int n = 0; n < 4; n++)
|
for (int n = 0; n < 4; n++)
|
||||||
@ -10100,6 +10100,10 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
PopID();
|
PopID();
|
||||||
EndGroup();
|
EndGroup();
|
||||||
|
|
||||||
|
// When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4().
|
||||||
|
if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window)
|
||||||
|
window->DC.LastItemId = g.ActiveId;
|
||||||
|
|
||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user