From 72ef39db6067bb9d4b4ac9445c1d20e38daba821 Mon Sep 17 00:00:00 2001 From: YohananDiamond Date: Mon, 3 Apr 2023 00:05:25 -0300 Subject: [PATCH 1/2] New song dialog: auto focus on pop up + reset search box --- src/gui/gui.cpp | 1 + src/gui/newSong.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 6213bdfd..2f96b897 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4840,6 +4840,7 @@ bool FurnaceGUI::loop() { } if (displayNew) { + newSongQuery = ""; displayNew=false; ImGui::OpenPopup("New Song"); } diff --git a/src/gui/newSong.cpp b/src/gui/newSong.cpp index 8fdafeb9..08155412 100644 --- a/src/gui/newSong.cpp +++ b/src/gui/newSong.cpp @@ -23,6 +23,9 @@ #include void FurnaceGUI::drawNewSong() { + // Be sure to reset this to true when the popup is closed + static bool firstFrame = true; + bool accepted=false; ImGui::PushFont(bigFont); @@ -34,6 +37,10 @@ void FurnaceGUI::drawNewSong() { avail.y-=ImGui::GetFrameHeightWithSpacing(); if (ImGui::BeginChild("sysPickerC",avail,false,ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar)) { + if (firstFrame) { + ImGui::SetKeyboardFocusHere(); + firstFrame = false; + } ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); if (ImGui::InputTextWithHint("##SysSearch","Search...",&newSongQuery)) { String lowerCase=newSongQuery; @@ -122,10 +129,12 @@ void FurnaceGUI::drawNewSong() { if (ImGui::Button("I'm feeling lucky")) { if (sysCategories.size()==0) { + firstFrame = true; ImGui::CloseCurrentPopup(); } else { FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()]; if (newSystemCat->systems.size()==0) { + firstFrame = true; ImGui::CloseCurrentPopup(); } else { unsigned int selection=rand()%newSystemCat->systems.size(); @@ -139,6 +148,7 @@ void FurnaceGUI::drawNewSong() { ImGui::SameLine(); if (ImGui::Button("Cancel")) { + firstFrame = true; ImGui::CloseCurrentPopup(); } @@ -157,6 +167,7 @@ void FurnaceGUI::drawNewSong() { selEnd=SelectionPoint(); cursor=SelectionPoint(); updateWindowTitle(); + firstFrame = true; ImGui::CloseCurrentPopup(); } } From c3654a4d525ad40bfa1c158a7fab25a853c002b6 Mon Sep 17 00:00:00 2001 From: YohananDiamond Date: Mon, 3 Apr 2023 11:11:26 -0300 Subject: [PATCH 2/2] Applying corrections --- src/gui/gui.cpp | 3 ++- src/gui/gui.h | 1 + src/gui/newSong.cpp | 13 +++---------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2f96b897..66e57df0 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4840,7 +4840,8 @@ bool FurnaceGUI::loop() { } if (displayNew) { - newSongQuery = ""; + newSongQuery=""; + newSongFirstFrame=true; displayNew=false; ImGui::OpenPopup("New Song"); } diff --git a/src/gui/gui.h b/src/gui/gui.h index cf18f7e8..e75ee91b 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1564,6 +1564,7 @@ class FurnaceGUI { double exportFadeOut; + bool newSongFirstFrame; bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen; bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen; bool mixerOpen, debugOpen, inspectorOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen; diff --git a/src/gui/newSong.cpp b/src/gui/newSong.cpp index 08155412..735f8bfb 100644 --- a/src/gui/newSong.cpp +++ b/src/gui/newSong.cpp @@ -23,9 +23,6 @@ #include void FurnaceGUI::drawNewSong() { - // Be sure to reset this to true when the popup is closed - static bool firstFrame = true; - bool accepted=false; ImGui::PushFont(bigFont); @@ -37,10 +34,8 @@ void FurnaceGUI::drawNewSong() { avail.y-=ImGui::GetFrameHeightWithSpacing(); if (ImGui::BeginChild("sysPickerC",avail,false,ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar)) { - if (firstFrame) { + if (newSongFirstFrame) ImGui::SetKeyboardFocusHere(); - firstFrame = false; - } ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); if (ImGui::InputTextWithHint("##SysSearch","Search...",&newSongQuery)) { String lowerCase=newSongQuery; @@ -129,12 +124,10 @@ void FurnaceGUI::drawNewSong() { if (ImGui::Button("I'm feeling lucky")) { if (sysCategories.size()==0) { - firstFrame = true; ImGui::CloseCurrentPopup(); } else { FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()]; if (newSystemCat->systems.size()==0) { - firstFrame = true; ImGui::CloseCurrentPopup(); } else { unsigned int selection=rand()%newSystemCat->systems.size(); @@ -148,7 +141,6 @@ void FurnaceGUI::drawNewSong() { ImGui::SameLine(); if (ImGui::Button("Cancel")) { - firstFrame = true; ImGui::CloseCurrentPopup(); } @@ -167,7 +159,8 @@ void FurnaceGUI::drawNewSong() { selEnd=SelectionPoint(); cursor=SelectionPoint(); updateWindowTitle(); - firstFrame = true; ImGui::CloseCurrentPopup(); } + + newSongFirstFrame=false; }