From f20ee48ec38e5f49b768fa22c8f8f0d02a50d843 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Wed, 27 Sep 2023 13:41:43 +0200 Subject: [PATCH] Add RunnerParams.useImGuiTestEngine --- .../internal/backend_impls/abstract_runner.cpp | 3 ++- src/hello_imgui/runner_params.h | 12 ++++++++++++ .../hello_imgui_demo_test_engine.main.cpp | 1 + src/hello_imgui_test_engine_integration/todo_test.md | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 551654b1..558394c8 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -333,7 +333,8 @@ void AbstractRunner::LayoutSettings_Save() void AbstractRunner::Setup() { #ifdef HELLOIMGUI_WITH_TEST_ENGINE - _AddTestEngineCallbacks(&this->params); + if (params.useImGuiTestEngine) + _AddTestEngineCallbacks(&this->params); #endif Impl_InitBackend(); diff --git a/src/hello_imgui/runner_params.h b/src/hello_imgui/runner_params.h index 18721b6a..94161df6 100644 --- a/src/hello_imgui/runner_params.h +++ b/src/hello_imgui/runner_params.h @@ -70,6 +70,8 @@ struct FpsIdling Select the wanted backend type between `Sdl`, `Glfw` and `Qt`. Only useful when multiple backend are compiled and available. * `fpsIdling`: _FpsIdling_. Idling parameters (set fpsIdling.enableIdling to false to disable Idling) +* `useImGuiTestEngine`: _bool, default=false_. + Set this to true if you intend to use imgui_test_engine (please read note below) * `iniFilename`: _string, default = ""_ Sets the ini filename under which imgui will save its params. Path is relative to the current app working dir. If empty, then the ini file name will be derived from appWindowParams.windowTitle (if both are empty, the ini filename will be imgui.ini). @@ -82,6 +84,13 @@ struct FpsIdling shall not exit._ * `emscripten_fps`: _int, default = 0_. Set the application refresh rate (only used on emscripten: 0 stands for "let the app or the browser decide") + +Notes about the use of [Dear ImGui Test & Automation Engine](https://github.com/ocornut/imgui_test_engine): +* HelloImGui must be compiled with the option HELLOIMGUI_WITH_TEST_ENGINE (-DHELLOIMGUI_WITH_TEST_ENGINE=ON) +* See demo in src/hello_imgui_demos/hello_imgui_demo_test_engine. +* imgui_test_engine is subject to a [specific license](https://github.com/ocornut/imgui_test_engine/blob/main/imgui_test_engine/LICENSE.txt) + TL;DR: free for individuals, educational, open-source and small businesses uses. Paid for larger businesses. + @@md */ struct RunnerParams @@ -96,8 +105,11 @@ struct RunnerParams BackendPointers backendPointers; BackendType backendType = BackendType::FirstAvailable; + FpsIdling fpsIdling; + bool useImGuiTestEngine = false; + std::string iniFilename = ""; bool iniFilename_useAppWindowTitle = true; diff --git a/src/hello_imgui_demos/hello_imgui_demo_test_engine/hello_imgui_demo_test_engine.main.cpp b/src/hello_imgui_demos/hello_imgui_demo_test_engine/hello_imgui_demo_test_engine.main.cpp index 7ab12428..49f28b19 100644 --- a/src/hello_imgui_demos/hello_imgui_demo_test_engine/hello_imgui_demo_test_engine.main.cpp +++ b/src/hello_imgui_demos/hello_imgui_demo_test_engine/hello_imgui_demo_test_engine.main.cpp @@ -93,6 +93,7 @@ int main(int, char *[]) { HelloImGui::RunnerParams runnerParams; runnerParams.callbacks.ShowGui = Gui; + runnerParams.useImGuiTestEngine = true; #ifdef HELLOIMGUI_WITH_TEST_ENGINE runnerParams.callbacks.PostInit = [](){ diff --git a/src/hello_imgui_test_engine_integration/todo_test.md b/src/hello_imgui_test_engine_integration/todo_test.md index 3e644c3b..c9f1e5fe 100644 --- a/src/hello_imgui_test_engine_integration/todo_test.md +++ b/src/hello_imgui_test_engine_integration/todo_test.md @@ -1,4 +1,8 @@ check uses of HELLOIMGUI_WITH_TEST_ENGINE vs IMGUI_ENABLE_TEST_ENGINE +HELLOIMGUI_WITH_TEST_ENGINE default ON or OFF ? + OFF dans HelloImGui ? + ON dans imGui Bundle ? + Config: Study params