### hello_globe.main.cpp: Immediate mode GUI with button and image Source: https://pthom.github.io/hello_imgui/book/get-started Example of an immediate mode GUI using Hello ImGui. It displays a label, an image, and a button that exits the app when clicked. Uses HelloImGui::Run to start the application. ```cpp #include "hello_imgui/hello_imgui.h" int main(int , char *[]) { auto guiFunction = []() { ImGui::Text("Hello, "); // Display a simple label HelloImGui::ImageFromAsset("world.png"); // Display a static image if (ImGui::Button("Bye!")) // Display a button // and immediately handle its action if it is clicked! HelloImGui::GetRunnerParams()->appShallExit = true; }; HelloImGui::Run(guiFunction, "Hello, globe", true); return 0; } ``` -------------------------------- ### Manual vcpkg dependency installation and build Source: https://pthom.github.io/hello_imgui/book/building Clones HelloImGui and vcpkg, bootstraps vcpkg, sets VCPKG_ROOT, installs dependencies from vcpkg.json, and builds with CMake. Requires setting VCPKG_ROOT environment variable. ```bash # Clone hello_imgui git clone https://github.com/pthom/hello_imgui.git cd hello_imgui # Clone vcpkg -& bootstrap git clone https://github.com/microsoft/vcpkg.git ./vcpkg/bootstrap-vcpkg.sh export VCPKG_ROOT=$(pwd)/vcpkg # You *need* to set this environment variable # to tell cmake where to find vcpkg # Install dependencies required by hello_imgui # (they will be read from the vcpkg.json file) ./vcpkg/vcpkg install # Build hello_imgui mkdir build && cd build cmake .. -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake cmake --build . -j 4 ``` -------------------------------- ### Launch Python web server for Emscripten testing Source: https://pthom.github.io/hello_imgui/book/building Starts a basic web server to test an Emscripten application. Run from the build_emscripten directory, then open http://localhost:8000 in a browser. ```bash cd build_emscripten python3 -m http.server ``` -------------------------------- ### CMakeLists.txt: hello_imgui_add_app helper function Source: https://pthom.github.io/hello_imgui/book/get-started CMake utility function that simplifies adding an app to a CMake build. It links required libraries, embeds assets, and performs platform-specific customizations. Set HELLOIMGUI_ADD_APP_WITH_INSTALL to OFF to control the install. ```cmake # hello_imgui_add_app is a helper function, similar to cmake's "add_executable" # # Usage: # hello_imgui_add_app(app_name file1.cpp file2.cpp ...) # Or: # hello_imgui_add_app(app_name file1.cpp file2.cpp ... ASSETS_LOCATION "path/to/assets") # (By default, ASSETS_LOCATION is "assets", which means that the assets will be searched in the "assets" folder, # relative to the location of the CMakeLists.txt file) # # Features: # * It will automatically link the target to the required libraries (hello_imgui, OpenGl, glad, etc) # * It will embed the assets (for desktop, mobile, and emscripten apps) # * It will perform additional customization (app icon and name on mobile platforms, etc) # * On desktop platforms, it will perform a "portable install" (i.e. assets and executable are in the same folder) # # If you want to control the install of your app, you can set HELLOIMGUI_ADD_APP_WITH_INSTALL to OFF # See an example in https://github.com/pthom/hello_imgui_template/blob/main/CMakeLists.txt # ``` -------------------------------- ### Get assets path and check existence Source: https://pthom.github.io/hello_imgui/book/doc-api Provides AssetFileFullPath to get the full path to an asset file, working on all platforms except Android. On Android it throws an error because assets can be compressed. Also provides AssetExists to check if an asset file exists. ```cpp //`std::string AssetFileFullPath(const std::string& assetRelativeFilename)` // will return the path to assets. // // This works under all platforms *except Android* // For compatibility with Android and other platforms, prefer to use `LoadAssetFileData` // whenever possible. // * Under iOS it will give a path in the app bundle (/private/XXX/....) // * Under emscripten, it will be stored in the virtual filesystem at "/" // * Under Android, assetFileFullPath is *not* implemented, and will throw an error: // assets can be compressed under android, and you can't use standard file operations! // Use LoadAssetFileData instead std::string AssetFileFullPath(const std::string& assetRelativeFilename, bool assertIfNotFound = true); // Returns true if this asset file exists bool AssetExists(const std::string& assetRelativeFilename); ``` -------------------------------- ### BackendPointers Source: https://pthom.github.io/hello_imgui/book/doc-params A struct containing optional pointers to the backend implementations (for SDL and GLFW). These pointers are filled when the application starts and can be used to customize application behavior using the selected backend. ```APIDOC ## BackendPointers ### Description A struct that contains optional pointers to the backend implementations (for SDL and GLFW). These pointers will be filled when the application starts, and you can use them to customize your application behavior using the selected backend. ### Fields - **glfwWindow** (void*) - Optional - Pointer to the main GLFW window (of type `GLFWwindow*`). Only filled if the backend is GLFW. - **sdlWindow** (void*) - Optional - Pointer to the main SDL window (of type `SDL_Window*`). Only filled if the backend is SDL (or emscripten + sdl). - **sdlGlContext** (void*) - Optional - Pointer to SDL's GlContext (of type `SDL_GLContext`). Only filled if the backend is SDL (or emscripten + sdl). ### Notes - If using the Metal, Vulkan or DirectX rendering backend, you can find some interesting pointers inside: - `src/hello_imgui/internal/backend_impls/rendering_metal.h` - `src/hello_imgui/internal/backend_impls/rendering_vulkan.h` - `src/hello_imgui/internal/backend_impls/rendering_dx11.h` - `src/hello_imgui/internal/backend_impls/rendering_dx12.h` ``` -------------------------------- ### WidgetWithResizeHandle usage with ImPlot Source: https://pthom.github.io/hello_imgui/book/doc-api Example usage of WidgetWithResizeHandle with ImPlot. The function takes an id, a widget function, and optional callbacks, returning the new widget size. ```cpp // WidgetWithResizeHandle: adds a resize handle to a widget // Example usage with ImPlot: // void gui() // { // static ImVec2 widget_size(200, 200); // auto myWidgetFunction = []() // { // if (ImPlot::BeginPlot("My Plot", widget_size)) { // ImPlot::PlotLine("My Line", x.data(), y.data(), 1000); // ImPlot::EndPlot(); // } // }; // widget_size = widget_with_resize_handle("plot", myWidgetFunction); // } ImVec2 WidgetWithResizeHandle( const char* id, VoidFunction widgetGuiFunction, float handleSizeEm = 1.0f, std::optional onItemResized = std::nullopt, std::optional onItemHovered = std::nullopt ); ``` -------------------------------- ### InputTextResizable C++ usage Source: https://pthom.github.io/hello_imgui/book/doc-api Usage example for the InputTextResizable widget in C++. Create an InputTextData object and call InputTextResizable in the GUI function. ```cpp // Somewhere in the application state (static) InputTextData textInput("My text", true, ImVec2(10, 3)); // In the GUI function bool changed = InputTextResizable("Label", &textInput); ``` -------------------------------- ### SetupFromGuiFunction Source: https://pthom.github.io/hello_imgui/book/doc-api Initializes the renderer with a simple GUI function and additional parameters. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). ```APIDOC ## SetupFromGuiFunction ### Description Initializes the renderer with a simple GUI function and additional parameters. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). ### Method SetupFromGuiFunction ### Signature void SetupFromGuiFunction( const VoidFunction& guiFunction, const std::string& windowTitle = "", bool windowSizeAuto = false, bool windowRestorePreviousGeometry = false, const ScreenSize& windowSize = DefaultWindowSize, float fpsIdle = 10.f, bool topMost = false ); ### Parameters - **guiFunction** (const VoidFunction&) - Required - The GUI function to be called each frame. - **windowTitle** (const std::string&) - Optional - The title of the window. Default is empty string. - **windowSizeAuto** (bool) - Optional - Whether to auto-size the window. Default is false. - **windowRestorePreviousGeometry** (bool) - Optional - Whether to restore previous window geometry. Default is false. - **windowSize** (const ScreenSize&) - Optional - The window size. Default is DefaultWindowSize. - **fpsIdle** (float) - Optional - The idle FPS. Default is 10.0. - **topMost** (bool) - Optional - Whether the window should be topmost. Default is false. ### Usage Example ```cpp HelloImGui::ManualRender::SetupFromGuiFunction([]() { /* GUI code */ }); ``` ``` -------------------------------- ### SetupFromSimpleRunnerParams Source: https://pthom.github.io/hello_imgui/book/doc-api Initializes the rendering with `SimpleRunnerParams`. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). ```APIDOC ## SetupFromSimpleRunnerParams ### Description Initializes the rendering with `SimpleRunnerParams`. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). ### Method SetupFromSimpleRunnerParams ### Signature void SetupFromSimpleRunnerParams(const SimpleRunnerParams& simpleParams); ### Parameters - **simpleParams** (const SimpleRunnerParams&) - Required - The simple runner parameters to initialize with. ### Usage Example ```cpp HelloImGui::SimpleRunnerParams simpleParams; // configure simpleParams as needed HelloImGui::ManualRender::SetupFromSimpleRunnerParams(simpleParams); ``` ``` -------------------------------- ### Build Hello ImGui and its demos Source: https://pthom.github.io/hello_imgui/book/building Commands to clone the repository, create a build directory, configure with CMake, and compile the library and demos. ```APIDOC ## Build Hello ImGui and its demos ### Description Clone the Hello ImGui repository, configure with CMake, and build the library and demos. ### Method N/A ### Endpoint N/A ### Parameters None ### Request Example ```bash git clone https://github.com/pthom/hello_imgui.git cd hello_imgui mkdir build && cd build cmake .. make -j ``` ### Response #### Success Response - **build/bin/** - Directory containing the compiled demos. #### Response Example ``` build/bin/ ``` ``` -------------------------------- ### SetupFromRunnerParams Source: https://pthom.github.io/hello_imgui/book/doc-api Initializes the rendering with a full customizable RunnerParams. This sets up the platform and rendering backends and keeps a reference to the user's RunnerParams. ```APIDOC ## SetupFromRunnerParams ### Description Initializes the rendering with the full customizable `RunnerParams`. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). A reference to the user's `RunnerParams` is kept internally (similar to HelloImGui::Run). ### Method SetupFromRunnerParams ### Signature void SetupFromRunnerParams(RunnerParams& runnerParams); ### Parameters - **runnerParams** (RunnerParams&) - Required - The runner parameters to initialize with. ### Usage Example ```cpp HelloImGui::RunnerParams runnerParams; runnerParams.callbacks.ShowGui = ...; // your GUI function HelloImGui::ManualRender::SetupFromRunnerParams(runnerParams); ``` ``` -------------------------------- ### SetAssetsFolder Source: https://pthom.github.io/hello_imgui/book/doc-api Sets the assets folder location. When using this, automatic assets installation on mobile platforms may not work. ```APIDOC ## SetAssetsFolder ### Description Sets the assets folder location. When using this, automatic assets installation on mobile platforms may not work. ### Method N/A ### Endpoint N/A ### Parameters #### Parameters - **folder** (const std::string&) - Required - The path to the assets folder. ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### InputTextResizable Python usage Source: https://pthom.github.io/hello_imgui/book/doc-api Usage example for the InputTextResizable widget in Python. Create an InputTextData object and call input_text_resizable in the GUI function. ```python # Somewhere in the application state text_input = hello_imgui.InputTextData("My text", multiline=True, size_em=ImVec2(10, 3)) # In the GUI function changed = hello_imgui.input_text_resizable("Label", text_input) ``` -------------------------------- ### HelloImGui::Run(guiFunction, windowTitle, windowSize, windowSizeAuto, restoreLastWindowGeometry, fpsIdle) Source: https://pthom.github.io/hello_imgui/book/doc-api Runs an application by providing the GUI function, window title, window size, and other optional settings. ```APIDOC ## HelloImGui::Run(guiFunction, windowTitle, windowSize, windowSizeAuto, restoreLastWindowGeometry, fpsIdle) ### Description Runs an application by providing the GUI function, window title, window size, and other optional settings. ### Method Run ### Signature `HelloImGui::Run(guiFunction, windowTitle, windowSize, windowSizeAuto=false, restoreLastWindowGeometry=false, fpsIdle=10)` ### Parameters - **guiFunction** (function) - Required - The GUI function to be called each frame. - **windowTitle** (string) - Required - The title of the application window. - **windowSize** (size) - Required - The initial size of the window. - **windowSizeAuto** (bool) - Optional - Automatically size the window. Default: false. - **restoreLastWindowGeometry** (bool) - Optional - Restore the last window geometry. Default: false. - **fpsIdle** (float) - Optional - Idle frames per second. Default: 10. ``` -------------------------------- ### tweakedTheme Source: https://pthom.github.io/hello_imgui/book/doc-params Sets the ImGui theme at startup. Pick a base theme and optionally fine-tune with tweaks. ```APIDOC ## tweakedTheme ### Description Sets the ImGui theme at startup. Pick a base theme (e.g., DarculaDarker, Cherry) and optionally fine-tune with tweaks (rounding, hue, saturation, alpha, luminance). ### Parameters - **Theme** (ImGuiTheme::ImGuiTheme_) - Required - The base theme to apply. - **Tweaks** (ImGuiTheme::ImGuiThemeTweaks) - Optional - Fine-tuning options for the theme. ### Usage Examples #### C++ ```cpp params.imGuiWindowParams.tweakedTheme.Theme = ImGuiTheme::ImGuiTheme_Cherry; // optionally: params.imGuiWindowParams.tweakedTheme.Tweaks.Rounding = 10.f; ``` #### Python ```python params.imgui_window_params.tweaked_theme.theme = imgui_theme.ImGuiTheme_.cherry # optionally: params.imgui_window_params.tweaked_theme.tweaks.rounding = 10.0 ``` ### Notes At runtime, `ShowThemeTweakGui()` lets the user select and tweak themes interactively. ``` -------------------------------- ### Build HelloImGui with CMake preset build_vcpkg_default Source: https://pthom.github.io/hello_imgui/book/building Clones HelloImGui and vcpkg, bootstraps vcpkg, sets VCPKG_ROOT, then uses the CMake preset 'build_vcpkg_default' to grab dependencies and build. Requires setting VCPKG_ROOT environment variable. ```bash # Clone hello_imgui git clone https://github.com/pthom/hello_imgui.git cd hello_imgui # Clone vcpkg -& bootstrap git clone https://github.com/microsoft/vcpkg.git ./vcpkg/bootstrap-vcpkg.sh export VCPKG_ROOT=$(pwd)/vcpkg # You *need* to set this environment variable # to tell cmake where to find vcpkg # Use the CMake preset "build_vcpkg_default" # This will grab all dependencies from vcpkg, # and use vcpkg toolchain file cmake --preset build_vcpkg_default cmake --build . -j 4 ``` -------------------------------- ### Configure DPI, Test Engine, and Emscripten FPS in RunnerParams Source: https://pthom.github.io/hello_imgui/book/doc-params Sets up DPI handling, enables the ImGui test engine, and sets the emscripten FPS. The test engine requires compilation with -DHELLOIMGUI_WITH_TEST_ENGINE=ON and is subject to a specific license. ```cpp // --------------- DPI Handling ----------- // Hello ImGui will try its best to automatically handle DPI scaling for you. // If it fails, look at DpiAwareParams (and the corresponding Ini file settings) DpiAwareParams dpiAwareParams; // --------------- Misc ------------------- // `useImGuiTestEngine`: _bool, default=false_. // Set this to true if you intend to use Dear ImGui Test & Automation Engine // ( https://github.com/ocornut/imgui_test_engine ) // HelloImGui must be compiled with the option -DHELLOIMGUI_WITH_TEST_ENGINE=ON // See demo in src/hello_imgui_demos/hello_imgui_demo_test_engine. // License: // 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.) bool useImGuiTestEngine = false; // `emscripten_fps`: _int, default = 0_. // Set the application refresh rate // (only used on emscripten: 0 stands for "let the app or the browser decide") int emscripten_fps = 0; #ifdef HELLOIMGUI_WITH_REMOTE_DISPLAY RemoteParams remoteParams; // Parameters for Remote display (experimental, unsupported) #endif }; ``` -------------------------------- ### EdgeToolbarType enum, EdgeToolbarOptions, EdgeToolbar struct, and helper functions Source: https://pthom.github.io/hello_imgui/book/doc-params Defines the EdgeToolbarType enum for toolbar locations (Top, Bottom, Left, Right), the EdgeToolbarOptions struct for size and padding, the EdgeToolbar struct with a callback, and helper functions to list all types and get a type name. ```cpp // EdgeToolbarType: location of an Edge Toolbar enum class EdgeToolbarType { Top, Bottom, Left, Right }; struct EdgeToolbarOptions { // height or width the top toolbar, in em units // (i.e. multiples of the default font size, to be Dpi aware) float sizeEm = 2.5f; // Padding inside the window, in em units ImVec2 WindowPaddingEm = ImVec2(0.3f, 0.3f); // Window background color, only used if WindowBg.w > 0 ImVec4 WindowBg = ImVec4(0.f, 0.f, 0.f, 0.f); }; // EdgeToolbar :a toolbar that can be placed on the edges of the App window // It will be placed in a non-dockable window struct EdgeToolbar { VoidFunction ShowToolbar = EmptyVoidFunction(); EdgeToolbarOptions options; }; std::vector AllEdgeToolbarTypes(); std::string EdgeToolbarTypeName(EdgeToolbarType e); ``` -------------------------------- ### HelloImGui::Run(const SimpleRunnerParams&) Source: https://pthom.github.io/hello_imgui/book/doc-api Runs an application using simpler parameters, providing a more straightforward way to launch an application. ```APIDOC ## HelloImGui::Run(const SimpleRunnerParams&) ### Description Runs an application using simpler parameters, providing a more straightforward way to launch an application. ### Method Run ### Signature `HelloImGui::Run(const SimpleRunnerParams&)` ### Parameters - **runnerParams** (const SimpleRunnerParams&) - Required - The simpler parameters for the application. ``` -------------------------------- ### Select backend via CMake options Source: https://pthom.github.io/hello_imgui/book/building CMake options to select platform and rendering backends when configuring Hello ImGui. ```APIDOC ## Select backend via CMake options ### Description Use CMake command-line options to select the desired platform and rendering backends for Hello ImGui. ### Method N/A ### Endpoint N/A ### Parameters #### CMake Options - **HELLOIMGUI_USE_GLFW3** (bool) - Optional - Use Glfw3 as a platform backend. Default OFF. - **HELLOIMGUI_USE_SDL2** (bool) - Optional - Use SDL2 as a platform backend. Default OFF. - **HELLOIMGUI_HAS_OPENGL3** (bool) - Optional - Use OpenGL3 as a rendering backend. Default OFF. - **HELLOIMGUI_HAS_METAL** (bool) - Optional - Use Metal as a rendering backend. Default OFF. - **HELLOIMGUI_HAS_VULKAN** (bool) - Optional - Use Vulkan as a rendering backend. Default OFF. - **HELLOIMGUI_HAS_DIRECTX11** (bool) - Optional - Use DirectX11 as a rendering backend. Default OFF. - **HELLOIMGUI_HAS_DIRECTX12** (bool) - Optional - Use DirectX12 as a rendering backend. Default OFF. - **HELLOIMGUI_HEADLESS** (bool) - Optional - Allow headless mode using Null backends. Default OFF. ### Request Example ```bash cmake .. -DHELLOIMGUI_USE_SDL2=ON -DHELLOIMGUI_HAS_OPENGL3=ON ``` ### Response #### Success Response - Configuration succeeds with the selected backends. #### Response Example N/A ``` -------------------------------- ### Hello World CMake configuration Source: https://pthom.github.io/hello_imgui A one-line CMake configuration to build a Hello ImGui app. It uses the hello_imgui_add_app function with the source file name. ```cmake hello_imgui_add_app(hello_world hello_world.cpp) ``` -------------------------------- ### Hello World in C++ Source: https://pthom.github.io/hello_imgui A minimal C++ Hello World app using Hello ImGui. It includes the necessary header and uses HelloImGui::Run with a lambda for GUI code and window title. ```cpp #include "hello_imgui/hello_imgui.h" int main(int , char *[]) { HelloImGui::Run( []{ ImGui::Text("Hello, world!"); }, // Gui code "Hello!", true); // Window title + Window size auto } ``` -------------------------------- ### WinMain entry point forwarding to main Source: https://pthom.github.io/hello_imgui/book//build/HelloImGui_WinMain-c036ab8e0eedffba0953280a2912d7ae.cpp Use this WinMain wrapper when building a Windows GUI application that expects a standard main function. It calls main(0, NULL) and returns its exit code. The parameters are unused and commented out. ```cpp #include int main(int, char **); INT WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, PSTR /*lpCmdLine*/, INT /*nCmdShow*/) { int exit_result = main(0, NULL); return exit_result; } ``` -------------------------------- ### HelloImGui::Run(RunnerParams &) Source: https://pthom.github.io/hello_imgui/book/doc-api Runs an application with the most customizable signature, using a RunnerParams object to specify application parameters and GUI. ```APIDOC ## HelloImGui::Run(RunnerParams &) ### Description Runs an application with the full signature, the most customizable version. The application's parameters and GUI are provided by the runnerParams object. ### Method Run ### Signature `HelloImGui::Run(RunnerParams &)` ### Parameters - **runnerParams** (RunnerParams&) - Required - The parameters and GUI for the application. ``` -------------------------------- ### ShowViewMenu and ShowAppMenu declarations Source: https://pthom.github.io/hello_imgui/book/doc-api Declarations for the optional menu callbacks. Set showMenuBar to true and showMenu_App/showMenu_View to false, then implement ShowMenus to call these functions. ```cpp // `ShowViewMenu(RunnerParams & runnerParams)`: // shows the View menu (where you can select the layout and docked windows visibility void ShowViewMenu(RunnerParams & runnerParams); // `ShowAppMenu(RunnerParams & runnerParams)`: // shows the default App menu (including the Quit item) void ShowAppMenu(RunnerParams & runnerParams); ``` -------------------------------- ### ImageFromAssetWithBg Source: https://pthom.github.io/hello_imgui/book/doc-api Displays a static image from the assets with a colored background and a border. ```APIDOC ## ImageFromAssetWithBg ### Description Displays a static image from the assets with a colored background and a border. ### Method N/A ### Endpoint N/A ### Parameters #### Parameters - **assetPath** (const char*) - Required - The path to the image asset. - **size** (const ImVec2&) - Optional - The size of the image. Default is ImVec2(0, 0). - **uv0** (const ImVec2&) - Optional - The UV coordinate of the top-left corner. Default is ImVec2(0, 0). - **uv1** (const ImVec2&) - Optional - The UV coordinate of the bottom-right corner. Default is ImVec2(1, 1). - **tint_col** (const ImVec4&) - Optional - The tint color. Default is ImVec4(1,1,1,1). - **border_col** (const ImVec4&) - Optional - The border color. Default is ImVec4(0,0,0,0). ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### PostRenderDockableWindows Source: https://pthom.github.io/hello_imgui/book/doc-params Callback invoked after dockable windows are rendered, allowing custom drawing or UI updates. ```APIDOC ## PostRenderDockableWindows ### Description Callback function called after the dockable windows are rendered. Use this to perform custom drawing or UI updates that should occur after the main dockable windows have been rendered. ### Callback Signature - **Type**: VoidFunction - **Default**: EmptyVoidFunction() ### Usage Assign a function to this member to be called after dockable windows are rendered. ### Example ```cpp runnerCallbacks.PostRenderDockableWindows = []() { // Custom drawing code }; ``` ``` -------------------------------- ### CMake option for ImGui Test Engine (HELLOIMGUI_WITH_TEST_ENGINE) Source: https://pthom.github.io/hello_imgui/book/building Provides the ImGui Test engine. Default is OFF. ```cmake option(HELLOIMGUI_WITH_TEST_ENGINE "Provide ImGui Test engine" OFF) ``` -------------------------------- ### Select Platform Backend Type (SDL, GLFW) via PlatformBackendType Source: https://pthom.github.io/hello_imgui/book/doc-params Use this enum to choose the platform backend. The order of preference is used when FirstAvailable is selected. ```cpp // You can select the platform backend type (SDL, GLFW) and the rendering backend type // via RunnerParams.platformBackendType and RunnerParams.renderingBackendType. // Platform backend type (SDL, GLFW) // They are listed in the order of preference when FirstAvailable is selected. enum class PlatformBackendType { FirstAvailable, Glfw, Sdl, Null }; ``` -------------------------------- ### ShowViewMenu Source: https://pthom.github.io/hello_imgui/book/doc-api Shows the View menu where users can select the layout and docked windows visibility. This function is part of the customization callbacks for the menu bar. ```APIDOC ## ShowViewMenu ### Description Shows the View menu where users can select the layout and docked windows visibility. ### Method Function ### Endpoint void ShowViewMenu(RunnerParams & runnerParams); ### Parameters #### Parameters - **runnerParams** (RunnerParams&) - Required - Reference to the runner parameters. ### Request Example No request body. ### Response No return value. ``` -------------------------------- ### ImageFromAsset Source: https://pthom.github.io/hello_imgui/book/doc-api Displays a static image from the assets. Images are loaded when first displayed and then cached. ```APIDOC ## ImageFromAsset ### Description Displays a static image from the assets. Images are loaded when first displayed and then cached. ### Method N/A ### Endpoint N/A ### Parameters #### Parameters - **assetPath** (const char*) - Required - The path to the image asset. - **size** (const ImVec2&) - Optional - The size of the image. Default is ImVec2(0, 0). - **uv0** (const ImVec2&) - Optional - The UV coordinate of the top-left corner. Default is ImVec2(0, 0). - **uv1** (const ImVec2&) - Optional - The UV coordinate of the bottom-right corner. Default is ImVec2(1, 1). ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### TearDown Source: https://pthom.github.io/hello_imgui/book/doc-api Tears down the renderer and releases all associated resources. This will release the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). After calling TearDown(), the InitFromXXX can be called with new parameters. ```APIDOC ## TearDown ### Description Tears down the renderer and releases all associated resources. This will release the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.). After calling `TearDown()`, the InitFromXXX can be called with new parameters. ### Method TearDown ### Signature void TearDown(); ### Usage Example ```cpp HelloImGui::ManualRender::TearDown(); ``` ``` -------------------------------- ### RunnerCallbacks struct definition with all callback members Source: https://pthom.github.io/hello_imgui/book/doc-params Defines the RunnerCallbacks struct with fields for SetupImGuiStyle, RegisterTests, exit callbacks (ConfirmExit, BeforeExit, EnqueueBeforeExit, BeforeExit_PostCleanup), and render loop callbacks (PreNewFrame, PostNewFrame, BeforeImGuiRender, BeforeSwap, AfterSwap, CustomBackground). Each callback has a default value and comments explain usage, constraints, and platform-specific notes. ```cpp // `SetupImGuiStyle`: default=_ImGuiDefaultSettings::SetupDefaultImGuiConfig*. // If needed, set your own style by providing your own SetupImGuiStyle callback VoidFunction SetupImGuiStyle = (VoidFunction)ImGuiDefaultSettings::SetupDefaultImGuiStyle; // `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 ------------------- // `ConfirmExit`: Called when the user requests to close the window // (window close button, Cmd-Q / Alt-F4, or the default App/Quit menu). // Return true to proceed with the exit, false to cancel it (the app keeps running). // Use it to confirm quitting (e.g. unsaved changes, or several open documents/tabs). // // Two ways to use it: // - Synchronous: pop a native/OS dialog and return the user's answer directly. // - Deferred (to show a Dear ImGui modal): return false to cancel now, raise a // flag, open your popup inside ShowGui, and set RunnerParams.appShallExit = true // yourself once the user confirms there. // // IMPORTANT: this is called during event polling, *before* ImGui::NewFrame(). // Do NOT call any ImGui function inside it. It is NOT called for programmatic // exits (setting RunnerParams.appShallExit = true directly is always honored). // Default: empty -> the exit proceeds immediately (the historical behavior). ConfirmExitCallback ConfirmExit = EmptyConfirmExitCallback(); // `BeforeExit`: You can here add a function that will be called once before exiting // (when OpenGL and ImGui are still inited) VoidFunction BeforeExit = EmptyVoidFunction(); // `EnqueueBeforeExit`: Add a function that will be called once before exiting // (when OpenGL and ImGui are still inited) // (this will modify the `BeforeExit` callback by appending the new callback (using `SequenceFunctions`) void EnqueueBeforeExit(const VoidFunction& callback); // `BeforeExit_PostCleanup`: You can here add a function that will be called once // before exiting (after OpenGL and ImGui have been stopped) VoidFunction BeforeExit_PostCleanup = EmptyVoidFunction(); // --------------- Callbacks in the render loop ------------------- // `PreNewFrame`: You can here add a function that will be called at each frame, // and before the call to ImGui::NewFrame(). // It is a good place to add new dockable windows. VoidFunction PreNewFrame = EmptyVoidFunction(); // `PostNewFrame`: You can here add a function that will be called at each frame, // just after the call to ImGui::NewFrame(), and before any Gui code. VoidFunction PostNewFrame = EmptyVoidFunction(); // `BeforeImGuiRender`: You can here add a function that will be called at each frame, // after the user Gui code, and just before the call to // ImGui::Render() (which will also call ImGui::EndFrame()). VoidFunction BeforeImGuiRender = EmptyVoidFunction(); // `BeforeSwap`: You can here add a function that will be called at each frame, // after the Gui was rendered, but before it is swapped to the screen. // This is a good place for a full-screen post-process pass over the whole frame // (for example a color management pass): unlike with AfterSwap, what you draw // here is still part of the presented frame. // Note: with OpenGL, Metal and DirectX11, the frame is still open at this point, // so that you can draw into it. With Vulkan and DirectX12, the command buffer // was already submitted by then: you would need to submit and synchronize // your own work. // Note: this concerns the main window only: the secondary viewport windows // are rendered after this callback. VoidFunction BeforeSwap = EmptyVoidFunction(); // `AfterSwap`: You can here add a function that will be called at each frame, // after the Gui was rendered and swapped to the screen. VoidFunction AfterSwap = EmptyVoidFunction(); // `CustomBackground`: // By default, the background is cleared using ImGuiWindowParams.backgroundColor. // If set, this function gives you full control over the background that is drawn // behind the Gui. An example use case is if you have a 3D application // like a mesh editor, or game, and just want the Gui to be drawn // on top of that content. VoidFunction CustomBackground = EmptyVoidFunction(); ``` -------------------------------- ### ImageButtonFromAsset Source: https://pthom.github.io/hello_imgui/book/doc-api Displays a button using an image from the assets. ```APIDOC ## ImageButtonFromAsset ### Description Displays a button using an image from the assets. ### Method N/A ### Endpoint N/A ### Parameters #### Parameters - **assetPath** (const char*) - Required - The path to the image asset. - **size** (const ImVec2&) - Optional - The size of the image. Default is ImVec2(0, 0). - **uv0** (const ImVec2&) - Optional - The UV coordinate of the top-left corner. Default is ImVec2(0, 0). - **uv1** (const ImVec2&) - Optional - The UV coordinate of the bottom-right corner. Default is ImVec2(1, 1). - **frame_padding** (int) - Optional - The frame padding. Default is -1. - **bg_col** (const ImVec4&) - Optional - The background color. Default is ImVec4(0,0,0,0). - **tint_col** (const ImVec4&) - Optional - The tint color. Default is ImVec4(1,1,1,1). ### Request Example N/A ### Response #### Success Response - **return** (bool) - Returns true if the button is clicked. #### Response Example N/A ``` -------------------------------- ### ShowAppMenu Source: https://pthom.github.io/hello_imgui/book/doc-api Shows the default App menu including the Quit item. This function is part of the customization callbacks for the menu bar. ```APIDOC ## ShowAppMenu ### Description Shows the default App menu including the Quit item. ### Method Function ### Endpoint void ShowAppMenu(RunnerParams & runnerParams); ### Parameters #### Parameters - **runnerParams** (RunnerParams&) - Required - Reference to the runner parameters. ### Request Example No request body. ### Response No return value. ``` -------------------------------- ### EdgeToolbarOptions struct Source: https://pthom.github.io/hello_imgui/book/doc-params Configuration options for an edge toolbar. ```APIDOC ## EdgeToolbarOptions ### Description Configuration options for an edge toolbar. ### Fields - **sizeEm** (float) - Height or width of the toolbar in em units (multiples of default font size). Default: 2.5f. - **WindowPaddingEm** (ImVec2) - Padding inside the window in em units. Default: ImVec2(0.3f, 0.3f). - **WindowBg** (ImVec4) - Window background color, only used if alpha > 0. Default: ImVec4(0.f, 0.f, 0.f, 0.f). ``` -------------------------------- ### Select Rendering Backend Type (OpenGL3, Metal, Vulkan, DirectX11, DirectX12) via RendererBackendType Source: https://pthom.github.io/hello_imgui/book/doc-params Use this enum to choose the rendering backend. The order of preference is used when FirstAvailable is selected. ```cpp // Rendering backend type (OpenGL3, Metal, Vulkan, DirectX11, DirectX12) // They are listed in the order of preference when FirstAvailable is selected. enum class RendererBackendType { FirstAvailable, OpenGL3, Metal, Vulkan, DirectX11, DirectX12, Null }; ``` -------------------------------- ### Render Source: https://pthom.github.io/hello_imgui/book/doc-api Renders the current frame. Should be called regularly to maintain the application's responsiveness. Must be called on the main thread. ```APIDOC ## Render ### Description Renders the current frame. Should be called regularly to maintain the application's responsiveness. Must be called on the main thread. ### Method Render ### Signature void Render(); ### Usage Example ```cpp while (!HelloImGui::GetRunnerParams()->appShallExit) { HelloImGui::ManualRender::Render(); } ``` ``` -------------------------------- ### HelloImGui::FreeImageCache Source: https://pthom.github.io/hello_imgui/book/doc-api Clears the asset image cache shared by ImageFromAsset, ImageAndSizeFromAsset and ImageAndSizeFromEncodedData. ```APIDOC ## FreeImageCache ### Description Clears the asset image cache shared by ImageFromAsset, ImageAndSizeFromAsset and ImageAndSizeFromEncodedData. Inside a HelloImGui::Run() context this is called automatically at shutdown. When using imgui_md (or any of the helpers above) without Run(), the cache lives until process exit unless you call this manually before destroying your GL context. ### Method C++ function ### Endpoint HelloImGui::FreeImageCache ### Parameters None ### Request Example ```cpp // Example usage HelloImGui::FreeImageCache(); ``` ### Response No return value. ``` -------------------------------- ### ImageAndSizeFromAsset Source: https://pthom.github.io/hello_imgui/book/doc-api Returns the texture ID and the size of an image loaded from the assets. ```APIDOC ## ImageAndSizeFromAsset ### Description Returns the texture ID and the size of an image loaded from the assets. ### Method N/A ### Endpoint N/A ### Parameters #### Parameters - **assetPath** (const char*) - Required - The path to the image asset. ### Request Example N/A ### Response #### Success Response - **return** (ImageAndSize) - A struct containing the texture ID and size of the image. #### Response Example N/A ``` -------------------------------- ### RendererBackendOptions Source: https://pthom.github.io/hello_imgui/book/doc-params A struct that contains options for the renderer backend (Metal, Vulkan, DirectX, OpenGL). It includes a function to check for extended dynamic range (EDR) support and fields to request a floating-point framebuffer and configure OpenGL options. ```APIDOC ## RendererBackendOptions ### Description A struct that contains options for the renderer backend (Metal, Vulkan, DirectX, OpenGL). ### Fields - **requestFloatBuffer** (bool) - Optional - Set to true to request a floating-point framebuffer (required for HDR/EDR output). Only available on Metal, and on OpenGL3 + Glfw if your version of Glfw defines GLFW_FLOATBUFFER (it is ignored otherwise). Ignored by the other rendering backends. Before setting this to true, first check `hasEdrSupport()`. Note: HelloImGui sets this back to false if the request could not be satisfied, so you can read it back once Run() has created the window, to know what you actually got. Note: on macOS, EDR output requires the Metal backend: even with a floating point framebuffer, OpenGL surfaces are composited clamped to standard range. This is an advanced and experimental option: HDR display support is still evolving in the operating systems, in Glfw and in Wayland, so its behavior may have to change in the future. - **openGlOptions** (OpenGlOptions) - Optional - Advanced options for OpenGL. Use at your own risk. ### Methods #### hasEdrSupport() ##### Description Check whether extended dynamic range (EDR), i.e. the ability to reproduce intensities exceeding the standard dynamic range from 0.0-1.0, is supported. To leverage EDR support, you need to set `requestFloatBuffer=true` in `RendererBackendOptions`. This currently returns false on all backends except Metal, where it checks whether this is supported on the current displays. On the other backends, a display's capabilities can only be queried once a window exists, which is too late here: set `requestFloatBuffer=true` and read it back instead (see below). ##### Returns - **bool** - True if EDR is supported, false otherwise. ### Notes - If using Metal, Vulkan or DirectX, you can find interesting pointers inside: - `src/hello_imgui/internal/backend_impls/rendering_metal.h` - `src/hello_imgui/internal/backend_impls/rendering_vulkan.h` - `src/hello_imgui/internal/backend_impls/rendering_dx11.h` - `src/hello_imgui/internal/backend_impls/rendering_dx12.h` ``` -------------------------------- ### DockingParams::dockableWindowOfName Source: https://pthom.github.io/hello_imgui/book/doc-params Returns a pointer to a dockable window with the given name. ```APIDOC ## DockableWindow * dockableWindowOfName(const std::string & name) ### Description Returns a pointer to a dockable window with the given name. ### Method N/A (C++ method) ### Parameters - **name** (const std::string&) - Required - The name of the dockable window to find. ### Returns - **DockableWindow*** - Pointer to the dockable window, or nullptr if not found. ``` -------------------------------- ### HelloImGui::GetRunnerParams() Source: https://pthom.github.io/hello_imgui/book/doc-api Returns the runnerParams of the current application, allowing access to the current application's parameters. ```APIDOC ## HelloImGui::GetRunnerParams() ### Description Returns the runnerParams of the current application, allowing access to the current application's parameters. ### Method GetRunnerParams ### Signature `HelloImGui::GetRunnerParams()` ### Returns - **RunnerParams** - The runner parameters of the current application. ``` -------------------------------- ### EmSize Source: https://pthom.github.io/hello_imgui/book/doc-api Returns the visible font size on the screen, or a size corresponding to a number of text lines. ```APIDOC ## EmSize ### Description Returns the visible font size on the screen, or a size corresponding to a number of text lines. ### Method Function ### Endpoint HelloImGui::EmSize ### Parameters #### Parameters - **nbLines** (float) - Optional - Number of text lines to get the size for. ### Request Example ```cpp float fontSize = HelloImGui::EmSize(); float lineSize = HelloImGui::EmSize(2.0f); ``` ### Response #### Success Response - **float** - The font size in pixels, or the size for the given number of lines. #### Response Example ```cpp 16.0f // example ``` ```