Skip to content

Commit

Permalink
update hello_imgui (Test Engine: can re-call params.callbacks.Registe…
Browse files Browse the repository at this point in the history
…rTests)
  • Loading branch information
pthom committed Jan 16, 2024
1 parent 20eecc0 commit 745ded6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion bindings/imgui_bundle/hello_imgui.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,11 @@ class RunnerCallbacks:
# `RegisterTests`: A function that is called once ImGuiTestEngine is ready
# to be filled with tests and automations definitions.
register_tests: VoidFunction = EmptyVoidFunction()
# bool registerTestsCalled = false; /* original C++ signature */
# `registerTestsCalled`: will be set to True when RegisterTests was called
# (you can set this to False if you want to RegisterTests to be called again
# during the app execution)
register_tests_called: bool = False

# --------------- Exit sequence callbacks -------------------

Expand Down Expand Up @@ -1484,7 +1489,7 @@ class RunnerCallbacks:
any_backend_event_callback: AnyEventCallback = EmptyEventCallback()

# --------------- Mobile callbacks -------------------
# RunnerCallbacks(VoidFunction ShowGui = EmptyVoidFunction(), VoidFunction ShowMenus = EmptyVoidFunction(), VoidFunction ShowAppMenuItems = EmptyVoidFunction(), VoidFunction ShowStatus = EmptyVoidFunction(), VoidFunction PostInit_AddPlatformBackendCallbacks = EmptyVoidFunction(), VoidFunction PostInit = EmptyVoidFunction(), VoidFunction LoadAdditionalFonts = (VoidFunction)(ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons), VoidFunction SetupImGuiConfig = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiConfig), VoidFunction SetupImGuiStyle = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiStyle), VoidFunction RegisterTests = EmptyVoidFunction(), VoidFunction BeforeExit = EmptyVoidFunction(), VoidFunction BeforeExit_PostCleanup = EmptyVoidFunction(), VoidFunction PreNewFrame = EmptyVoidFunction(), VoidFunction BeforeImGuiRender = EmptyVoidFunction(), VoidFunction AfterSwap = EmptyVoidFunction(), VoidFunction CustomBackground = EmptyVoidFunction(), AnyEventCallback AnyBackendEventCallback = EmptyEventCallback()); /* original C++ signature */
# RunnerCallbacks(VoidFunction ShowGui = EmptyVoidFunction(), VoidFunction ShowMenus = EmptyVoidFunction(), VoidFunction ShowAppMenuItems = EmptyVoidFunction(), VoidFunction ShowStatus = EmptyVoidFunction(), VoidFunction PostInit_AddPlatformBackendCallbacks = EmptyVoidFunction(), VoidFunction PostInit = EmptyVoidFunction(), VoidFunction LoadAdditionalFonts = (VoidFunction)(ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons), VoidFunction SetupImGuiConfig = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiConfig), VoidFunction SetupImGuiStyle = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiStyle), VoidFunction RegisterTests = EmptyVoidFunction(), bool registerTestsCalled = false, VoidFunction BeforeExit = EmptyVoidFunction(), VoidFunction BeforeExit_PostCleanup = EmptyVoidFunction(), VoidFunction PreNewFrame = EmptyVoidFunction(), VoidFunction BeforeImGuiRender = EmptyVoidFunction(), VoidFunction AfterSwap = EmptyVoidFunction(), VoidFunction CustomBackground = EmptyVoidFunction(), AnyEventCallback AnyBackendEventCallback = EmptyEventCallback()); /* original C++ signature */
def __init__(
self,
show_gui: VoidFunction = EmptyVoidFunction(),
Expand All @@ -1503,6 +1508,7 @@ class RunnerCallbacks:
ImGuiDefaultSettings.SetupDefaultImGuiStyle
),
register_tests: VoidFunction = EmptyVoidFunction(),
register_tests_called: bool = False,
before_exit: VoidFunction = EmptyVoidFunction(),
before_exit_post_cleanup: VoidFunction = EmptyVoidFunction(),
pre_new_frame: VoidFunction = EmptyVoidFunction(),
Expand Down
4 changes: 4 additions & 0 deletions external/hello_imgui/bindings/hello_imgui_amalgamation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,10 @@ struct RunnerCallbacks
// `RegisterTests`: A function that is called once ImGuiTestEngine is ready
// to be filled with tests and automations definitions.
VoidFunction RegisterTests = EmptyVoidFunction();
// `registerTestsCalled`: will be set to true when RegisterTests was called
// (you can set this to false if you want to RegisterTests to be called again
// during the app execution)
bool registerTestsCalled = false;


// --------------- Exit sequence callbacks -------------------
Expand Down
6 changes: 4 additions & 2 deletions external/hello_imgui/bindings/pybind_hello_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void py_init_module_hello_imgui(py::module& m)
py::class_<HelloImGui::RunnerCallbacks>
(m, "RunnerCallbacks", " RunnerCallbacks is a struct that contains the callbacks\n that are called by the application\n")
.def(py::init<>([](
VoidFunction ShowGui = HelloImGui::EmptyVoidFunction(), VoidFunction ShowMenus = HelloImGui::EmptyVoidFunction(), VoidFunction ShowAppMenuItems = HelloImGui::EmptyVoidFunction(), VoidFunction ShowStatus = HelloImGui::EmptyVoidFunction(), VoidFunction PostInit_AddPlatformBackendCallbacks = HelloImGui::EmptyVoidFunction(), VoidFunction PostInit = HelloImGui::EmptyVoidFunction(), VoidFunction LoadAdditionalFonts = (VoidFunction)(ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons), VoidFunction SetupImGuiConfig = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiConfig), VoidFunction SetupImGuiStyle = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiStyle), VoidFunction RegisterTests = HelloImGui::EmptyVoidFunction(), VoidFunction BeforeExit = HelloImGui::EmptyVoidFunction(), VoidFunction BeforeExit_PostCleanup = HelloImGui::EmptyVoidFunction(), VoidFunction PreNewFrame = HelloImGui::EmptyVoidFunction(), VoidFunction BeforeImGuiRender = HelloImGui::EmptyVoidFunction(), VoidFunction AfterSwap = HelloImGui::EmptyVoidFunction(), VoidFunction CustomBackground = HelloImGui::EmptyVoidFunction(), AnyEventCallback AnyBackendEventCallback = HelloImGui::EmptyEventCallback())
VoidFunction ShowGui = HelloImGui::EmptyVoidFunction(), VoidFunction ShowMenus = HelloImGui::EmptyVoidFunction(), VoidFunction ShowAppMenuItems = HelloImGui::EmptyVoidFunction(), VoidFunction ShowStatus = HelloImGui::EmptyVoidFunction(), VoidFunction PostInit_AddPlatformBackendCallbacks = HelloImGui::EmptyVoidFunction(), VoidFunction PostInit = HelloImGui::EmptyVoidFunction(), VoidFunction LoadAdditionalFonts = (VoidFunction)(ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons), VoidFunction SetupImGuiConfig = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiConfig), VoidFunction SetupImGuiStyle = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiStyle), VoidFunction RegisterTests = HelloImGui::EmptyVoidFunction(), bool registerTestsCalled = false, VoidFunction BeforeExit = HelloImGui::EmptyVoidFunction(), VoidFunction BeforeExit_PostCleanup = HelloImGui::EmptyVoidFunction(), VoidFunction PreNewFrame = HelloImGui::EmptyVoidFunction(), VoidFunction BeforeImGuiRender = HelloImGui::EmptyVoidFunction(), VoidFunction AfterSwap = HelloImGui::EmptyVoidFunction(), VoidFunction CustomBackground = HelloImGui::EmptyVoidFunction(), AnyEventCallback AnyBackendEventCallback = HelloImGui::EmptyEventCallback())
{
auto r = std::make_unique<RunnerCallbacks>();
r->ShowGui = ShowGui;
Expand All @@ -652,6 +652,7 @@ void py_init_module_hello_imgui(py::module& m)
r->SetupImGuiConfig = SetupImGuiConfig;
r->SetupImGuiStyle = SetupImGuiStyle;
r->RegisterTests = RegisterTests;
r->registerTestsCalled = registerTestsCalled;
r->BeforeExit = BeforeExit;
r->BeforeExit_PostCleanup = BeforeExit_PostCleanup;
r->PreNewFrame = PreNewFrame;
Expand All @@ -661,7 +662,7 @@ void py_init_module_hello_imgui(py::module& m)
r->AnyBackendEventCallback = AnyBackendEventCallback;
return r;
})
, py::arg("show_gui") = HelloImGui::EmptyVoidFunction(), py::arg("show_menus") = HelloImGui::EmptyVoidFunction(), py::arg("show_app_menu_items") = HelloImGui::EmptyVoidFunction(), py::arg("show_status") = HelloImGui::EmptyVoidFunction(), py::arg("post_init_add_platform_backend_callbacks") = HelloImGui::EmptyVoidFunction(), py::arg("post_init") = HelloImGui::EmptyVoidFunction(), py::arg("load_additional_fonts") = (VoidFunction)(ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons), py::arg("setup_imgui_config") = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiConfig), py::arg("setup_imgui_style") = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiStyle), py::arg("register_tests") = HelloImGui::EmptyVoidFunction(), py::arg("before_exit") = HelloImGui::EmptyVoidFunction(), py::arg("before_exit_post_cleanup") = HelloImGui::EmptyVoidFunction(), py::arg("pre_new_frame") = HelloImGui::EmptyVoidFunction(), py::arg("before_imgui_render") = HelloImGui::EmptyVoidFunction(), py::arg("after_swap") = HelloImGui::EmptyVoidFunction(), py::arg("custom_background") = HelloImGui::EmptyVoidFunction(), py::arg("any_backend_event_callback") = HelloImGui::EmptyEventCallback()
, py::arg("show_gui") = HelloImGui::EmptyVoidFunction(), py::arg("show_menus") = HelloImGui::EmptyVoidFunction(), py::arg("show_app_menu_items") = HelloImGui::EmptyVoidFunction(), py::arg("show_status") = HelloImGui::EmptyVoidFunction(), py::arg("post_init_add_platform_backend_callbacks") = HelloImGui::EmptyVoidFunction(), py::arg("post_init") = HelloImGui::EmptyVoidFunction(), py::arg("load_additional_fonts") = (VoidFunction)(ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons), py::arg("setup_imgui_config") = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiConfig), py::arg("setup_imgui_style") = (VoidFunction)(ImGuiDefaultSettings::SetupDefaultImGuiStyle), py::arg("register_tests") = HelloImGui::EmptyVoidFunction(), py::arg("register_tests_called") = false, py::arg("before_exit") = HelloImGui::EmptyVoidFunction(), py::arg("before_exit_post_cleanup") = HelloImGui::EmptyVoidFunction(), py::arg("pre_new_frame") = HelloImGui::EmptyVoidFunction(), py::arg("before_imgui_render") = HelloImGui::EmptyVoidFunction(), py::arg("after_swap") = HelloImGui::EmptyVoidFunction(), py::arg("custom_background") = HelloImGui::EmptyVoidFunction(), py::arg("any_backend_event_callback") = HelloImGui::EmptyEventCallback()
)
.def_readwrite("show_gui", &RunnerCallbacks::ShowGui, "`ShowGui`: Fill it with a function that will add your widgets.")
.def_readwrite("show_menus", &RunnerCallbacks::ShowMenus, " `ShowMenus`: Fill it with a function that will add ImGui menus by calling:\n ImGui::BeginMenu(...) / ImGui::MenuItem(...) / ImGui::EndMenu()\n Notes:\n * you do not need to call ImGui::BeginMenuBar and ImGui::EndMenuBar\n * Some default menus can be provided:\n see ImGuiWindowParams options:\n _showMenuBar, showMenu_App_QuitAbout, showMenu_View_")
Expand All @@ -682,6 +683,7 @@ void py_init_module_hello_imgui(py::module& m)
.def_readwrite("setup_imgui_config", &RunnerCallbacks::SetupImGuiConfig, " `SetupImGuiConfig`: default=_ImGuiDefaultSettings::SetupDefaultImGuiConfig*.\n If needed, change ImGui config via SetupImGuiConfig\n (enable docking, gamepad, etc)")
.def_readwrite("setup_imgui_style", &RunnerCallbacks::SetupImGuiStyle, " `SetupImGuiStyle`: default=_ImGuiDefaultSettings::SetupDefaultImGuiConfig*.\n If needed, set your own style by providing your own SetupImGuiStyle callback")
.def_readwrite("register_tests", &RunnerCallbacks::RegisterTests, " `RegisterTests`: A function that is called once ImGuiTestEngine is ready\n to be filled with tests and automations definitions.")
.def_readwrite("register_tests_called", &RunnerCallbacks::registerTestsCalled, " `registerTestsCalled`: will be set to True when RegisterTests was called\n (you can set this to False if you want to RegisterTests to be called again\n during the app execution)")
.def_readwrite("before_exit", &RunnerCallbacks::BeforeExit, " `BeforeExit`: You can here add a function that will be called once before exiting\n (when OpenGL and ImGui are still inited)")
.def("enqueue_before_exit",
&RunnerCallbacks::EnqueueBeforeExit,
Expand Down

0 comments on commit 745ded6

Please sign in to comment.