Widget Categories
Dear ImGui widgets are organized into several categories:Text and Labels
Display formatted text, colored text, and labels
Buttons
Interactive buttons including standard, small, and arrow buttons
Input Widgets
Text input, numeric input, and input validation
Sliders and Drags
Value adjustment widgets with visual feedback
Color Pickers
Color selection and editing widgets
Trees and Selectables
Hierarchical data display and selection widgets
Combos and Lists
Dropdown menus and list boxes
Menus
Menu bars and context menus
Tables
Advanced table layouts with sorting and resizing
Common Widget Patterns
Return Values
Most widgets returntrue when their value has been changed or when they’ve been activated:
Widget IDs
Dear ImGui uses the widget label to generate a unique ID. When you need multiple widgets with the same label, usePushID() / PopID():
## syntax to hide part of the label:
Querying Widget State
After calling a widget function, you can query its state usingIsItem*() functions:
Widget Sizing
Many widgets accept a size parameter. Common conventions:size.x == 0.0f: Use default/natural widthsize.x > 0.0f: Specify exact width in pixelssize.x < 0.0f: Align to right edge with specified margin-FLT_MIN: Use all available width
Widget Flags
Many widget types support flags to customize their behavior:Best Practices
Use static variables for widget state
Use static variables for widget state
Widget state variables should persist across frames:
Check return values when needed
Check return values when needed
Only check return values when you need to respond to changes:
Use descriptive labels
Use descriptive labels
Labels help with debugging and make code more readable:
Next Steps
Explore specific widget categories to learn about their unique features and usage patterns:- Start with Text and Labels for basic output
- Learn about Buttons for user interaction
- Dive into Input Widgets for data entry