Skip to content

Commit

Permalink
ui: Limit window title length
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Nov 4, 2022
1 parent 48e9d3b commit 291da64
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
lib/external/** linguist-vendored
lib/libimhex-rs/imgui-rs/** linguist-vendored
lib/libimhex-rs/imgui-sys/** linguist-vendored
lib/external/** linguist-vendored
2 changes: 1 addition & 1 deletion lib/external/pattern_language
4 changes: 3 additions & 1 deletion main/source/window/win_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ namespace hex {
void Window::drawTitleBar() {
if (!ImHexApi::System::isBorderlessWindowModeEnabled()) return;

auto startX = ImGui::GetCursorPosX();

auto buttonSize = ImVec2(g_titleBarHeight * 1.5F, g_titleBarHeight - 1);

ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
Expand Down Expand Up @@ -382,7 +384,7 @@ namespace hex {
ImGui::PopStyleColor(5);
ImGui::PopStyleVar();

ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize(this->m_windowTitle.c_str()).x) / 2);
ImGui::SetCursorPosX(std::max(startX, (ImGui::GetWindowWidth() - ImGui::CalcTextSize(this->m_windowTitle.c_str()).x) / 2));
ImGui::TextUnformatted(this->m_windowTitle.c_str());
}

Expand Down
2 changes: 1 addition & 1 deletion main/source/window/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace hex {
if (ImHexApi::Provider::isValid()) {
auto provider = ImHexApi::Provider::get();
if (!windowTitle.empty() && provider != nullptr) {
title += " - " + windowTitle;
title += " - " + hex::limitStringLength(windowTitle, 32);

if (provider->isDirty())
title += " (*)";
Expand Down

0 comments on commit 291da64

Please sign in to comment.