Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

immapp (C++)

ImmApp: runs an app in one call, with the bundle’s add-ons set up: ImPlot, ImPlot3D, markdown, LaTeX, the node editor, ImAnim.

The C++ API of ImmApp as it is bound to Python: the entries of the module imgui_bundle.immapp, in the same order, with their C++ signatures and the headers’ comments. From the stubs: the functions excluded from the bindings, the typedefs and the macros are absent.

Start with: ImmApp::Run, ImmApp::RunWithMarkdown, AddOnsParams, ImmApp::EmSize, ImmApp::EmToVec2.

runner.h

AddOnsParams (struct)

AddOnParams: require specific ImGuiBundle packages (markdown, node editor, texture viewer) to be initialized at startup.

Member
bool withImplot = false;
bool withImplot3d = false;
bool withMarkdown = false;
bool withNodeEditor = false;
bool withTexInspect = false;
bool withImAnim = false;
bool withLatex = false;
std::optional<NodeEditorConfig> withNodeEditorConfig = std::nullopt;
bool updateNodeEditorColorsFromImguiColors = true;
std::optional<RichMd::MarkdownOptions> withMarkdownOptions = std::nullopt;

Helpers to run an app from C++

Run an application using HelloImGui params + some addons

ImmApp::Run

void Run(HelloImGui::RunnerParams& runnerParams, const AddOnsParams& addOnsParams = AddOnsParams());
void Run(const HelloImGui::SimpleRunnerParams& simpleParams, const AddOnsParams& addOnsParams = AddOnsParams());
void Run( // HelloImGui::SimpleRunnerParams below: const VoidFunction& guiFunction, const std::string& windowTitle = "", bool windowSizeAuto = false, bool windowRestorePreviousGeometry = false, const ScreenSize& windowSize = DefaultWindowSize, float fpsIdle = 10.f, bool topMost = false, bool iniDisable = false, // AddOnsParams below: bool withImplot = false, bool withImplot3d = false, bool withMarkdown = false, bool withNodeEditor = false, bool withTexInspect = false, bool withImAnim = false, bool withLatex = false, #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR const std::optional<NodeEditorConfig>& withNodeEditorConfig = std::nullopt, #endif const std::optional<RichMd::MarkdownOptions> & withMarkdownOptions = std::nullopt );

ImmApp::RunWithMarkdown

void RunWithMarkdown( // HelloImGui::SimpleRunnerParams below: const VoidFunction& guiFunction, const std::string& windowTitle = "", bool windowSizeAuto = false, bool windowRestorePreviousGeometry = false, const ScreenSize& windowSize = DefaultWindowSize, float fpsIdle = 10.f, bool topMost = false, bool iniDisable = false, // AddOnsParams below: bool withImplot = false, bool withImplot3d = false, bool withNodeEditor = false, bool withTexInspect = false, bool withImAnim = false, bool withLatex = false, #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR const std::optional<NodeEditorConfig>& withNodeEditorConfig = std::nullopt, #endif const std::optional<RichMd::MarkdownOptions> & withMarkdownOptions = std::nullopt );

Run an application with markdown

ImmApp::EmSize

float EmSize();
float EmSize(float nbLines);

EmSize() returns the visible font size on the screen. For good results on HighDPI screens, always scale your widgets and windows relatively to this size.
It is somewhat comparable to the em CSS Unit.
EmSize() = ImGui::GetFontSize()

Dpi aware utilities (which call the same utilities from HelloImGui)

ImmApp::EmToVec2

ImVec2 EmToVec2(float x, float y);
ImVec2 EmToVec2(ImVec2 v);

EmToVec2() returns an ImVec2 that you can use to size or place your widgets in a DPI independent way (pass sizes that are proportional to the font height)

ImmApp::PixelsToEm

ImVec2 PixelsToEm(ImVec2 pixels);

PixelsToEm() converts a Vec2 in pixels to a Vec2 in em

ImmApp::PixelSizeToEm

float PixelSizeToEm(float pixelSize);

PixelSizeToEm() converts a size in pixels to a size in em

Utility for ImGui node editor & NanoVG

ImmApp::DefaultNodeEditorContext

NodeEditorContext* DefaultNodeEditorContext();

ImmApp::DefaultNodeEditorConfig

NodeEditorConfig* DefaultNodeEditorConfig();

ImmApp::NodeEditorSettingsLocation

std::string NodeEditorSettingsLocation(const HelloImGui::RunnerParams& runnerParams);

NodeEditorSettingsLocation returns the path to the json file for the node editor settings.

ImmApp::HasNodeEditorSettings

bool HasNodeEditorSettings(const HelloImGui::RunnerParams& runnerParams);

HasNodeEditorSettings returns True if the json file for the node editor settings exists.

ImmApp::DeleteNodeEditorSettings

void DeleteNodeEditorSettings(const HelloImGui::RunnerParams& runnerParams);

DeleteNodeEditorSettings deletes the json file for the node editor settings.

manual_render (struct)

manual_render::SetupFromRunnerParams
void SetupFromRunnerParams(HelloImGui::RunnerParams& runnerParams, const AddOnsParams& addOnsParams = AddOnsParams());

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 ImmApp::Run).

Immapp::ManualRender is a namespace that groups functions, allowing fine-grained control over the rendering process:

manual_render::SetupFromSimpleRunnerParams
void SetupFromSimpleRunnerParams(const HelloImGui::SimpleRunnerParams& simpleParams, const AddOnsParams& addOnsParams = AddOnsParams());

Initializes the rendering with SimpleRunnerParams.
This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.).

manual_render::SetupFromGuiFunction
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, bool iniDisable = false, // AddOnsParams below: bool withImplot = false, bool withImplot3d = false, bool withMarkdown = false, bool withNodeEditor = false, bool withTexInspect = false, bool withImAnim = false, bool withLatex = false, #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR const std::optional<NodeEditorConfig>& withNodeEditorConfig = std::nullopt, #endif const std::optional<RichMd::MarkdownOptions> & withMarkdownOptions = std::nullopt );

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.).

manual_render::Render
void Render();

Renders the current frame. Should be called regularly to maintain the application’s responsiveness.

manual_render::TearDown
void TearDown();

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.

    }

immapp_widgets.h

ImmApp::BeginPlotInNodeEditor

bool BeginPlotInNodeEditor(const char* title_id, const ImVec2& size=ImVec2(-1,0), ImPlotFlags flags=0);

These functions wrap ImPlot::BeginPlot and ImPlot::EndPlot, but they enable to make the plot content draggable inside a node

ImmApp::EndPlotInNodeEditor

void EndPlotInNodeEditor();

ImmApp::ShowResizablePlotInNodeEditor

ImVec2 ShowResizablePlotInNodeEditor( const char* title_id, // plot title const ImVec2& size_pixels, // plot size (will be updated if resized by the user) VoidFunction plotFunction, // your function to draw the plot ImPlotFlags flags=0, float resizeHandleSizeEm=1.0f );

ShowResizablePlotInNodeEditor: shows a resizable plot inside a node
Returns the new size of the plot

ImmApp::ShowResizablePlotInNodeEditor_Em

ImVec2 ShowResizablePlotInNodeEditor_Em( const char* title_id, // plot title const ImVec2& size_em, // plot size (will be updated if resized by the user) VoidFunction plotFunction, // your function to draw the plot ImPlotFlags flags=0, float resizeHandleSizeEm=1.0f );

ShowResizablePlotInNodeEditor_Em: shows a resizable plot inside a node
Returns the new size of the plot. Units are in em.

ImmApp::WidgetWithResizeHandle_InNodeEditor

ImVec2 WidgetWithResizeHandle_InNodeEditor( const char* id, VoidFunction guiFunction, // your function to draw the widget float resizeHandleSizeEm=1.0f );

WidgetWithResizeHandle_InNodeEditor: shows a resizable widget inside a node
Returns the new size of the widget.

ImmApp::WidgetWithResizeHandle_InNodeEditor_Em

ImVec2 WidgetWithResizeHandle_InNodeEditor_Em( const char* id, VoidFunction guiFunction, // your function to draw the widget float resizeHandleSizeEm=1.0f );

WidgetWithResizeHandle_InNodeEditor_Em: shows a resizable widget inside a node
Returns the new size of the widget. Size is in em.

clock.h

ImmApp::ClockSeconds

double ClockSeconds();

Chronometer in seconds

}

code_utils.h

Submodule code_utils

code_utils (struct)

code_utils::Unindent
std::string Unindent(const std::string& code, bool is_markdown);
code_utils::UnindentCode
std::string UnindentCode(const std::string& code);
code_utils::UnindentMarkdown
std::string UnindentMarkdown(const std::string& code);
}

snippets.h

Submodule snippets

snippets (struct)

snippets::SnippetLanguage (enum)
MemberValue
Cpp0
Hlsl1
Glsl2
C3
Sql4
AngelScript5
Lua6
Python7
snippets::SnippetTheme (enum)
MemberValue
Auto0Automatic based on bg color
Dark1
Light, }2
snippets::DefaultSnippetLanguage
inline SnippetLanguage DefaultSnippetLanguage();

DefaultSnippetLanguage: Cpp, or Python when the host defines IMGUI_RICHMD_DEFAULT_SNIPPET_LANGUAGE_PYTHON (Python bindings)

snippets::SnippetData (struct)
Member
std::string Code = "";
SnippetLanguage Language = DefaultSnippetLanguage();
SnippetTheme Palette = SnippetTheme::Auto;
bool ShowCopyButton = true;Displayed on top of the editor (Top Right corner)
bool ShowCursorPosition = true;Show line and column number
std::string DisplayedFilename = {};Displayed on top of the editor
int HeightInLines = 0;Number of visible lines in the editor
int MaxHeightInLines = 40;
bool ReadOnly = true;Snippets are read-only by default
bool Border = false;Draw a border around the editor
bool DeIndentCode = true;Keep the code indentation, but remove main indentation,
bool AddFinalEmptyLine = false;Add an empty line at the end of the code if missing
snippets::ShowEditableCodeSnippet
bool ShowEditableCodeSnippet(const std::string& label_id, SnippetData* snippetData, float width = 0.f, int overrideHeightInLines = 0);

One snippet, editable or not, or several side by side.

snippets::ShowCodeSnippet
void ShowCodeSnippet(const SnippetData& snippetData, float width = 0.f, int overrideHeightInLines = 0);
snippets::ShowSideBySideSnippets
void ShowSideBySideSnippets(const SnippetData& snippet1, const SnippetData& snippet2, bool hideIfEmpty = true, bool equalVisibleLines = true);
void ShowSideBySideSnippets(const std::vector<SnippetData>& snippets , bool hideIfEmpty = true, bool equalVisibleLines = true);

ImmApp::render_markdown_doc_panel

Render a markdown documentation panel with a light theme, inside a resizable child window.
Useful for showing docstrings or documentation at the top of a demo.

Args: doc: markdown string to render (will be unindented automatically) height_em: height of the panel in em units

ImmApp::download_url_bytes

Download data from a URL synchronously. Works on both desktop (urllib) and Pyodide (sync XMLHttpRequest).
Returns the downloaded bytes, or empty bytes on failure.

Args: url: the URL to download from