fix: Centered text not being centered correctly

This commit is contained in:
WerWolv
2023-11-20 21:40:54 +01:00
parent 1e98e641bb
commit 448d792988

View File

@@ -232,7 +232,7 @@ namespace ImGuiExt {
inline void TextFormattedCentered(const std::string &fmt, auto &&...args) {
auto text = hex::format(fmt, std::forward<decltype(args)>(args)...);
auto availableSpace = ImGui::GetContentRegionAvail();
auto textSize = ImGui::CalcTextSize(text.c_str(), nullptr, false);
auto textSize = ImGui::CalcTextSize(text.c_str(), nullptr, false, availableSpace.x * 0.75F);
ImGui::SetCursorPos(((availableSpace - textSize) / 2.0F));
@@ -244,7 +244,7 @@ namespace ImGuiExt {
inline void TextFormattedCenteredHorizontal(const std::string &fmt, auto &&...args) {
auto text = hex::format(fmt, std::forward<decltype(args)>(args)...);
auto availableSpace = ImGui::GetContentRegionAvail();
auto textSize = ImGui::CalcTextSize(text.c_str(), nullptr, false);
auto textSize = ImGui::CalcTextSize(text.c_str(), nullptr, false, availableSpace.x * 0.75F);
ImGui::SetCursorPosX(((availableSpace - textSize) / 2.0F).x);