imgui
Bindings for ImGui. Can be used in the re.on_draw_ui callback.
Some methods can be used in re.on_frame if imgui.begin_window/imgui.end_window is used.
Example:
local thing = 1
local things = { "hi", "hello", "howdy", "hola", "aloha" }
re.on_draw_ui(function()
if imgui.button("Whats up") then
thing = 1
end
local changed, new_thing = imgui.combo("Greeting", thing, things)
if changed then thing = new_thing end
end)
Enums
imgui.TableFlags
None,Resizable,Reorderable,Hideable,Sortable,NoSavedSettings,ContextMenuInBodyRowBgBordersInnerH,BordersOuterH,BordersInnerV,BordersOuterV,BordersH,BordersV,BordersInner,BordersOuter,BordersNoBordersInBody,NoBordersInBodyUntilResizeSizingFixedFit,SizingFixedSame,SizingStretchProp,SizingStretchSameNoHostExtendX,NoHostExtendY,NoKeepColumnsVisible,PreciseWidths,NoClipPadOuterX,NoPadOuterX,NoPadInnerXScrollX,ScrollYSortMulti,SortTristate
imgui.ColumnFlags
None,DefaultHide,DefaultSort,WidthStretch,WidthFixedNoResize,NoReorder,NoHide,NoClip,NoSort,NoSortAscending,NoSortDescendingNoHeaderWidth,PreferSortAscending,PreferSortDescendingIndentEnable,IndentDisableIsEnabled,IsVisible,IsSorted,IsHovered
imgui.ImGuiKey
Input keys:
Key_None,Key_Tab,Key_LeftArrow,Key_RightArrow,Key_UpArrow,Key_DownArrowKey_PageUp,Key_PageDown,Key_Home,Key_End,Key_Insert,Key_Delete,Key_BackspaceKey_Space,Key_Enter,Key_EscapeKey_0–Key_9,Key_A–Key_ZKey_F1–Key_F24Key_Apostrophe,Key_Comma,Key_Minus,Key_Period,Key_Slash,Key_Semicolon,Key_EqualKey_LeftBracket,Key_Backslash,Key_RightBracket,Key_GraveAccentKey_CapsLock,Key_ScrollLock,Key_NumLock,Key_PrintScreen,Key_PauseKey_Keypad0–Key_Keypad9,Key_KeypadDecimal,Key_KeypadDivide,Key_KeypadMultiply,Key_KeypadSubtract,Key_KeypadAdd,Key_KeypadEnter,Key_KeypadEqualKey_AppBack,Key_AppForward,Key_Oem102Key_MouseLeft,Key_MouseRight,Key_MouseMiddle,Key_MouseX1,Key_MouseX2,Key_MouseWheelX,Key_MouseWheelYKey_GamepadStart,Key_GamepadBack,Key_GamepadFaceLeft/Right/Up/Down,Key_GamepadDpadLeft/Right/Up/Down,Key_GamepadL1/R1,Key_GamepadL2/R2,Key_GamepadL3/R3Key_GamepadLStickLeft/Right/Up/Down,Key_GamepadRStickLeft/Right/Up/Down- Modifier keys:
Key_LeftCtrl,Key_LeftShift,Key_LeftAlt,Key_LeftSuper,Key_RightCtrl,Key_RightShift,Key_RightAlt,Key_RightSuper,Key_Menu
Modifier aliases:
Mod_None,Mod_Ctrl,Mod_Shift,Mod_Alt,Mod_Super,Mod_Mask_
imgui.ImGuiStyleVar
Alpha,DisabledAlphaWindowPadding,WindowRounding,WindowBorderSize,WindowMinSize,WindowTitleAlignChildRounding,ChildBorderSizePopupRounding,PopupBorderSizeFramePadding,FrameRounding,FrameBorderSizeItemSpacing,ItemInnerSpacing,IndentSpacingCellPaddingScrollbarSize,ScrollbarRoundingGrabMinSize,GrabRoundingImageBorderSizeTabRounding,TabBorderSize,TabBarBorderSize,TabBarOverlineSizeTableAngledHeadersAngle,TableAngledHeadersTextAlignButtonTextAlign,SelectableTextAlignSeparatorTextBorderSize,SeparatorTextAlign,SeparatorTextPadding
imgui.ImGuizmoOperation
TRANSLATE,ROTATE,SCALE,SCALEU,UNIVERSAL
imgui.ImGuizmoMode
WORLD,LOCAL
Usertypes
imgui.TableSortSpecs
Returned by table sort query APIs.
Fields:
specs_dirty— Boolean, true if specs have changed.get_specs()— Returns a list ofTableColumnSortSpecs.
imgui.TableColumnSortSpecs
Fields:
user_id— Column user ID.column_index— Column index.sort_order— Sort order index.sort_direction— Sort direction (0 = unsorted, 1 = ascending, 2 = descending).
Methods
imgui.begin_window(name, open, flags)
Creates a new window with the title of name.
open is a bool. Can be nil. If not nil, a close button will be shown in the top right of the window.
flags - ImGuiWindowFlags.
begin_window must have a corresponding end_window call.
This function may only be called in on_frame, not on_draw_ui.
Returns a bool. Returns false if the user wants to close the window.
imgui.end_window()
Ends the last begin_window call. Required.
imgui.begin_child_window(size, border, flags)
size - Vector2f
border - bool
flags - ImGuiWindowFlags
imgui.end_child_window()
imgui.begin_group()
imgui.end_group()
imgui.begin_rect()
imgui.end_rect(additional_size, rounding)
These two methods draw a rectangle around the elements between begin_rect and end_rect
imgui.begin_disabled(disabled=true)
imgui.end_disabled()
These two methods will disable and darken elements in between it.
imgui.button(label, size)
Draws a button with label text, and optional size.
size is a Vector2f or a size 2 array.
Returns true when the user presses the button.
imgui.small_button(label)
imgui.invisible_button(id, size, flags)
size is a Vector2f or a size 2 array.
imgui.arrow_button(id, dir)
dir is an ImguiDir
imgui.text(text)
Draws text.
imgui.text_colored(text, color)
Draws text with color.
color is an integer color in the form ARGB.
imgui.checkbox(label, value)
Returns a tuple of changed, value
imgui.drag_float(label, value, speed, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.drag_float2(label, value (Vector2f), speed, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.drag_float3(label, value (Vector3f), speed, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.drag_float4(label, value (Vector4f), speed, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.drag_int(label, value, speed, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.slider_float(label, value, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.slider_int(label, value, min, max, display_format (optional))
Returns a tuple of changed, value
imgui.input_text(label, value, flags (optional))
Returns a tuple of changed, value, selection_start, selection_end
imgui.input_text_multiline(label, value, size, flags (optional))
Returns a tuple of changed, value, selection_start, selection_end
imgui.combo(label, selection, values)
Returns a tuple of changed, value.
changed = true when selection changes.
value is the selection index within values (a table)
values can be a table with any type of keys, as long as the values are strings.
imgui.color_picker(label, color, flags)
Returns a tuple of changed, value. color is an integer color in the form ABGR which imgui and draw APIs expect.
imgui.color_picker_argb(label, color, flags)
Returns a tuple of changed, value. color is an integer color in the form ARGB.
imgui.color_picker3(label, color (Vector3f), flags)
Returns a tuple of changed, value
imgui.color_picker4(label, color (Vector4f), flags)
Returns a tuple of changed, value
imgui.color_edit(label, color, flags)
Returns a tuple of changed, value. color is an integer color in the form ABGR which imgui and draw APIs expect.
imgui.color_edit_argb(label, color, flags)
Returns a tuple of changed, value. color is an integer color in the form ARGB.
imgui.color_edit3(label, color (Vector3f), flags)
Returns a tuple of changed, value
imgui.color_edit4(label, color (Vector4f), flags)
Returns a tuple of changed, value
flags for color_picker/edit APIs: ImGuiColorEditFlags
imgui.tree_node(label)
imgui.tree_node_ptr_id(id, label)
imgui.tree_node_str_id(id, label)
imgui.tree_pop()
All of the above tree functions must have a corresponding tree_pop!
imgui.same_line()
imgui.spacing()
imgui.new_line()
imgui.is_item_hovered(flags)
imgui.is_item_active()
imgui.is_item_focused()
imgui.collapsing_header(name)
imgui.load_font(filepath, size, [ranges])
Loads a font file from the reframework/fonts subdirectory at the specified size with optional Unicode ranges (an array of start, end pairs ending with 0). Returns a handle for use with imgui.push_font(). If filepath is nil, it will load the default font at the specified size.
imgui.push_font(font, size)
Sets the font to be used for the next set of ImGui widgets/draw commands until imgui.pop_font is called. size is optional.
imgui.pop_font()
Unsets the previously pushed font.
imgui.get_default_font_size()
Returns size of the default font for REFramework's UI.
imgui.set_next_window_pos(pos (Vector2f or table), condition, pivot (Vector2f or table))
condition is the ImGuiCond enum.
enum ImGuiCond_
{
ImGuiCond_None = 0, // No condition (always set the variable), same as _Always
ImGuiCond_Always = 1 << 0, // No condition (always set the variable)
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed)
ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
};
imgui.set_next_window_size(size (Vector2f or table), condition)
condition is the ImGuiCond enum.
imgui.push_id(id)
id can be an int, const char*, or void*.
imgui.pop_id()
imgui.get_id()
imgui.get_mouse()
Returns a Vector2f corresponding to the user's mouse position in window space.
imgui.progress_bar(progress, size, overlay)
progress is a float between 0 and 1.
size is a Vector2f or a size 2 array.
overlay is a string on top of the progress bar.
local progress = 0.0
re.on_frame(function()
progress = progress + 0.001
if progress > 1.0 then
progress = 0.0
end
end)
re.on_draw_ui(function()
imgui.progress_bar(progress, Vector2f.new(200, 20), string.format("Progress: %.1f%%", progress * 100))
end)
imgui.item_size(pos, size)
imgui.item_add(label, pos, size)
Adds an item with the specified label, position, and size to the current window.
imgui.draw_list_path_clear()
Clears the current window's draw list path.
imgui.draw_list_path_line_to(pos)
Adds a line to the current window's draw list path given the specified pos
posis a Vector2f or a size 2 array.
imgui.draw_list_path_stroke(color, closed, thickness)
Strokes the current window's draw list path with the specified color, closed state, and thickness.
coloris an integer color in the form ARGB.closedis a bool.thicknessis a float.
imgui.get_key_index(imgui_key)
Returns the index of the specified imgui_key.
imgui.is_key_down(key)
Returns true if the specified key is currently being held down.
imgui.is_key_pressed(key)
Returns true if the specified key was pressed during the current frame.
imgui.is_key_released(key)
Returns true if the specified key was released during the current frame.
imgui.is_mouse_down(button)
Returns true if the specified mouse button is currently being held down.
imgui.is_mouse_clicked(button)
Returns true if the specified mouse button was clicked during the current frame.
imgui.is_mouse_released(button)
Returns true if the specified mouse button was released during the current frame.
imgui.is_mouse_double_clicked(button)
Returns true if the specified mouse button was double-clicked during the current frame.
imgui.indent(indent_width)
Indents the current line by indent_width pixels.
imgui.unindent(indent_width)
Unindents the current line by indent_width pixels.
imgui.begin_tooltip()
Starts a tooltip window that will be drawn at the current cursor position.
imgui.end_tooltip()
Ends the current tooltip window.
imgui.set_tooltip(text)
Sets the text for the current tooltip window.
imgui.open_popup(str_id, flags)
Opens a popup with the specified str_id and flags.
imgui.begin_popup(str_id, flags)
Begins a new popup with the specified str_id and flags.
imgui.begin_popup_context_item(str_id, flags)
Begins a new popup with the specified str_id and flags, anchored to the last item.
imgui.end_popup()
Ends the current popup window.
imgui.close_current_popup()
Closes the current popup window.
imgui.is_popup_open(str_id)
Returns true if the popup with the specified str_id is open.
imgui.calc_text_size(text)
Calculates and returns the size of the specified text as a Vector2f.
imgui.get_window_size()
Returns the size of the current window as a Vector2f.
imgui.get_window_pos()
Returns the position of the current window as a Vector2f.
imgui.set_next_item_open(is_open, condition)
Sets the open state of the next collapsing header or tree node to is_open based on the specified condition.
imgui.begin_list_box(label, size)
Begins a new list box with the specified label and size.
imgui.end_list_box()
Ends the current list box.
imgui.begin_menu_bar()
Begins a new menu bar.
imgui.end_menu_bar()
Ends the current menu bar.
imgui.begin_main_menu_bar()
Begins the main menu bar.
imgui.end_main_menu_bar()
Ends the main menu bar.
imgui.begin_menu(label, enabled)
Begins a new menu with the specified label. The menu will be disabled if enabled is false.
imgui.end_menu()
Ends the current menu.
imgui.menu_item(label, shortcut, selected, enabled)
Adds a menu item with the specified label, shortcut, selected state, and enabled state.
imgui.get_display_size()
Returns the size of the display as a Vector2f.
imgui.push_item_width(item_width)
Pushes the width of the next item to item_width pixels.
imgui.pop_item_width()
Pops the last item width off the stack.
imgui.set_next_item_width(item_width)
Sets the width of the next item to item_width pixels.
imgui.calc_item_width()
Calculates and returns the current item width.
imgui.push_style_color(style_color, color)
Pushes a new style color onto the style stack.
imgui.pop_style_color(count)
Pops count style colors off the style stack.
imgui.push_style_var(idx, value)
Pushes a new style variable onto the style stack.
imgui.pop_style_var(count)
Pops count style variables off the style stack.
imgui.get_cursor_pos()
Returns the current cursor position as a Vector2f.
imgui.set_cursor_pos(pos)
Sets the current cursor position to pos.
imgui.get_cursor_start_pos()
Returns the initial cursor position as a Vector2f.
imgui.get_cursor_screen_pos()
Returns the current cursor position in screen coordinates as a Vector2f.
imgui.set_cursor_screen_pos(pos)
Sets the current cursor position in screen coordinates to pos.
imgui.set_item_default_focus()
Sets the default focus to the next widget.
Scroll APIs
imgui.get_scroll_x()
Returns the horizontal scroll position.
imgui.get_scroll_y()
Returns the vertical scroll position.
imgui.set_scroll_x(scroll_x)
Sets the horizontal scroll position to scroll_x.
imgui.set_scroll_y(scroll_y)
Sets the vertical scroll position to scroll_y.
imgui.get_scroll_max_x()
Returns the maximum horizontal scroll position.
imgui.get_scroll_max_y()
Returns the maximum vertical scroll position.
imgui.set_scroll_here_x(center_x_ratio)
Centers the horizontal scroll position.
imgui.set_scroll_here_y(center_y_ratio)
Centers the vertical scroll position.
imgui.set_scroll_from_pos_x(local_x, center_x_ratio)
Sets the horizontal scroll position from the specified local_x and center_x_ratio.
imgui.set_scroll_from_pos_y(local_y, center_y_ratio)
Sets the vertical scroll position from the specified local_y and center_y_ratio.
Table API
imgui.begin_table(str_id, column, flags, outer_size, inner_width)
Begins a new table with the specified str_id, column count, flags, outer_size, and inner_width.
str_idis a string.columnis an integer.flagsis an optionalImGuiTableFlagsenum.outer_sizeis a Vector2f or a size 2 array.inner_widthis an optional float.
imgui.end_table()
Ends the current table.
imgui.table_next_row(row_flags, min_row_height)
Begins a new row in the current table with the specified row_flags and min_row_height.
row_flagsis an optionalImGuiTableRowFlagsenum.min_row_heightis an optional float.
imgui.table_next_column()
Advances to the next column in the current table.
imgui.table_set_column_index(column_index)
Sets the current column index to column_index.
imgui.table_setup_column(label, flags, init_width_or_weight, user_id)
Sets up a column in the current table with the specified label, flags, init_width_or_weight, and user_id.
imgui.table_setup_scroll_freeze(cols, rows)
Sets up a scrolling region in the current table with cols columns and rows rows frozen.
imgui.table_headers_row()
Submits a header row in the current table.
imgui.table_header(label)
Submits a header cell with the specified label in the current table.
imgui.table_get_sort_specs()
Returns the sort specifications for the current table.
imgui.table_get_column_count()
Returns the number of columns in the current table.
imgui.table_get_column_index()
Returns the current column index.
imgui.table_get_row_index()
Returns the current row index.
imgui.table_get_column_name(column)
Returns the name of the specified column in the current table.
imgui.table_get_column_flags(column)
Returns the flags of the specified column in the current table.
imgui.table_set_bg_color(target, color, column)
Sets the background color of the specified target in the current table with the given color and column index.
imgui.get_window_draw_list()
Returns the current window's ImDrawList.
imgui.get_background_draw_list()
Returns the background ImDrawList (drawn behind everything).
imgui.get_foreground_draw_list()
Returns the foreground ImDrawList (drawn over everything).
imgui.separator()
Draws a horizontal separator line.
imgui.set_clipboard(text)
Copies text to the system clipboard.
imgui.get_clipboard()
Returns the current clipboard text.
imgui.push_font_size(size)
Pushes a font size change without changing the font face. Use imgui.pop_font_size() to restore.
imgui.pop_font_size()
Restores the previous font after push_font_size.
ImDrawList
Returned from imgui.get_window_draw_list(), imgui.get_background_draw_list(), or imgui.get_foreground_draw_list().
Shape Drawing
self:add_line(p1, p2, color, thickness)— Draws a line.self:add_rect(min, max, color, rounding, flags, thickness)— Draws a rectangle outline.self:add_rect_filled(min, max, color, rounding, flags)— Draws a filled rectangle.self:add_rect_filled_multi_color(min, max, col_upr_left, col_upr_right, col_bot_right, col_bot_left)— Draws a filled rectangle with different corner colors.self:add_quad(p1, p2, p3, p4, color, thickness)— Draws a quad outline.self:add_quad_filled(p1, p2, p3, p4, color)— Draws a filled quad.self:add_triangle(p1, p2, p3, color, thickness)— Draws a triangle outline.self:add_triangle_filled(p1, p2, p3, color)— Draws a filled triangle.self:add_circle(center, radius, color, num_segments, thickness)— Draws a circle outline.self:add_circle_filled(center, radius, color, num_segments)— Draws a filled circle.self:add_ngon(center, radius, color, num_segments, thickness)— Draws an N-sided polygon outline.self:add_ngon_filled(center, radius, color, num_segments)— Draws a filled N-sided polygon.self:add_ellipse(center, radius, color, rot, num_segments, thickness)— Draws an ellipse outline.self:add_ellipse_filled(center, radius, color, rot, num_segments)— Draws a filled ellipse.self:add_text(pos, color, text)— Draws text at the specified position.self:add_bezier_cubic(p1, p2, p3, p4, color, thickness)— Draws a cubic Bezier curve.self:add_bezier_quadratic(p1, p2, p3, color, thickness)— Draws a quadratic Bezier curve.
Clip Rect
self:push_clip_rect(min, max, intersect_with_current)— Pushes a clip rectangle.self:push_clip_rect_fullscreen()— Pushes a fullscreen clip rectangle.self:pop_clip_rect()— Pops the last clip rectangle.
Path Drawing
self:path_clear()— Clears the current path.self:path_line_to(pos)— Adds a line to the current path.self:path_line_to_merge_duplicate(pos)— Adds a line, merging if duplicate.self:path_fill_convex(color)— Fills the current path as convex.self:path_fill_concave(color)— Fills the current path as concave.self:path_stroke(color, flags, thickness)— Strokes the current path.self:path_arc_to(center, radius, a_min, a_max, num_segments)— Adds an arc to the current path.self:path_arc_to_fast(center, radius, a_min_of_12, a_max_of_12)— Adds a fast arc to the current path.self:path_elliptical_arc_to(center, radius, a_min, a_max, num_segments)— Adds an elliptical arc.self:path_bezier_cubic_curve_to(p2, p3, p4, num_segments)— Adds a cubic Bezier curve to the path.self:path_bezier_quadratic_curve_to(p2, p3, num_segments)— Adds a quadratic Bezier curve to the path.self:path_rect(min, max, rounding, flags)— Adds a rectangle to the current path.