Comments + docs: tidying up todo list + demo tweak for tooltips.

This commit is contained in:
ocornut
2023-06-28 16:01:01 +02:00
parent a02315e1c4
commit 655aae5911
4 changed files with 42 additions and 45 deletions

View File

@ -776,7 +776,7 @@ static void ShowDemoWindowWidgets()
// - Full-form (any contents): if (IsItemHovered(...) && BeginTooltip()) { Text("Hello"); EndTooltip(); }
HelpMarker(
"Tooltip are typically created by using the IsItemHovered() + SetTooltip() functions over any kind of item.\n\n"
"Tooltip are typically created by using a IsItemHovered() + SetTooltip() sequence.\n\n"
"We provide a helper SetItemTooltip() function to perform the two with standards flags.");
ImVec2 sz = ImVec2(-FLT_MIN, 0.0f);
@ -794,13 +794,25 @@ static void ShowDemoWindowWidgets()
ImGui::EndTooltip();
}
ImGui::SeparatorText("Custom");
ImGui::SeparatorText("Always On");
// Showcase NOT relying on a IsItemHovered() to emit a tooltip.
static bool always_on = false;
ImGui::Checkbox("Always On", &always_on);
if (always_on)
// Here the tooltip is always emitted when 'always_on == true'.
static int always_on = 0;
ImGui::RadioButton("Off", &always_on, 0);
ImGui::SameLine();
ImGui::RadioButton("Always On (Simple)", &always_on, 1);
ImGui::SameLine();
ImGui::RadioButton("Always On (Advanced)", &always_on, 2);
if (always_on == 1)
ImGui::SetTooltip("I am following you around.");
else if (always_on == 2 && ImGui::BeginTooltip())
{
ImGui::ProgressBar(sinf((float)ImGui::GetTime()) * 0.5f + 0.5f, ImVec2(ImGui::GetFontSize() * 25, 0.0f));
ImGui::EndTooltip();
}
ImGui::SeparatorText("Custom");
// The following examples are passed for documentation purpose but may not be useful to most users.
// Passing ImGuiHoveredFlags_Tooltip to IsItemHovered() will pull ImGuiHoveredFlags flags values from