|
@@ -3446,7 +3446,7 @@ bool ImGui::IsItemActive()
|
|
|
|
|
|
bool ImGui::IsItemClicked(int mouse_button)
|
|
bool ImGui::IsItemClicked(int mouse_button)
|
|
{
|
|
{
|
|
- return IsMouseClicked(mouse_button) && IsItemHovered();
|
|
|
|
|
|
+ return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_Default);
|
|
}
|
|
}
|
|
|
|
|
|
bool ImGui::IsAnyItemHovered()
|
|
bool ImGui::IsAnyItemHovered()
|
|
@@ -3746,22 +3746,29 @@ void ImGui::EndPopup()
|
|
PopStyleVar();
|
|
PopStyleVar();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
|
|
|
|
+{
|
|
|
|
+ ImGuiWindow* window = GImGui->CurrentWindow;
|
|
|
|
+ if (IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
|
+ {
|
|
|
|
+ ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
|
|
|
+ IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
|
|
|
+ OpenPopupEx(id, true);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
// This is a helper to handle the simplest case of associating one named popup to one given widget.
|
|
// This is a helper to handle the simplest case of associating one named popup to one given widget.
|
|
-// 1. If you have many possible popups (for different "instances" of a same widget, or for wholly different widgets), you may be better off handling
|
|
|
|
-// this yourself so you can store data relative to the widget that opened the popup instead of choosing different popup identifiers.
|
|
|
|
-// 2. If you want right-clicking on the same item to reopen the popup at new location, use the same code replacing IsItemHovered() with IsItemRectHovered()
|
|
|
|
-// and passing true to the OpenPopupEx().
|
|
|
|
-// This is because hovering an item in a window below the popup won't work. IsItemRectHovered() skips this test.
|
|
|
|
-// The pattern of ignoring the fact that the item can be interacted with (because it is blocked by the active popup) may useful in some situation
|
|
|
|
-// when e.g. large canvas where the content of menu driven by click position.
|
|
|
|
|
|
+// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
|
|
|
+// You can pass a NULL str_id to use the identifier of the last item.
|
|
bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
|
|
bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
|
|
{
|
|
{
|
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
|
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
|
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
|
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
|
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
|
- if (IsMouseClicked(mouse_button))
|
|
|
|
- if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
|
- OpenPopupEx(id, true);
|
|
|
|
|
|
+ if (IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
|
+ OpenPopupEx(id, true);
|
|
return BeginPopupEx(id, ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_AlwaysAutoResize);
|
|
return BeginPopupEx(id, ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_AlwaysAutoResize);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -9575,8 +9582,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
value_changed |= value_changed_as_float |= DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
|
|
value_changed |= value_changed_as_float |= DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
|
|
else
|
|
else
|
|
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
|
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
|
- if (!(flags & ImGuiColorEditFlags_NoOptions) && IsItemHovered() && IsMouseClicked(1))
|
|
|
|
- OpenPopup("context");
|
|
|
|
|
|
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
|
+ OpenPopupOnItemClick("context");
|
|
}
|
|
}
|
|
PopItemWidth();
|
|
PopItemWidth();
|
|
PopItemWidth();
|
|
PopItemWidth();
|
|
@@ -9602,8 +9609,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
else
|
|
else
|
|
sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]);
|
|
sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]);
|
|
}
|
|
}
|
|
- if (!(flags & ImGuiColorEditFlags_NoOptions) && IsItemHovered() && IsMouseClicked(1))
|
|
|
|
- OpenPopup("context");
|
|
|
|
|
|
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
|
+ OpenPopupOnItemClick("context");
|
|
PopItemWidth();
|
|
PopItemWidth();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -9624,9 +9631,9 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y));
|
|
SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!(flags & ImGuiColorEditFlags_NoOptions) && IsItemHovered() && IsMouseClicked(1))
|
|
|
|
- OpenPopup("context");
|
|
|
|
-
|
|
|
|
|
|
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
|
+ OpenPopupOnItemClick("context");
|
|
|
|
+
|
|
if (BeginPopup("picker"))
|
|
if (BeginPopup("picker"))
|
|
{
|
|
{
|
|
picker_active = true;
|
|
picker_active = true;
|
|
@@ -9791,8 +9798,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
value_changed = value_changed_sv = true;
|
|
value_changed = value_changed_sv = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!(flags & ImGuiColorEditFlags_NoOptions) && IsItemHovered() && IsMouseClicked(1))
|
|
|
|
- OpenPopup("context");
|
|
|
|
|
|
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
|
+ OpenPopupOnItemClick("context");
|
|
}
|
|
}
|
|
else if (flags & ImGuiColorEditFlags_PickerHueBar)
|
|
else if (flags & ImGuiColorEditFlags_PickerHueBar)
|
|
{
|
|
{
|
|
@@ -9804,8 +9811,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1));
|
|
V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1));
|
|
value_changed = value_changed_sv = true;
|
|
value_changed = value_changed_sv = true;
|
|
}
|
|
}
|
|
- if (!(flags & ImGuiColorEditFlags_NoOptions) && IsItemHovered() && IsMouseClicked(1))
|
|
|
|
- OpenPopup("context");
|
|
|
|
|
|
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
|
+ OpenPopupOnItemClick("context");
|
|
|
|
|
|
// Hue bar logic
|
|
// Hue bar logic
|
|
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|
|
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|