From 57ac73b9d460d354543d99ee54fbfda53a83af72 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 28 Aug 2025 22:17:19 +0200 Subject: [PATCH] impr: Properly vertically center search icon in search bar --- .../source/content/window_decoration.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index b24495d19..485ced9cc 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -262,14 +262,6 @@ namespace hex::plugin::builtin { ImGui::SetCursorPos(searchBoxPos); if (s_showSearchBar) { - fonts::Default().pushBold(0.8); - #if defined(OS_MACOS) - ImGui::GetWindowDrawList()->AddText(ImGui::GetCursorScreenPos() + ImGui::GetStyle().FramePadding + ImVec2(0, 2_scaled), ImGui::GetColorU32(ImGuiCol_Text), ICON_VS_SEARCH); - #else - ImGui::GetWindowDrawList()->AddText(ImGui::GetCursorScreenPos() + ImGui::GetStyle().FramePadding, ImGui::GetColorU32(ImGuiCol_Text), ICON_VS_SEARCH); - #endif - fonts::Default().pop(); - const auto buttonColor = [](float alpha) { return ImU32(ImColor(ImGui::GetStyleColorVec4(ImGuiCol_DockingEmptyBg) * ImVec4(1, 1, 1, alpha))); }; @@ -279,8 +271,17 @@ namespace hex::plugin::builtin { ImGui::PushStyleColor(ImGuiCol_ButtonActive, buttonColor(0.9F)); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0_scaled); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4_scaled); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, scaled({ 1, 1 })); + const auto style = ImGui::GetStyle(); + fonts::Default().pushBold(0.8); + ImGui::GetWindowDrawList()->AddText( + ImGui::GetCursorScreenPos() + ImVec2(style.FramePadding.x, style.ChildBorderSize + (searchBoxSize.y - ImGui::CalcTextSize(ICON_VS_SEARCH).y) / 2), + ImGui::GetColorU32(ImGuiCol_Text), + ICON_VS_SEARCH + ); + fonts::Default().pop(); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, scaled({ 1, 1 })); if (ImGui::Button(s_windowTitle.c_str(), searchBoxSize)) { EventSearchBoxClicked::post(ImGuiMouseButton_Left);