fix text shifting in status bar from font scale changes
This commit is contained in:
43
src/app.cpp
43
src/app.cpp
@@ -1223,8 +1223,6 @@ void App::renderStatusBar()
|
|||||||
const float sbIconTextGap = S.drawElement("components.status-bar", "icon-text-gap").size;
|
const float sbIconTextGap = S.drawElement("components.status-bar", "icon-text-gap").size;
|
||||||
const float sbSectionGap = S.drawElement("components.status-bar", "section-gap").size;
|
const float sbSectionGap = S.drawElement("components.status-bar", "section-gap").size;
|
||||||
const float sbSeparatorGap = S.drawElement("components.status-bar", "separator-gap").size;
|
const float sbSeparatorGap = S.drawElement("components.status-bar", "separator-gap").size;
|
||||||
const float sbRightContentOff = S.label("components.status-bar", "right-content").position;
|
|
||||||
const float sbVersionRightOff = S.label("components.status-bar", "version-label").position;
|
|
||||||
|
|
||||||
ImGuiWindowFlags childFlags = ImGuiWindowFlags_NoScrollbar |
|
ImGuiWindowFlags childFlags = ImGuiWindowFlags_NoScrollbar |
|
||||||
ImGuiWindowFlags_NoScrollWithMouse;
|
ImGuiWindowFlags_NoScrollWithMouse;
|
||||||
@@ -1364,19 +1362,36 @@ void App::renderStatusBar()
|
|||||||
ImGui::TextColored(ImVec4(0.6f, 0.8f, 1.0f, 1.0f), "Importing keys%s", dotStr);
|
ImGui::TextColored(ImVec4(0.6f, 0.8f, 1.0f, 1.0f), "Importing keys%s", dotStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right side: connection status message (if any) + version always at far right
|
// Right side: version always at far right, connection status to its left.
|
||||||
float rightStart = ImGui::GetWindowWidth() - sbRightContentOff;
|
// Compute positions dynamically from actual text widths so they
|
||||||
if (!connection_status_.empty() && connection_status_ != "Connected") {
|
// never overlap and always stay within the window at any font scale.
|
||||||
ImGui::SameLine(rightStart);
|
{
|
||||||
ImGui::TextDisabled("%s", connection_status_.c_str());
|
char versionBuf[32];
|
||||||
} else if (!daemon_status_.empty() && daemon_status_.find("Error") != std::string::npos) {
|
snprintf(versionBuf, sizeof(versionBuf), "v%s", DRAGONX_VERSION);
|
||||||
ImGui::SameLine(rightStart);
|
float versionW = ImGui::CalcTextSize(versionBuf).x;
|
||||||
ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.5f, 1.0f), "Daemon not found");
|
float rightPad = sbPadX; // match the left window padding
|
||||||
}
|
float versionX = ImGui::GetWindowWidth() - versionW - rightPad;
|
||||||
|
|
||||||
// Version always at far right
|
// Connection / daemon status sits to the left of the version string
|
||||||
ImGui::SameLine(ImGui::GetWindowWidth() - sbVersionRightOff);
|
// with a small gap.
|
||||||
ImGui::Text("v%s", DRAGONX_VERSION);
|
float gap = sbSectionGap;
|
||||||
|
if (!connection_status_.empty() && connection_status_ != "Connected") {
|
||||||
|
float statusW = ImGui::CalcTextSize(connection_status_.c_str()).x;
|
||||||
|
float statusX = versionX - statusW - gap;
|
||||||
|
ImGui::SameLine(statusX);
|
||||||
|
ImGui::TextDisabled("%s", connection_status_.c_str());
|
||||||
|
} else if (!daemon_status_.empty() && daemon_status_.find("Error") != std::string::npos) {
|
||||||
|
const char* errText = "Daemon not found";
|
||||||
|
float statusW = ImGui::CalcTextSize(errText).x;
|
||||||
|
float statusX = versionX - statusW - gap;
|
||||||
|
ImGui::SameLine(statusX);
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.5f, 1.0f), "%s", errText);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version always at far right
|
||||||
|
ImGui::SameLine(versionX);
|
||||||
|
ImGui::Text("%s", versionBuf);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::PopStyleColor(1); // Text opacity
|
ImGui::PopStyleColor(1); // Text opacity
|
||||||
ImGui::PopFont(); // status bar font
|
ImGui::PopFont(); // status bar font
|
||||||
|
|||||||
Reference in New Issue
Block a user