Overview
Dear ImGui uses a cursor-based layout system. The cursor represents the current output position where the next widget will be placed. Understanding cursor positioning is fundamental to creating custom layouts.Coordinate Systems
Dear ImGui uses two coordinate systems:- Absolute coordinates:
GetCursorScreenPos(),SetCursorScreenPos(), allImDrawListfunctions - Window-local coordinates:
GetCursorPos(),SetCursorPos(),GetCursorStartPos()
Primary Cursor Functions
GetCursorScreenPos
ImVec2
Current cursor position in absolute screen coordinates
SetCursorScreenPos
const ImVec2&
New cursor position in absolute screen coordinates
GetContentRegionAvail
ImVec2
Available space in current region
Window-Local Cursor Functions
These functions use window-local coordinates. Prefer using
GetCursorScreenPos() instead.GetCursorPos
ImVec2
Cursor position in window-local coordinates
GetCursorPosX / GetCursorPosY
SetCursorPos
const ImVec2&
New cursor position in window-local coordinates
SetCursorPosX / SetCursorPosY
float
New X position in window-local coordinates
float
New Y position in window-local coordinates
GetCursorStartPos
GetCursorScreenPos() after Begin() to get the absolute coordinates version.
ImVec2
Initial cursor position in window-local coordinates
Conversion
To convert between coordinate systems:Related Functions
See also:- Spacing & Alignment for
Indent(),Unindent(),Spacing(),Dummy() - Columns & Groups for
BeginGroup(),EndGroup()