Skip to main content

Text Utilities

CalcTextSize

Calculate text size for current font.
const char*
Text to measure
const char*
default:"NULL"
End of text (NULL for null-terminated)
bool
default:"false"
Hide text after ## (useful for labels)
float
default:"-1.0f"
Width for text wrapping (-1.0f = no wrapping)
ImVec2
Text size in pixels
Example:

Color Utilities

ColorConvertU32ToFloat4

Convert 32-bit packed RGBA color to ImVec4. Example:

ColorConvertFloat4ToU32

Convert ImVec4 color to 32-bit packed RGBA. Example:

ColorConvertRGBtoHSV / ColorConvertHSVtoRGB

Convert between RGB and HSV color spaces. Example:

ID Functions

PushID

Push identifier into the ID stack (will hash the identifier). Example:

PopID

Pop from the ID stack.

GetID

Calculate unique ID (hash of whole ID stack + given parameter). Example:

Clipboard

GetClipboardText

Get text from clipboard.
const char*
Clipboard text, or empty string if unavailable
Example:

SetClipboardText

Set clipboard text. Example:

Version Information

GetVersion

Get the compiled version string (e.g., “1.92.7 WIP”). Example:

IMGUI_CHECKVERSION

Check that version and structure layouts match between compiled code and headers. Example:

Memory Management

SetAllocatorFunctions

Set custom memory allocator functions. Example:

MemAlloc / MemFree

Allocate/free memory using Dear ImGui’s allocator.
These functions use the allocator set via SetAllocatorFunctions(), or the default allocator.

Storage

GetStateStorage

Get storage for current window. Example:

ImGuiStorage

Debug Tools

ShowMetricsWindow

Create Metrics/Debugger window. Display Dear ImGui internals: windows, draw commands, various internal state, etc. Example:

ShowDebugLogWindow

Create Debug Log window. Display a simplified log of important Dear ImGui events.

ShowIDStackToolWindow

Create Stack Tool window. Hover items with mouse to query information about the source of their unique ID.

ShowAboutWindow

Create About window. Display Dear ImGui version, credits and build/system information.

DebugTextEncoding

Helper to debug text encoding issues. Display UTF-8 text with markers.

Settings (.ini) Management

LoadIniSettingsFromDisk

Call after CreateContext() and before first NewFrame(). NewFrame() automatically calls this with io.IniFilename.

SaveIniSettingsToDisk

Automatically called (if io.IniFilename is not empty) a few seconds after any modification.

LoadIniSettingsFromMemory

Call after CreateContext() and before first NewFrame() to provide .ini data from your own data source.

SaveIniSettingsToMemory

Return a zero-terminated string with the .ini data. Call when io.WantSaveIniSettings is set, then save by your own means and clear io.WantSaveIniSettings. Example:

Common Utility Patterns

Unique IDs in Loops

Persistent State

Custom Widget with State

See Also

  • Colors - Color conversion functions
  • Input - Input state and ImGuiIO
  • Text - Text rendering functions