summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorEblo <7004497+Eblo@users.noreply.github.com>2025-10-15 12:57:58 -0400
committerGitHub <noreply@github.com>2025-10-15 12:57:58 -0400
commitcc88b5aa0578ea0261780fec90cfb86afc4f1ef2 (patch)
tree3df60fdd2cf85c37c689c9cc4263f7331a0ac67a /mm
parentc95a7739f92465d3fc2e1a4eca2912ec47c2ed3a (diff)
Fix search autofocus bug, increase vibrancy (#1290)
Diffstat (limited to 'mm')
-rw-r--r--mm/2s2h/BenGui/Menu.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/mm/2s2h/BenGui/Menu.cpp b/mm/2s2h/BenGui/Menu.cpp
index 27ab9c46d..b0b5a9a63 100644
--- a/mm/2s2h/BenGui/Menu.cpp
+++ b/mm/2s2h/BenGui/Menu.cpp
@@ -494,6 +494,7 @@ void Menu::Draw() {
SyncVisibilityConsoleVariable();
}
+static bool freshOpen = true;
void Menu::DrawElement() {
for (auto& [reason, info] : disabledMap) {
info.active = info.evaluation(info);
@@ -531,6 +532,7 @@ void Menu::DrawElement() {
if (!popout) {
ImGui::PopStyleVar();
}
+ freshOpen = true;
ImGui::End();
return;
}
@@ -659,13 +661,13 @@ void Menu::DrawElement() {
std::string menuSearchText = "";
if (headerSearch) {
ImGui::SameLine();
- if (autoFocus && ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !ImGui::IsAnyItemActive() &&
- !ImGui::IsMouseClicked(0)) {
- ImGui::SetKeyboardFocusHere(0);
+ if (autoFocus && freshOpen) {
+ ImGui::SetKeyboardFocusHere();
}
auto color = UIWidgets::ColorValues.at(menuThemeIndex);
- color.w = 0.2f;
+ color.w = 0.6f;
ImGui::PushStyleColor(ImGuiCol_FrameBg, color);
+ ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
menuSearch.Draw("##search", 200.0f);
menuSearchText = menuSearch.InputBuf;
menuSearchText.erase(std::remove(menuSearchText.begin(), menuSearchText.end(), ' '), menuSearchText.end());
@@ -673,6 +675,7 @@ void Menu::DrawElement() {
ImGui::SameLine(headerWidth - 200.0f + style.ItemSpacing.x);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "Search...");
}
+ ImGui::PopStyleVar();
ImGui::PopStyleColor();
}
ImGui::EndChild();
@@ -833,6 +836,9 @@ void Menu::DrawElement() {
poppedSize = ImGui::GetWindowSize();
poppedPos = ImGui::GetWindowPos();
}
+ if (freshOpen) {
+ freshOpen = false;
+ }
ImGui::End();
}
} // namespace Ship