ui: Update Dear ImGui API

This commit is contained in:
Matt Borgerson 2023-07-20 22:27:27 -07:00 committed by mborgerson
parent 81935947dc
commit 1a5dff927d
4 changed files with 9 additions and 15 deletions

View file

@ -1257,8 +1257,8 @@ void MainMenuScene::HandleInput()
// XXX: Ensure we have focus for two frames. If a user cancels a popup window, we do not want to cancel main
// window as well.
if (nofocus || (focus && m_had_focus_last_frame &&
ImGui::IsNavInputTest(ImGuiNavInput_Cancel,
ImGuiInputReadMode_Pressed))) {
(ImGui::IsKeyDown(ImGuiKey_GamepadFaceRight)
|| ImGui::IsKeyDown(ImGuiKey_Escape)))) {
Hide();
return;
}

View file

@ -284,7 +284,7 @@ void xemu_hud_render(void)
bool mod_key_down = ImGui::IsKeyDown(ImGuiKey_ModShift);
for (int f_key = 0; f_key < 4; ++f_key) {
if (ImGui::IsKeyPressed(f_key + ImGuiKey_F5)) {
if (ImGui::IsKeyPressed((enum ImGuiKey)(ImGuiKey_F5 + f_key))) {
ActionActivateBoundSnapshot(f_key, mod_key_down);
break;
}

View file

@ -28,13 +28,6 @@ extern "C" {
#include <noc_file_dialog.h>
}
static inline
bool IsNavInputPressed(ImGuiNavInput i) {
ImGuiIO &io = ImGui::GetIO();
return io.NavInputs[i] > 0.0f && io.NavInputsDownDuration[i] == 0.0f;
}
static inline const char *PausedFileOpen(int flags, const char *filters,
const char *default_path,
const char *default_name)
@ -67,7 +60,7 @@ static inline bool IsShortcutKeyPressed(int scancode)
ImGuiIO& io = ImGui::GetIO();
const bool is_osx = io.ConfigMacOSXBehaviors;
const bool is_shortcut_key = (is_osx ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
return is_shortcut_key && ImGui::IsKeyPressed(scancode);
return is_shortcut_key && ImGui::IsKeyPressed((enum ImGuiKey)scancode);
}
static inline float mix(float a, float b, float t)

View file

@ -459,9 +459,9 @@ void PopupMenuScene::PopFocus()
m_focus_stack.pop_back();
ImGuiContext *g = ImGui::GetCurrentContext();
g->NavInitRequest = false;
g->NavInitResultId = next_focus.first;
g->NavInitResultRectRel = ImGui::WindowRectAbsToRel(g->CurrentWindow,
next_focus.second);
g->NavInitResult.ID = next_focus.first;
g->NavInitResult.RectRel = ImGui::WindowRectAbsToRel(g->CurrentWindow,
next_focus.second);
// ImGui::NavUpdateAnyRequestFlag();
g->NavAnyRequest = g->NavMoveScoringItems || g->NavInitRequest;// || (IMGUI_DEBUG_NAV_SCORING && g->NavWindow != NULL);
}
@ -480,7 +480,8 @@ void PopupMenuScene::ClearMenuStack()
void PopupMenuScene::HandleInput()
{
if (IsNavInputPressed(ImGuiNavInput_Cancel)) {
if (ImGui::IsKeyPressed(ImGuiKey_GamepadFaceRight, false)
|| ImGui::IsKeyPressed(ImGuiKey_Escape, false)) {
PopMenu();
}
}