Added UI helper function for tooltips

This commit is contained in:
Antoine Pilote
2024-08-27 22:54:39 -04:00
parent c01d6e960c
commit e34ba3abac
2 changed files with 18 additions and 0 deletions

View File

@@ -174,5 +174,21 @@ namespace Nuake {
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), ImGui::GetColorU32(*v ? colors[ImGuiCol_Button] : ImVec4(0.85f, 0.85f, 0.85f, 1.0f)), height * 0.50f);
draw_list->AddCircleFilled(ImVec2(p.x + radius + (*v ? 1 : 0) * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 255));
}
void Tooltip(const std::string& message)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(450.0f);
ImGui::TextUnformatted(message.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
ImGui::PopStyleVar();
}
}
}

View File

@@ -31,5 +31,7 @@ namespace Nuake
bool CheckBox(const std::string& name, bool& value);
void ToggleButton(const char* str_id, bool* v);
void Tooltip(const std::string& message);
}
}