imgui: fix nav with dock & fps display disabled by default

This commit is contained in:
Vinicius Rangel 2024-10-03 21:32:03 -03:00
parent da519f9091
commit 09973ba022
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
2 changed files with 11 additions and 7 deletions

View File

@ -17,7 +17,7 @@ using namespace ImGui;
using namespace Core::Devtools; using namespace Core::Devtools;
using L = Core::Devtools::Layer; using L = Core::Devtools::Layer;
static bool show_simple_fps = false; static bool show_simple_fps = true;
static bool show_advanced_debug = false; static bool show_advanced_debug = false;
static int dump_frame_count = 1; static int dump_frame_count = 1;
@ -149,9 +149,7 @@ void L::SetupSettings() {
}; };
handler.ReadLineFn = [](ImGuiContext*, ImGuiSettingsHandler*, void*, const char* line) { handler.ReadLineFn = [](ImGuiContext*, ImGuiSettingsHandler*, void*, const char* line) {
int v; int v;
if (sscanf(line, "show_simple_fps=%d", &v) == 1) { if (sscanf(line, "show_advanced_debug=%d", &v) == 1) {
show_simple_fps = v != 0;
} else if (sscanf(line, "show_advanced_debug=%d", &v) == 1) {
show_advanced_debug = v != 0; show_advanced_debug = v != 0;
} else if (sscanf(line, "show_frame_graph=%d", &v) == 1) { } else if (sscanf(line, "show_frame_graph=%d", &v) == 1) {
frame_graph.is_open = v != 0; frame_graph.is_open = v != 0;
@ -161,7 +159,6 @@ void L::SetupSettings() {
}; };
handler.WriteAllFn = [](ImGuiContext*, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) { handler.WriteAllFn = [](ImGuiContext*, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) {
buf->appendf("[%s][Data]\n", handler->TypeName); buf->appendf("[%s][Data]\n", handler->TypeName);
buf->appendf("show_simple_fps=%d\n", show_simple_fps);
buf->appendf("show_advanced_debug=%d\n", show_advanced_debug); buf->appendf("show_advanced_debug=%d\n", show_advanced_debug);
buf->appendf("show_frame_graph=%d\n", frame_graph.is_open); buf->appendf("show_frame_graph=%d\n", frame_graph.is_open);
buf->appendf("dump_frame_count=%d\n", dump_frame_count); buf->appendf("dump_frame_count=%d\n", dump_frame_count);

View File

@ -35,6 +35,7 @@ std::deque<std::pair<bool, ImGui::Layer*>>& GetChangeLayers() {
} }
static std::mutex change_layers_mutex{}; static std::mutex change_layers_mutex{};
static ImGuiID dock_id;
namespace ImGui { namespace ImGui {
@ -106,6 +107,10 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w
Vulkan::Init(vk_info); Vulkan::Init(vk_info);
TextureManager::StartWorker(); TextureManager::StartWorker();
char label[32];
ImFormatString(label, IM_ARRAYSIZE(label), "WindowOverViewport_%08X", GetMainViewport()->ID);
dock_id = ImHashStr(label);
} }
void OnResize() { void OnResize() {
@ -147,8 +152,10 @@ bool ProcessEvent(SDL_Event* event) {
case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
case SDL_EVENT_GAMEPAD_AXIS_MOTION: case SDL_EVENT_GAMEPAD_AXIS_MOTION:
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN: case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION: case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION: {
return GetIO().NavActive; const auto& io = GetIO();
return io.NavActive && io.Ctx->NavWindow != nullptr && io.Ctx->NavWindow->ID != dock_id;
}
default: default:
return false; return false;
} }