Skip to content

ImGui

The ImGui Lua wrapper is a package that provides a Lua interface for the popular ImGui module. It allows developers to create in-game user interfaces using the familiar Lua programming language. The wrapper offers a simple and easy-to-use API that mirrors the C++ API of the ImGui module. This package provides a wide range of UI elements and widgets, customizable styling options, and support for multiple languages and internationalization. With this package, developers can easily add robust UI functionality to their games and applications written in Lua. The package also supports advanced layout and positioning options and built-in support for common UI interactions such as drag and drop, and context menus.

Some of the key features include:

  • A wide range of UI elements and widgets
  • Customizable styling options
  • Support for multiple languages and internationalization
  • Advanced layout and positioning options
  • Support for keyboard and mouse input
  • Built-in support for common UI interactions such as drag and drop, and context menus.

Usage

To use this module, add the following require at the top of your script:

local Imgui = require 'engine/imgui'

Reference

setGlobalWindowPadding

static setGlobalWindowPadding(x, y)

Sets the global window padding for all windows.

Parameters

  • x (number): Padding for the x-axis.
  • y (number): Padding for the y-axis.

setGlobalWindowRounding

static setGlobalWindowRounding(r)

Sets the global window rounding for all windows.

Parameters

  • r (number): Rounding value.

setGlobalFramePadding

static setGlobalFramePadding(x, y)

Sets the global frame padding for all windows.

Parameters

  • x (float): Padding for the x-axis.
  • y (float): Padding for the y-axis.

setGlobalFrameRounding

static setGlobalFrameRounding(r)

Sets the global frame rounding for all windows.

Parameters

  • r (number): Rounding value.

setGlobalItemSpacing

static setGlobalItemSpacing(x, y)

Sets the global item spacing for all windows.

Parameters

  • x (number): Spacing for the x-axis.
  • y (number): Spacing for the y-axis.

setGlobalItemInnerSpacing

static setGlobalItemInnerSpacing(x, y)

Sets the global item inner spacing for all windows.

Parameters

  • x (number): Inner spacing for the x-axis.
  • y (number): Inner spacing for the y-axis.

setGlobalIndentSpacing

static setGlobalIndentSpacing(value)

Sets the global indent spacing for all windows.

Parameters

  • value (number): Indent spacing value.

setGlobalScrollbarSize

static setGlobalScrollbarSize(value)

Sets the global scrollbar size for all windows.

Parameters

  • value (number): Scrollbar size value.

setGlobalScrollbarRounding

static setGlobalScrollbarRounding(value)

Sets the global scrollbar rounding for all windows.

Parameters

  • value (number): The value of the scrollbar rounding.

setGlobalGrabMinSize

static setGlobalGrabMinSize(value)

Sets the global minimum width/height of a grab box for slider/scrollbar for all windows.

Parameters

  • value (number): The value of the minimum grab.

setGlobalGrabRounding

static setGlobalGrabRounding(value)

Sets the global radius of grabs corners rounding for all windows. Set to 0.0 to have rectangular slider grabs.

Parameters

  • value (number): The value of grabs corners rounding.

beginDialog

static beginDialog(text, x, y, flags)

Begins a new dialog.

Parameters

  • text (string): The title of the dialog.
  • x (number): The x coordinate of the dialog (optional).
  • y (number): The y coordinate of the dialog (optional).
  • flags (WindowFlags): Configuration flags.

endDialog

static endDialog()

Ends the current dialog.

beginMainMenuBar

static beginMainMenuBar()

Begins the main menu bar. See Menubar example.

Returns

  • boolean: true if the main menu bar is open, otherwise false.

endMainMenuBar

static endMainMenuBar()

Ends the current main menu bar.

beginMenuBar

static beginMenuBar()

Begins a new menu-bar inside current window. To be displayed correctly, the dialog parent needs to have the ImGui.WindowFlags.MenuBar flag enabled. See Menubar example.

Returns

  • boolean: true if the menu bar is open, otherwise false.

endMenuBar

static endMenuBar()

Ends the current menu bar.

beginMenu

static beginMenu(label)

Begins a new menu.

Parameters

Returns

  • boolean: true if the menu is open, otherwise false.

endMenu

static endMenu()

Ends the current menu.

static menuItem(mainLabel, secondaryLabel)

Creates a new menu item.

Parameters

  • mainLabel (string): The main label of the menu item.
  • secondaryLabel (string): The secondary label of the menu item.

Returns

  • boolean: true if the menu item is pressed, otherwise false.

beginChild

static beginChild(label)

Begins a child window. See Group Child example for a full example

Parameters

  • label (string): the label of the child window.

endChild

static endChild()

Ends the current child window.

beginGroup

static beginGroup()

Begins a new group of items. See Group Child example for a full example

endGroup

static endGroup()

Ends the current group of items.

beginTable

static beginTable(mode, number)

Begins a new table. See Table example for a full example.

Parameters

  • mode (string): The mode of the table.
  • number (number): The number of the table.

Returns

  • boolean: true if the table is open, otherwise false.

endTable

static endTable()

Ends the current table.

tableNextRow

static tableNextRow()

Moves to the next row in the table.

tableNextColumn

static tableNextColumn()

Appends into into the next column of the table.

moveToNextColumn

static moveToNextColumn()

Moves to the next column in the table.

tableSetCell

static tableSetCell(label)

Sets a cell in the table.

Parameters

  • label (string): The label of the cell.

createColumns

static createColumns(numberCols)

Creates the specified number of columns in the current window.

Parameters

  • numberCols (number): The number of columns.

beginTabBar

static beginTabBar(label, flags)

Begins a new tab bar. See Tabbar example for a full example.

Parameters

  • label (string): The label of the tab bar.
  • flags (TabBarFlags): Configuration flags.

Returns

  • boolean: true if the tab bar is open, otherwise false.

endTabBar

static endTabBar()

Ends the current tab bar.

beginTabItem

static beginTabItem(label, flags)

Begins a new tab item.

Parameters

  • label (string): The label of the tab item.
  • flags (TabBarFlags): Configuration flags.

Returns

  • boolean: true if the tab item is open, otherwise false.

endTabItem

static endTabItem()

Ends the current tab item.

beginTooltip

static beginTooltip()

Begins a new tooltip.

endTooltip

static endTooltip()

Ends the current tab item.

beginPopup

static beginPopup(label, flags)

Begins a new popup window. See Popup example for a full example.

Parameters

  • label (string): The label of the pop up item.
  • flags (PopupFlags): Configuration flags.

Returns

  • boolean: true if the popup is open, otherwise false.

endPopup

static endPopup()

Ends the current popup window.

openPopup

static openPopup(label)

Opens a popup window identified by the label.

Parameters

  • label

closeCurrentPopup

static closeCurrentPopup()

Closes the current popup window.

beginPopupModal

static beginPopupModal(label, flags)

Begins a new modal popup window.

Parameters

  • label (string): The label of the pop up modal item.
  • flags (PopupFlags): Configuration flags.

Returns

  • boolean: true if the popup is open, otherwise false.

text

static text(text)

Displays text to the current window.

Parameters

  • text (string): The text to be displayed.

textColored

static textColored(text, color)

Displays text to the current window with a given color.

Parameters

  • text (string): the text to be displayed.
  • color (WidgetColor): An instance of WidgetColor.

textWrapped

static textWrapped(text)

Displays wrapped text to the current window

Parameters

  • text (string): The text to be displayed.

inputText

static inputText(label, widgetString, flags)

Creates a text input widget.

Parameters

  • label (string): the label to add to the input widget.
  • widgetString (WidgetString): An intance of WidgetString to interact with the inputText widget.
  • flags (InputTextFlags): The flags to be used for the input label (optional).

Example

local gui = require 'engine/imgui'
widgetString = gui.WidgetString:new(32, "")
gui.inputText("your name", widgetString)

inputNumber

static inputNumber(label, widgetNumber, flags)

Creates a number input widget.

Parameters

  • label (string): the label to add to the input widget.
  • widgetNumber (WidgetNumber): An intance of WidgetString to interact with the inputNumber widget.
  • flags (InputTextFlags): The flags to be used for the input label (optional). They are the same for InputText.

Example

local gui = require 'engine/imgui'
widgetNumber = gui.WidgetNumber:new(42)
gui.inputNumber("Answer to The Ultimate Question of Life", widgetNumber)

bulletText

static bulletText(text)

Creates a bullet point with accompanying text.

Parameters

  • text (string): The text to display next to the bullet point.

indent

static indent()

Increases the horizontal indent of the subsequent widgets by a certain amount.

unindent

static unindent()

Decreases the horizontal indent of the subsequent widgets by a certain amount.

progressBar

static progressBar(status)

Creates a new progress bar.

Parameters

  • status (number): Progress status (0.0f to 1.0f) to represent in the progress bar.

sliderFloat

static sliderFloat(label, number, minValue, maxValue, format, flags)

Creates a new float slider.

Parameters

  • label (string): the label to add to the slider.
  • number (WidgetNumber): The widgetNumber to use as storage.
  • minValue (number): the minimum value for the slider.
  • maxValue (number): the maximum value for the slider.
  • format (string): format of the string in the slider. The default if omitted is "%f".
  • flags (SliderFlags): The flags to be used for the slider (optional).

sliderInt

static sliderInt(label, number, minValue, maxValue, format, flags)

Creates a new integer slider.

Parameters

  • label (string): The label to add to the slider.
  • number (WidgetNumber): The widgetNumber to use as storage.
  • minValue (number): The minimum value for the slider.
  • maxValue (number): The maximum value for the slider.
  • format (string): The format of the string in the slider. The default if omitted is "%d".
  • flags (SliderFlags): The flags to be used for the slider (optional).

sliderVector3

static sliderVector3(label, vector, minValue, maxValue, format, flags)

Creates a set of three sliders for manipulating a vector3 object.

Parameters

  • label (string): The label to display next to the sliders.
  • vector
  • minValue (number): The minimum value for the slider.
  • maxValue (number): The maximum value for the slider.
  • format (string): The format of the string in the slider. The default if omitted is "%f".
  • flags (SliderFlags): The flags to be used for the slider (optional).

button

static button(text, width, height)

Creates a new button.

Parameters

  • text (string): The text to be displayed on the button.
  • width (number): The width of the button (optional).
  • height (number): The height of the button (optional).

Returns

  • boolean: true if the button was clicked, otherwise false.

logButtons

static logButtons()

Logs button events in the ImGui interface.

logToClipboard

static logToClipboard()

Logs the current ImGui interface to the clipboard. Useful for debugging.

logFinish

static logFinish()

Stops logging events in the ImGui interface.

logText

static logText(text)

Logs a text in the ImGui interface.

Parameters

  • text (string): the text to log

separator

static separator()

Adds an horizontal separator between items.

spacing

static spacing()

Adds horizontal spacing between items.

sameLine

static sameLine(spacing, offset)

The next item will be created on the same line.

Parameters

  • spacing (number): The spacing between items in pixels. If not given, the default spacing is used.
  • offset (number): The X position where the next item should start in window coordiantes. If not given, the item is placed right after the previous one.

selectable

static selectable(text, flags)

Creates a selectable item.

Parameters

  • text (string): Text in the selectable item.
  • flags (SelectableFlags): Configuration flags.

checkbox

static checkbox(label, number)

Creates a new checkbox.

Parameters

  • label (string): The label of the checkbox.
  • number (WidgetNumber): The widgetNumber to use as storage.

checkboxFlags

static checkboxFlags(label, flags)

Creates a new checkbox to enable/disable flags.

Parameters

  • label (string): The label of the checkbox.
  • flags (ConfigFlags): Configuration flags.

combo

static combo(label, number, items)

Creates a combo box with a list of items to choose from.

Parameters

  • label (string): The label of the combo box.
  • number (WidgetNumber): The widgetNumber to use as storage. Note that arrays in ImGUI are indexed from 0 and arrays in Lua are indexed from 1. You will need to offset the arrays.
  • items (array): An array of strings to use as options.

collapsingHeader

static collapsingHeader(label)

Creates a collapsing header with a given label.

Parameters

  • label (string): The label of the header.

Returns

  • boolean: true if the header is open, false if it is closed.

treeNode

static treeNode(label)

Creates a tree node.

Parameters

  • label (string): The label of the tree node.

Returns

  • boolean: boolean indicating whether the tree node is open.

Example

local gui = require 'engine/imgui'
local TreeBehaviour = Class.new(Behaviour)

function TreeBehaviour:rendergui()
    gui.beginDialog("Tree Example")

    if gui.treeNode("Click to expand") then
        if gui.isItemToggledOpen() then
            gui.text("Just opened!")
        end
        gui.text("Some content...")
        gui.treePop()
    end

    gui.endDialog()
end
return TreeBehaviour

treePop

static treePop()

Ends the current tree node. Called after treeNode(), it ends a tree node and automatically pops it from the ImGui tree structure.

treePush

static treePush(label)

Add a tree node to the GUI with the given label.

Parameters

  • label (string): The label to display on the tree node.

colorPicker

static colorPicker(label, color, flags)

Creates a color picker.

Parameters

  • label (string): The label of the color picker.
  • color (WidgetColor): An instance of WidgetColor.
  • flags

Example

local gui = Nk.ImGui
gui.beginDialog("Color picker")
gui.colorPicker("Pick a color", color1)
gui.spacing()
gui.colorEdit("Edit a color", color2)
gui.endDialog()

colorEdit

static colorEdit(label, color, flags)

Creates a color edit. Similar to ColorPicker

Parameters

  • label (string): The label of the color picker.
  • color (WidgetColor): An instance of WidgetColor.
  • flags

setNextWindowPos

static setNextWindowPos(x, y)

Sets the position of the next window.

Parameters

  • x (number): The x-coordinate of the window position.
  • y (number): The y-coordinate of the window position.

setNextWindowSize

static setNextWindowSize(x, y)

Sets the size of the next window.

Parameters

  • x (number): Width of the window.
  • y (number): Height of the window.

setNextWindowContentSize

static setNextWindowContentSize(x, y)

Sets the content size of the ColorEditFlagsnext window.

Parameters

  • x (number): Width of the window content
  • y (number): Height of the window content

setNextWindowSizeConstraints

static setNextWindowSizeConstraints(minX, minY, maxX, maxY)

Sets the size constraints of the next window.

Parameters

  • minX
  • minY
  • maxX
  • maxY

setNextWindowCollapsed

static setNextWindowCollapsed(collapsed)

Sets the collapsed state of the next window.

Parameters

  • collapsed (boolean): Whether the window should be collapsed or not.

setNextWindowFocus

static setNextWindowFocus()

Sets the focus state of the next window.

setNextWindowBgAlpha

static setNextWindowBgAlpha(alpha)

Sets the background alpha value of the next window.

Parameters

  • alpha (number): The alpha value of the background, between 0 and 1.

isItemHovered

static isItemHovered()

Determines if the current item is hovered by the mouse cursor. For an example, see Item State Example.

Returns

  • boolean: if the current item is being hovered by the mouse cursor, false otherwise.

isItemClicked

static isItemClicked()

Determines if the current item has been clicked. For an example, see Item State Example.

Returns

  • boolean: if the current item has been clicked, false otherwise.

isItemToggledOpen

static isItemToggledOpen()

Determines if the current item is open. For an example, see Item State Example.

Returns

  • boolean: if the current item is toggled open, false otherwise.

isMouseClicked

static isMouseClicked(event)

Returns true if the mouse was clicked on the given event.

Parameters

  • event (MouseButton): The event for which to check for a mouse click.

setMouseCursor

static setMouseCursor(cursor)

Sets the mouse cursor to the given cursor type.

Parameters

Enum: BackendFlags

Enumeration of the available backend flags.

Field Name Description
None number: No flag set.
HasGamepad number: Backend platform supports gamepad and currently has one connected.
HasMouseCursors number: Backend platform supports honoring GetMouseCursor() value to change the OS cursor shape.
HasSetMousePos number: Backend platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
RendererHasVtxOffset number: Backend renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices.

Enum: ConfigFlags

Enumeration of the available configuration flags.

Field Name Description
None number: No flag set.
NavEnableKeyboard number: Enable keyboard controls.
NavEnableGamepad number: Enable gamepad controls.
NavEnableSetMousePos number: Enable mouse repositioning requests with io.WantSetMousePos.
NavNoCaptureKeyboard number: Disable keyboard capture by ImGui.
NoMouse number: Disable mouse controls.
NoMouseCursorChange number: Disable mouse cursor change requests.
IsSRGB number: Enable sRGB gamma correction.
IsTouchScreen number: Enable touch screen controls.

Enum: WindowFlags

Enumeration of the available window flags.

Field Name Description
None number: No flag set.
NoTitleBar number: Window doesn't have a title bar.
NoResize number: Window can't be resized.
NoMove number: Window can't be moved.
NoScrollbar number: Window has no scrollbar.
NoScrollWithMouse number: Window scrollbar doesn't respond to mouse scrolling.
NoCollapse number: Window can't be collapsed.
AlwaysAutoResize number: Window should resize to its content every frame.
ShowBorders number: Window has borders.
NoSavedSettings number: Never save settings (inodependent of ImGuiConfigFlags_NoSaveSettings).
NoMouseInputs number: Window will not receive mouse inputs.
MenuBar number: Window has a menu-bar.
HorizontalScrollbar number: Window has a horizontal scrollbar.
NoFocusOnAppearing number: Window doesn't take focus when first appearing.
NoBringToFrontOnFocus number: Window doesn't bring to front when taking focus.
AlwaysVerticalScrollbar number: Window has a vertical scrollbar.
AlwaysHorizontalScrollbar number: Window has a horizontal scrollbar.
AlwaysUseWindowPadding number: Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient).
NoNavInputs number: No gamepad/keyboard navigation within the window.
NoNavFocus number: No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB).
UnsavedDocument number: Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
NoNav number: No gamepad/keyboard navigation within the window and no focusing toward this window with gamepad/keyboard navigation.
NoDecoration number: Disable title-bar, resizing borders, and scrollbar.
NoInputs number: Window is completely sealed and won't receive inputs.

Enum: TabBarFlags

Enumeration of available tab bar flags.

Field Name Description
None number: No flags.
Reorderable number: Allow manually dragging tabs to re-order them + New tabs are appended at the end of list.
AutoSelectNewTabs number: Automatically select new tabs when they appear.
TabListPopupButton number: Disable buttons to open the tab list popup.
NoCloseWithMiddleMouseButton number: Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button.
NoTabListScrollingButtons number: Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll).
NoTooltip number: Disable tooltips when hovering a tab.
FittingPolicyResizeDown number: Resize tabs when they don't fit.
FittingPolicyScroll number: Add scroll buttons when tabs don't fit.
FittingPolicyMask number: Fitting policy mask (defaults to ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll).
FittingPolicyDefault number: Fitting policy when there are no tabs.

Enum: PopupFlags

Enumeration of available popup flags.

Field Name Description
None number: No flag set.
MouseButtonLeft number: Open on Left Mouse release.
MouseButtonRight number: Open on Right Mouse release.
MouseButtonMiddle number: Open on Middle Mouse release.
MouseButtonMask number: Bit mask for buttons.
MouseButtonDefault number: Open on MouseButtonRight Mouse release (default).
NoOpenOverExistingPopup number: Don't open if there's already a popup at the same level of the popup stack.
NoOpenOverItems number: Don't return true when hovering items, only when hovering empty space.
AnyPopupId number: Ignore the ImGuiID parameter and test for any popup.
AnyPopupLevel number: Search/test at any level of the popup stack.

Enum: InputTextFlags

Enumeration for input text flags.

Field Name Description
None number: No flags.
CharsDecimal number: Allow decimals and operators (0123456789.+-/).
CharsHexadecimal number: Allow decimals, operators ad letters (0123456789ABCDEFabcdef).
CharsUppercase number: Turn lowercase letters into uppercase.
CharsNoBlank number: Filter out spaces, tabs.
AutoSelectAll number: Select entire text when first taking mouse focus.
EnterReturnsTrue number: Return 'true' when Enter is pressed (as opposed to every time the value was modified).
CallbackCompletion number: Callback on pressing TAB (for completion handling).
CallbackHistory number: Callback on pressing Up/Down arrows (for history handling).
CallbackAlways number: Callback on each iteration. User code may query cursor position, modify text buffer.
CallbackCharFilter number: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
AllowTabInput number: Pressing TAB input a 't' character into the text field.
CtrlEnterForNewLine number: In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite unfocus with Ctrl+Enter, add line with Enter).
NoHorizontalScroll number: Disable following the cursor horizontally.
AlwaysOverwrite number: Overwrite mode.
ReadOnly number: Read-only mode.
Password number: Password mode, display all characters as ''.
NoUndoRedo number: Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
CharsScientific number: Allow scientific notation input (0123456789.+-*/eE).
CallbackResize number: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
CallbackEdit number: Callback on any edit.
EscapeClearsAll number: Clears the input when Escape key is pressed.

Class: WidgetString

new

new(length, initialValue)

Creates a new WidgetString object with the given length and initial value.

Parameters

  • length (number): The length (in bytes) of the buffer where the string is stored.
  • initialValue (string): The initial value of the string.

getValue

getValue()

Retrieves the value stored inside an instance of WidgetString.

Returns

  • string: string stored inside the instance of WidgetString.

setValue

setValue(value)

Sets a new internal value to an instance of WidgetString.

Parameters

  • value (string): The value to set the widget string to.

__concat

static __concat(self, other)

Concatenation operator for WidgetString. It also accepts primitive strings.

Parameters

  • self
  • other (WidgetString|string): The other WidgetString or string to concatenate with.

Returns

  • string: concatenated string.

__eq

static __eq(self, other)

Equality operator for WidgetString.

Parameters

  • self
  • other (WidgetString|string): The other WidgetString or string to compare with.

Returns

  • boolean: if the values are equal.

__tostring

__tostring()

Returns the string representation of the WidgetString.

Returns

  • string: string value.

Class: WidgetNumber

new

new(initialValue)

Creates a new WidgetNumber object with the given initial value

Parameters

  • initialValue (number): The initial value stored internally.

getValue

getValue()

Retrieves the value stored inside an instance of WidgetNumber.

Returns

  • number: value interally stored inside the widget number.

setValue

setValue(value)

Sets a new internal value to an instance of WidgetNumber.

Parameters

  • value (number): The value to set the widget number to.

__add

static __add(self, other)

Sum operator for widgetNumber. It also accepts primitive number.

Parameters

  • self
  • other (WidgetNumber): The other WidgetNumber (or number) to add to.

Returns

  • number: sum of the two values.

__mul

static __mul(self, other)

Multiplication operator for widgetNumber. It also accepts primitive number.

Parameters

  • self
  • other (WidgetNumber): The other WidgetNumber instance to multiply to.

Returns

  • number: product of the two values.

Class: WidgetVector3

new

new(x, y, z)

Creates a new WidgetVector3 object with the given initial values for x, y, z.

Parameters

  • x (number): The initial x component value.
  • y (number): The initial y component value.
  • z (number): The initial z component value.

Returns

  • WidgetVector3: new WidgetVector3 instance.

getValue

getValue()

Retrieves the vector components stored inside an instance of WidgetVector3.

Returns

  • number: The X component
  • number: The Y component
  • number: The Z component

setValue

setValue(x, y, z)

Sets new internal values for the x, y, z components of an instance of WidgetVector3.

Parameters

  • x (number): The x component to set.
  • y (number): The y component to set.
  • z (number): The z component to set.

__add

static __add(self, other)

Addition operator for WidgetVector3. It also accepts primitive number.

Parameters

  • self
  • other (WidgetVector3): The other WidgetVector3 (or number) to add to.

Returns

  • WidgetVector3: sum of the two vectors.

__sub

static __sub(self, other)

Subtraction operator for WidgetVector3. It also accepts primitive number.

Parameters

  • self
  • other (WidgetVector3): The other WidgetVector3 (or number) to subtract from.

Returns

  • WidgetVector3: difference between the two vectors.

Enum: SliderFlags

Enumeration for slider flags

Field Name Description
None number: No flag set.
AlwaysClamp number: Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
Logarithmic number: Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
NoRoundToFormat number: Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits).
NoInput number: Disable CTRL+Click or Enter key allowing to input text directly into the widget.

Enum: SelectableFlags

Enum for selectable flags

Field Name Description
None number: No flag set.
DontClosePopups number: Clicking this doesn't close parent popup window.
SpanAllColumns number: Selectable frame can span all columns (text will still fit in current column).
AllowDoubleClick number: Generate press events on double clicks too.
Disabled number: Cannot be selected, display grayed out text.
AllowItemOverlap number: (WIP) Hit testing to allow subsequent widgets to overlap this one.

Class: WidgetColor

new

new(r, g, b, a)

Creates a new WidgetColor object with the given RGBA values. The RGBA values range from 0 to 1.

Parameters

  • r (number): The red color component channel.
  • g (number): The green color component channel.
  • b (number): The blue color component channel.
  • a (number): The alpha color component channel.

Returns

  • WidgetColor: new WidgetColor instance.

getValue

getValue()

Retrieves the RGBA components stored inside an instance of WidgetColor. The RGBA values range from 0 to 1.

Returns

  • number: Red component
  • number: Green component
  • number: Blue component
  • number: Alpha component

setValue

setValue(r, g, b, a)

Sets new internal values for the r, g, b, a components of an instance of WidgetColor. The RGBA values range from 0 to 1.

Parameters

  • r (number): The r component to set.
  • g (number): The g component to set.
  • b (number): The b component to set.
  • a (number): The a component to set.

Enum: ColorEditFlags

Enumeration of flags for the color editing widgets.

Field Name Description
None number: No flag set.
NoAlpha number: ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer).
NoPicker number: ColorEdit: disable picker when clicking on color square.
NoOptions number: ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
NoSmallPreview number: ColorEdit, ColorPicker: disable color square preview next to the inputs. (e.g. to show only the inputs)
NoInputs number: ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview color square).
NoTooltip number: ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview.
NoLabel number: ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
NoSidePreview number: ColorPicker: disable bigger color preview on right side of the picker, use small color square preview instead.
NoDragDrop number: ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
NoBorder number: ColorButton: disable border (which is enforced by default)
AlphaBar number: ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
AlphaPreview number: ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
AlphaPreviewHalf number: ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque.
HDR number: ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
DisplayRGB number: ColorEdit: override display type among RGB.
DisplayHSV number: ColorEdit: override display type among HSV.
DisplayHex number: ColorEdit: override display type among Hex.
Uint8 number: Display values formatted as 0..255.
Float number: Display values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers.
PickerHueBar number: Display a bar for Hue and rectangle for Sat/Value.
PickerHueWheel number: Display a wheel for Hue and triangle for Sat/Value.
InputRGB number: Input and output data in RGB format.
InputHSV number: Input and output data in HSV format.

Enum: MouseButton

Enumeration for mouse button events.

Field Name Description
Left number: Index for the left mouse button.
Right number: Index for the right mouse button.
Middle number: Index for the middle mouse button.
COUNT number: The number of mouse buttons.

Enum: MouseCursor

Enumeration of mouse cursor types for use with SetMouseCursor().

Field Name Description
None number: No cursor.
Arrow number: Arrow cursor.
TextInput number: Text input I-beam cursor.
ResizeAll number: (Unused by Dear ImGui functions).
ResizeNS number: Vertical resize cursor.
ResizeEW number: Horizontal resize cursor.
ResizeNESW number: Cursor for resizing bottom-left corner of window.
ResizeNWSE number: Cursor for resizing bottom-right corner of window.
Hand number: Sets mouse cursor to hand.
NotAllowed number: Cursor for disallowed interaction (usually a crossed circle).
COUNT number: Number of cursor types.

Examples

Creating Menu bars
local Imgui = require 'engine/imgui'
local Controller = Class.new(Behaviour)

function Controller:rendergui()
    -- Begins a new main menu bar on top of the screen
    if (Imgui.beginMainMenuBar()) then
        if (Imgui.beginMenu("File")) then
            if (Imgui.menuItem("New", "Open New File")) then
                -- new file logic here
            end
            if (Imgui.menuItem("Open", "Open New File")) then
                -- open file logic here
            end
            if (Imgui.menuItem("Save", "Save File")) then
                -- save file logic here
            end
            Imgui.endMenu()
        end
        if (Imgui.beginMenu("Edit", "Edit File")) then
            if (Imgui.menuItem("Undo", "Undo Change")) then
                -- undo logic here
            end
            if (Imgui.menuItem("Redo", "Redo change")) then
                -- redo logic here
            end
            Imgui.endMenu()
        end
        Imgui.endMainMenuBar()
    end

    -- Dialog with menu bar (outside the main menu bar condition)
    if (Imgui.beginDialog("Dialog Menu Test", 200, 100, Imgui.WindowFlags.MenuBar)) then
        if (Imgui.beginMenuBar()) then
            -- Need to use beginMenu for dropdown menus
            if (Imgui.beginMenu("Objects")) then
                if (Imgui.menuItem("Meshes", "Add Mesh")) then
                    -- mesh logic here
                end
                if (Imgui.menuItem("Materials", "Add Material")) then
                    -- material logic here
                end
                Imgui.endMenu()  -- Don't forget to end the menu
            end

            if (Imgui.beginMenu("PostFx")) then
                if (Imgui.menuItem("Bloom", "Add Bloom")) then
                    -- bloom effect logic here
                end
                if (Imgui.menuItem("Depth of Field", "Add DoF")) then
                    -- DoF logic here
                end
                Imgui.endMenu()  -- Don't forget to end the menu
            end
            Imgui.endMenuBar()  -- End the menu bar
        end

        Imgui.text("Dialog menu test")
        -- Rest of dialog content here

        Imgui.endDialog()
    end
end

return Controller
Group Child example
Using Groups and Child
local Imgui = require 'engine/imgui'
local Controller = Class.new(Behaviour)

function Controller:rendergui()
    -- First dialog with child window example (positioned to the left)
    if (Imgui.beginDialog("Child Window Example", 550, 650, Imgui.WindowFlags.MenuBar)) then
        -- Add a menu bar to the dialog
        if (Imgui.beginMenuBar()) then
            if (Imgui.beginMenu("File")) then
                if (Imgui.menuItem("Save", "Save content")) then
                    -- Save logic
                end
                if (Imgui.menuItem("Load", "Load content")) then
                    -- Load logic
                end
                Imgui.endMenu()
            end

            if (Imgui.beginMenu("View")) then
                if (Imgui.menuItem("Refresh", "Refresh content")) then
                    -- Refresh logic
                end
                Imgui.endMenu()
            end
            Imgui.endMenuBar()
        end

        -- Add title with some padding
        Imgui.spacing()
        Imgui.text("CHILD WINDOW EXAMPLE")
        Imgui.separator()
        Imgui.spacing()

        -- Make child window slightly smaller to ensure padding
        if (Imgui.beginChild("Scrolling", 520, 480, true)) then
            for n=1,30,1 do
                Imgui.text("Scrollable content item " .. n)

                if (n % 5 == 0) then
                    -- Imgui.pushItemWidth(200)  -- Control width of buttons
                    if (Imgui.button("Button " .. n)) then
                        -- Button action logic
                    end
                    -- Imgui.popItemWidth()
                    Imgui.spacing()
                end
            end

            Imgui.endChild()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()
        Imgui.text("Footer content")

        -- Center the close button
        local windowWidth = 550
        local buttonWidth = 100
        -- Imgui.setCursorPosX((windowWidth - buttonWidth) / 2)
        if (Imgui.button("Close", buttonWidth, 30)) then
            -- Close logic
        end

        Imgui.endDialog()
    end

    -- Second dialog with group example (positioned to the right)
    if (Imgui.beginDialog("Group Example", 600, 400)) then
        -- Add title with some padding
        Imgui.spacing()
        Imgui.text("GROUP LAYOUT EXAMPLE")
        Imgui.separator()
        Imgui.spacing()

        -- Create the first group
        Imgui.beginGroup()
        Imgui.text("Group 1")
        Imgui.spacing()
        -- Imgui.pushItemWidth(150)  -- Consistent control width
        if (Imgui.button("Button 1", 150, 30)) then
            -- Button 1 logic
        end
        Imgui.spacing()
        if (Imgui.button("Button 2", 150, 30)) then
            -- Button 2 logic
        end
        Imgui.spacing()
        -- Add a slider to the first group
        local value1 = 50 -- This should be a class variable in practice
        -- value1 = Imgui.sliderFloat("Slider 1", value1, 0, 100)
        -- Imgui.popItemWidth()
        Imgui.endGroup()

        -- Place the second group on the same line with ample spacing
        Imgui.sameLine(250) -- Add more spacing between groups

        -- Create the second group
        Imgui.beginGroup()
        Imgui.text("Group 2")
        Imgui.spacing()
        -- Imgui.pushItemWidth(150)  -- Consistent control width
        if (Imgui.button("Button 3", 150, 30)) then
            -- Button 3 logic
        end
        Imgui.spacing()
        if (Imgui.button("Button 4", 150, 30)) then
            -- Button 4 logic
        end
        Imgui.spacing()
        -- Add a checkbox to the second group
        local checked = false -- This should be a class variable in practice
        -- checked = Imgui.checkbox("Option 1", checked)
        -- Imgui.popItemWidth()
        Imgui.endGroup()

        -- Add a visual separator with ample spacing
        Imgui.spacing()
        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()
        Imgui.spacing()

        -- Create a third group below
        Imgui.text("Groups can also be used for vertical layout:")
        Imgui.spacing()

        -- Center this group
        local windowWidth = 600
        local groupWidth = 400
        -- Imgui.setCursorPosX((windowWidth - groupWidth) / 2)

        Imgui.beginGroup()
        Imgui.text("Group 3 - Controls")
        Imgui.spacing()
        if (Imgui.button("Save Settings", 180, 30)) then
            -- Save settings logic
        end
        Imgui.sameLine(200)
        if (Imgui.button("Load Settings", 180, 30)) then
            -- Load settings logic
        end
        Imgui.endGroup()

        Imgui.spacing()
        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Center the close button
        -- Imgui.setCursorPosX((windowWidth - 100) / 2)
        if (Imgui.button("Close Dialog", 100, 30)) then
            -- Close dialog logic
        end

        Imgui.endDialog()
    end
end

return Controller
Table example
Using Tables
local Imgui = require 'engine/imgui'
local TableController = Class.new(Behaviour)

function TableController:rendergui()
    -- Demo dialog with table examples
    if (Imgui.beginDialog("Table Examples")) then
        -- Add title with some padding
        Imgui.spacing()
        Imgui.text("TABLE INTERFACE EXAMPLES")
        Imgui.separator()
        Imgui.spacing()

        -- Basic Table Example
        Imgui.text("Basic 3-Column Table Example:")
        Imgui.spacing()

        if (Imgui.beginTable("BasicTable", 3)) then
            -- Table headers
            Imgui.tableNextColumn()
            Imgui.text("Name")
            Imgui.tableNextColumn()
            Imgui.text("Value")
            Imgui.tableNextColumn()
            Imgui.text("Description")

            -- First row
            Imgui.tableNextRow()
            Imgui.tableNextColumn()
            Imgui.text("Item 1")
            Imgui.tableNextColumn()
            Imgui.text("42")
            Imgui.tableNextColumn()
            Imgui.text("First item description")

            -- Second row
            Imgui.tableNextRow()
            Imgui.tableNextColumn()
            Imgui.text("Item 2")
            Imgui.tableNextColumn()
            Imgui.text("75")
            Imgui.tableNextColumn()
            Imgui.text("Second item description")

            -- Third row
            Imgui.tableNextRow()
            Imgui.tableNextColumn()
            Imgui.text("Item 3")
            Imgui.tableNextColumn()
            Imgui.text("150")
            Imgui.tableNextColumn()
            Imgui.text("Third item description")

            Imgui.endTable()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Table with interactive elements
        Imgui.text("Table with Interactive Elements:")
        Imgui.spacing()

        if (Imgui.beginTable("InteractiveTable", 3)) then
            -- Table headers
            Imgui.tableNextColumn()
            Imgui.text("Control")
            Imgui.tableNextColumn()
            Imgui.text("Status")
            Imgui.tableNextColumn()
            Imgui.text("Action")

            -- Row 1
            Imgui.tableNextRow()
            Imgui.tableNextColumn()
            Imgui.text("Option A")
            Imgui.tableNextColumn()
            Imgui.text("Enabled")
            Imgui.tableNextColumn()
            if (Imgui.button("Disable A", 100, 25)) then
                -- Disable logic
            end

            -- Row 2
            Imgui.tableNextRow()
            Imgui.tableNextColumn()
            Imgui.text("Option B")
            Imgui.tableNextColumn()
            Imgui.text("Disabled")
            Imgui.tableNextColumn()
            if (Imgui.button("Enable B", 100, 25)) then
                -- Enable logic
            end

            -- Row 3
            Imgui.tableNextRow()
            Imgui.tableNextColumn()
            Imgui.text("Option C")
            Imgui.tableNextColumn()
            Imgui.text("Enabled")
            Imgui.tableNextColumn()
            if (Imgui.button("Disable C", 100, 25)) then
                -- Disable logic
            end

            Imgui.endTable()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Data Table Example
        Imgui.text("Data Entry Table Example:")
        Imgui.spacing()

        -- Use columns as an alternative layout option
        Imgui.createColumns(2)

        -- Left column - table
        if (Imgui.beginTable("DataTable", 2)) then
            -- Headers
            Imgui.tableNextColumn()
            Imgui.text("Parameter")
            Imgui.tableNextColumn()
            Imgui.text("Value")

            -- Generate some data rows
            for i=1,6,1 do
                Imgui.tableNextRow()
                Imgui.tableNextColumn()
                Imgui.text("Parameter " .. i)
                Imgui.tableNextColumn()
                Imgui.text(tostring(i * 10))
            end

            Imgui.endTable()
        end

        -- Move to the second column
        Imgui.moveToNextColumn()

        -- Right column - controls
        Imgui.text("Controls:")
        Imgui.spacing()

        if (Imgui.button("Add Row", 120, 30)) then
            -- Add row logic
        end

        Imgui.spacing()

        if (Imgui.button("Remove Row", 120, 30)) then
            -- Remove row logic
        end

        Imgui.spacing()

        if (Imgui.button("Update Values", 120, 30)) then
            -- Update values logic
        end

        -- Reset columns
        Imgui.createColumns(1)

        Imgui.spacing()
        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Footer with button
        if (Imgui.button("Close", 100, 30)) then
            -- Close dialog logic
        end

        Imgui.endDialog()
    end
end

return TableController
Tabbar example
Using the Tab Bar element.
local Imgui = require 'engine/imgui'
local TabBarController = Class.new(Behaviour)

function TabBarController:rendergui()
    -- Demo dialog with various tab bar examples
    Imgui.setNextWindowSize(750,850)
    if (Imgui.beginDialog("Tab Bar Examples")) then
        -- Add title with some padding
        Imgui.spacing()
        Imgui.text("TAB BAR INTERFACE EXAMPLES")
        Imgui.separator()
        Imgui.spacing()

        -- Define some colors for use in our tabs (commented out until createColor is supported)
        -- local colorBlue = Imgui.createColor(0, 0.5, 1, 1)
        -- local colorGreen = Imgui.createColor(0, 0.8, 0, 1)
        -- local colorRed = Imgui.createColor(1, 0, 0, 1)
        -- local colorYellow = Imgui.createColor(1, 0.9, 0, 1)

        -- Basic Tab Bar Example
        Imgui.text("Basic Tab Bar:")
        Imgui.spacing()

        if (Imgui.beginTabBar("BasicTabBar", Imgui.TabBarFlags.None)) then
            -- First tab
            if (Imgui.beginTabItem("Overview")) then
                Imgui.spacing()
                Imgui.text("This is a basic tab bar example.")
                Imgui.spacing()
                Imgui.text("Each tab contains different content and can be selected by clicking on the tab header.")
                Imgui.spacing()
                -- Using regular text instead of colored text
                Imgui.text("Try clicking on the other tabs to see their content!")
                -- Imgui.textColored("Try clicking on the other tabs to see their content!", colorBlue)
                Imgui.endTabItem()
            end

            -- Second tab
            if (Imgui.beginTabItem("Details")) then
                Imgui.spacing()
                Imgui.text("Tab Details:")
                Imgui.spacing()
                Imgui.text("- Tabs organize content into separate sections")
                Imgui.text("- Only one tab is visible at a time")
                Imgui.text("- Tabs can contain any UI elements")
                Imgui.spacing()

                if (Imgui.button("Click Me!", 120, 30)) then
                    -- Button action logic
                end

                Imgui.endTabItem()
            end

            -- Third tab
            if (Imgui.beginTabItem("Help")) then
                Imgui.spacing()
                Imgui.text("Tab Navigation:")
                Imgui.spacing()
                Imgui.text("- Click on tab headers to switch between tabs")
                Imgui.text("- Each tab maintains its own state")
                Imgui.endTabItem()
            end

            Imgui.endTabBar()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Advanced Tab Bar with Flags
        Imgui.text("Advanced Tab Bar with Flags:")
        Imgui.spacing()

        -- Combining multiple flags
        local tabFlags = Imgui.TabBarFlags.Reorderable + Imgui.TabBarFlags.AutoSelectNewTabs

        if (Imgui.beginTabBar("AdvancedTabBar", tabFlags)) then
            -- Data tab
            if (Imgui.beginTabItem("Data", Imgui.TabBarFlags.None)) then
                Imgui.spacing()
                Imgui.text("Data View")
                Imgui.spacing()

                -- Add a table inside the tab
                if (Imgui.beginTable("DataTable", 3)) then
                    -- Table headers
                    Imgui.tableNextColumn()
                    Imgui.text("Name")
                    -- Imgui.textColored("Name", colorBlue)
                    Imgui.tableNextColumn()
                    Imgui.text("Value")
                    -- Imgui.textColored("Value", colorBlue)
                    Imgui.tableNextColumn()
                    Imgui.text("Status")
                    -- Imgui.textColored("Status", colorBlue)

                    -- Row 1
                    Imgui.tableNextRow()
                    Imgui.tableNextColumn()
                    Imgui.text("Alpha")
                    Imgui.tableNextColumn()
                    Imgui.text("42")
                    Imgui.tableNextColumn()
                    Imgui.text("Active")
                    -- Imgui.textColored("Active", colorGreen)

                    -- Row 2
                    Imgui.tableNextRow()
                    Imgui.tableNextColumn()
                    Imgui.text("Beta")
                    Imgui.tableNextColumn()
                    Imgui.text("78")
                    Imgui.tableNextColumn()
                    Imgui.text("Pending")
                    -- Imgui.textColored("Pending", colorYellow)

                    -- Row 3
                    Imgui.tableNextRow()
                    Imgui.tableNextColumn()
                    Imgui.text("Gamma")
                    Imgui.tableNextColumn()
                    Imgui.text("15")
                    Imgui.tableNextColumn()
                    Imgui.text("Inactive")
                    -- Imgui.textColored("Inactive", colorRed)

                    Imgui.endTable()
                end

                Imgui.spacing()
                Imgui.text("This tab demonstrates a data view with a table.")
                Imgui.text("Try dragging this tab to reorder it (Reorderable flag is enabled).")

                Imgui.endTabItem()
            end

            -- Settings tab
            if (Imgui.beginTabItem("Settings", Imgui.TabBarFlags.None)) then
                Imgui.spacing()
                Imgui.text("Settings Panel")
                Imgui.spacing()

                -- Create columns for settings
                Imgui.createColumns(2)

                -- Left column
                Imgui.text("General Settings:")
                Imgui.spacing()

                if (Imgui.button("Save Configuration", 150, 30)) then
                    -- Save config logic
                end

                Imgui.spacing()

                if (Imgui.button("Load Configuration", 150, 30)) then
                    -- Load config logic
                end

                -- Move to right column
                Imgui.moveToNextColumn()

                Imgui.text("Display Settings:")
                Imgui.spacing()

                if (Imgui.button("Set Resolution", 150, 30)) then
                    -- Resolution logic
                end

                Imgui.spacing()

                if (Imgui.button("Toggle Fullscreen", 150, 30)) then
                    -- Fullscreen logic
                end

                -- Reset columns
                Imgui.createColumns(1)

                Imgui.spacing()
                Imgui.separator()
                Imgui.spacing()
                Imgui.text("This tab demonstrates settings with a column layout.")

                Imgui.endTabItem()
            end

            -- Statistics tab
            if (Imgui.beginTabItem("Statistics", Imgui.TabBarFlags.None)) then
                Imgui.spacing()
                Imgui.text("Statistics View")
                Imgui.spacing()

                -- Use a child window for scrollable content
                if (Imgui.beginChild("StatsContent", 0, 200, true)) then
                    Imgui.text("Performance Metrics:")
                    Imgui.spacing()

                    for i=1,10,1 do
                        Imgui.text("Metric " .. i .. ": " .. math.random(10, 100) .. "%")
                        Imgui.spacing()
                    end

                    Imgui.endChild()
                end

                Imgui.spacing()
                Imgui.text("This tab demonstrates scrollable content in a child window.")

                Imgui.endTabItem()
            end

            Imgui.endTabBar()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Nested Tab Bars Example
        Imgui.text("Nested Tab Bars:")
        Imgui.spacing()

        if (Imgui.beginTabBar("OuterTabBar", Imgui.TabBarFlags.None)) then
            -- First outer tab
            if (Imgui.beginTabItem("Main")) then
                Imgui.spacing()
                Imgui.text("Main Content")
                Imgui.spacing()

                -- Nested inner tab bar
                if (Imgui.beginTabBar("InnerTabBar", Imgui.TabBarFlags.None)) then
                    -- First inner tab
                    if (Imgui.beginTabItem("Sub-A")) then
                        Imgui.spacing()
                        Imgui.text("This is Sub-section A")
                        Imgui.spacing()
                        Imgui.text("Nested tab bars can help organize complex interfaces.")
                        Imgui.endTabItem()
                    end

                    -- Second inner tab
                    if (Imgui.beginTabItem("Sub-B")) then
                        Imgui.spacing()
                        Imgui.text("This is Sub-section B")
                        Imgui.spacing()

                        if (Imgui.button("Action B", 100, 30)) then
                            -- Action logic
                        end

                        Imgui.endTabItem()
                    end

                    -- Third inner tab
                    if (Imgui.beginTabItem("Sub-C")) then
                        Imgui.spacing()
                        Imgui.text("This is Sub-section C")
                        Imgui.spacing()
                        Imgui.text("Nested tabs can go multiple levels deep if needed.")
                        -- Imgui.textColored("Nested tabs can go multiple levels deep if needed.", colorBlue)
                        Imgui.endTabItem()
                    end

                    Imgui.endTabBar()
                end

                Imgui.endTabItem()
            end

            -- Second outer tab
            if (Imgui.beginTabItem("Options")) then
                Imgui.spacing()
                Imgui.text("Options Panel")
                Imgui.spacing()

                if (Imgui.button("Apply", 100, 30)) then
                    -- Apply logic
                end

                Imgui.sameLine(120)

                if (Imgui.button("Reset", 100, 30)) then
                    -- Reset logic
                end

                Imgui.endTabItem()
            end

            Imgui.endTabBar()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Footer with button
        if (Imgui.button("Close", 100, 30)) then
            -- Close dialog logic
        end

        Imgui.endDialog()
    end
end

return TabBarController
Creating different types of popups.
local Imgui = require 'engine/imgui'
local PopupController = Class.new(Behaviour)

function PopupController:rendergui()
    -- Demo dialog with various popup examples
    if (Imgui.beginDialog("Popup Examples")) then
        -- Add title with some padding
        Imgui.spacing()
        Imgui.text("POPUP INTERFACE EXAMPLES")
        Imgui.separator()
        Imgui.spacing()

        -- Basic Popup Example
        Imgui.text("Basic Popup:")
        Imgui.spacing()

        if (Imgui.button("Open Basic Popup", 150, 30)) then
            Imgui.openPopup("BasicPopup")
        end

        -- Basic popup implementation
        if (Imgui.beginPopup("BasicPopup")) then
            Imgui.text("This is a basic popup!")
            Imgui.spacing()
            Imgui.text("Popups appear over the current window")
            Imgui.text("and capture keyboard/mouse inputs.")
            Imgui.spacing()

            if (Imgui.button("Close", 100, 30)) then
                Imgui.closeCurrentPopup()
            end

            Imgui.endPopup()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Context Menu Popup Example
        Imgui.text("Context Menu Popup (Right-click below):")
        Imgui.spacing()

        -- Create a rectangle or area where right-click will open the popup
        -- In actual implementation, you might have a visual element here
        Imgui.text("Right-click in this area to open context menu")

        -- Use PopupFlags.MouseButtonRight to open on right mouse button
        if (Imgui.beginPopup("ContextMenu", Imgui.PopupFlags.MouseButtonRight)) then
            Imgui.text("Context Menu")
            Imgui.separator()

            if (Imgui.button("Option 1", 120, 25)) then
                -- Option 1 logic
                Imgui.closeCurrentPopup()
            end

            if (Imgui.button("Option 2", 120, 25)) then
                -- Option 2 logic
                Imgui.closeCurrentPopup()
            end

            if (Imgui.button("Option 3", 120, 25)) then
                -- Option 3 logic
                Imgui.closeCurrentPopup()
            end

            Imgui.separator()

            if (Imgui.button("Cancel", 120, 25)) then
                Imgui.closeCurrentPopup()
            end

            Imgui.endPopup()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Modal Popup Example
        Imgui.text("Modal Popup (blocks interaction with other windows):")
        Imgui.spacing()

        if (Imgui.button("Open Modal Dialog", 150, 30)) then
            Imgui.openPopup("ModalPopup")
        end

        -- Modal popup - blocks interaction with other windows until closed
        if (Imgui.beginPopupModal("ModalPopup")) then
            Imgui.text("This is a modal popup")
            Imgui.spacing()
            Imgui.text("Modal popups prevent interaction with other windows")
            Imgui.text("until they are closed. They're useful for important")
            Imgui.text("decisions or notifications that require attention.")
            Imgui.spacing()

            -- Create a simple form inside the modal
            Imgui.text("Enter value:")
            -- Here you would typically have an input field

            Imgui.spacing()
            Imgui.separator()
            Imgui.spacing()

            -- Buttons at the bottom
            if (Imgui.button("Confirm", 100, 30)) then
                -- Confirm action logic
                Imgui.closeCurrentPopup()
            end

            Imgui.sameLine(120)

            if (Imgui.button("Cancel", 100, 30)) then
                Imgui.closeCurrentPopup()
            end

            Imgui.endPopup()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Nested Popup Example
        Imgui.text("Nested Popups:")
        Imgui.spacing()

        if (Imgui.button("Open Parent Popup", 150, 30)) then
            Imgui.openPopup("ParentPopup")
        end

        -- Parent popup that contains a button to open a child popup
        if (Imgui.beginPopup("ParentPopup")) then
            Imgui.text("Parent Popup")
            Imgui.spacing()
            Imgui.text("This popup contains a button to open another popup.")
            Imgui.spacing()

            if (Imgui.button("Open Child Popup", 150, 30)) then
                Imgui.openPopup("ChildPopup")
            end

            -- Nested child popup
            if (Imgui.beginPopup("ChildPopup")) then
                Imgui.text("Child Popup")
                Imgui.spacing()
                Imgui.text("This is a popup inside another popup!")
                Imgui.spacing()

                if (Imgui.button("Close Child", 120, 30)) then
                    Imgui.closeCurrentPopup() -- Closes only the child popup
                end

                Imgui.endPopup()
            end

            Imgui.spacing()
            Imgui.separator()
            Imgui.spacing()

            if (Imgui.button("Close Parent", 120, 30)) then
                Imgui.closeCurrentPopup() -- Closes the parent popup
            end

            Imgui.endPopup()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Popup with Complex Content Example
        Imgui.text("Popup with Complex Content:")
        Imgui.spacing()

        if (Imgui.button("Open Complex Popup", 150, 30)) then
            Imgui.openPopup("ComplexPopup")
        end

        -- Popup containing more complex UI elements
        if (Imgui.beginPopup("ComplexPopup")) then
            Imgui.text("Complex Popup Example")
            Imgui.spacing()

            -- Create columns inside the popup
            Imgui.createColumns(2)

            -- Left column
            Imgui.text("Column 1")
            Imgui.spacing()

            if (Imgui.button("Button 1", 120, 30)) then
                -- Button 1 logic
            end

            Imgui.spacing()

            if (Imgui.button("Button 2", 120, 30)) then
                -- Button 2 logic
            end

            -- Right column
            Imgui.moveToNextColumn()

            Imgui.text("Column 2")
            Imgui.spacing()

            -- Add a table inside the popup
            if (Imgui.beginTable("PopupTable", 2)) then
                Imgui.tableNextColumn()
                Imgui.text("Name")
                Imgui.tableNextColumn()
                Imgui.text("Value")

                Imgui.tableNextRow()
                Imgui.tableNextColumn()
                Imgui.text("Item 1")
                Imgui.tableNextColumn()
                Imgui.text("100")

                Imgui.tableNextRow()
                Imgui.tableNextColumn()
                Imgui.text("Item 2")
                Imgui.tableNextColumn()
                Imgui.text("200")

                Imgui.endTable()
            end

            -- Reset columns
            Imgui.createColumns(1)

            Imgui.spacing()
            Imgui.separator()
            Imgui.spacing()

            if (Imgui.button("Close", 100, 30)) then
                Imgui.closeCurrentPopup()
            end

            Imgui.endPopup()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- File Menu Popup Example
        Imgui.text("Menu-Style Popup:")
        Imgui.spacing()

        if (Imgui.button("Show File Menu", 150, 30)) then
            Imgui.openPopup("FileMenuPopup")
        end

        -- Menu-style popup
        if (Imgui.beginPopup("FileMenuPopup")) then
            Imgui.text("File")
            Imgui.separator()

            if (Imgui.button("New", 100, 25)) then
                -- New file logic
                Imgui.closeCurrentPopup()
            end

            if (Imgui.button("Open...", 100, 25)) then
                -- Open file logic
                Imgui.closeCurrentPopup()
            end

            if (Imgui.button("Save", 100, 25)) then
                -- Save file logic
                Imgui.closeCurrentPopup()
            end

            if (Imgui.button("Save As...", 100, 25)) then
                -- Save as logic
                Imgui.closeCurrentPopup()
            end

            Imgui.separator()

            if (Imgui.button("Exit", 100, 25)) then
                -- Exit logic
                Imgui.closeCurrentPopup()
            end

            Imgui.endPopup()
        end

        Imgui.spacing()
        Imgui.separator()
        Imgui.spacing()

        -- Footer with button to close the dialog
        if (Imgui.button("Close Dialog", 120, 30)) then
            -- Close dialog logic
        end

        Imgui.endDialog()
    end
end

return PopupController
Item state example
Accesing item states.
local Imgui = require 'engine/imgui'
local ItemStateController = Class.new(Behaviour)

    function ItemStateController:init()
        -- State tracking for persistent UI behaviors
        self.showExtraInfo = {}      -- Track which nodes should show extra info
        self.clickCounter = {}       -- Track click counts for items
        self.hoveredItems = {}       -- Track which items were hovered last frame
    end

function ItemStateController:rendergui()
    Imgui.beginDialog("Item State Functions Example")

    Imgui.text("This example demonstrates various item state functions:")
    Imgui.spacing()
    Imgui.text("- isItemHovered(): Detects when mouse is over an item")
    Imgui.text("- isItemClicked(): Detects when an item is clicked")
    Imgui.text("- isItemToggledOpen(): Detects when an item is freshly opened")
    Imgui.spacing()
    Imgui.separator()
    Imgui.spacing()

    -- SECTION 1: isItemHovered example
    Imgui.text("1. isItemHovered() Example:")
    Imgui.spacing()

    -- Button that changes appearance when hovered
    if Imgui.button("Hover over me", 150, 30) then
        -- Button action
    end

    -- Check if the button is being hovered
    if Imgui.isItemHovered() then
        Imgui.text("Button is currently being hovered!")
        -- Track this item as hovered for next frame
        self.hoveredItems["hover_button"] = true
    else
        if self.hoveredItems["hover_button"] then
            Imgui.text("Button was previously hovered")
        else
            Imgui.text("Button has not been hovered yet")
        end
    end

    Imgui.spacing()
    Imgui.separator()
    Imgui.spacing()

    -- SECTION 2: isItemClicked example
    Imgui.text("2. isItemClicked() Example:")
    Imgui.spacing()

    -- Initialize click counter if not exists
    if self.clickCounter["click_button"] == nil then
        self.clickCounter["click_button"] = 0
    end

    -- Button that counts clicks
    if Imgui.button("Click me", 150, 30) then
        -- Button action happens here (standard button behavior)
    end

    -- Check if the button was clicked this frame
    if Imgui.isItemClicked() then
        self.clickCounter["click_button"] = self.clickCounter["click_button"] + 1
    end

    -- Display click count (persistent across frames)
    Imgui.text("Button has been clicked " .. self.clickCounter["click_button"] .. " times")

    Imgui.spacing()
    Imgui.separator()
    Imgui.spacing()

    -- SECTION 3: isItemToggledOpen example with persistent state
    Imgui.text("3. isItemToggledOpen() Example:")
    Imgui.spacing()

    -- Tree node 1: Basic example that toggles persistent visibility
    local nodeId = "info_node"
    local isOpen = Imgui.treeNode("Click to toggle extra information")

    -- When node is first opened, update our persistent visibility state
    if isOpen and Imgui.isItemToggledOpen() then
        -- Toggle the visibility state when opened
        self.showExtraInfo[nodeId] = not self.showExtraInfo[nodeId]
    end

    if isOpen then
        -- Show basic content always visible when open
        Imgui.text("Basic information (always visible)")

        -- Show extra information if toggled on (persists across opening/closing)
        if self.showExtraInfo[nodeId] then
            Imgui.spacing()
            Imgui.text("EXTRA INFORMATION PANEL:")
            Imgui.text("This panel remains visible until you toggle it off")
            Imgui.text("by opening the tree node again.")

            -- Add a button to manually hide extra info
            if Imgui.button("Hide Extra Info", 150, 30) then
                self.showExtraInfo[nodeId] = false
            end
        else
            Imgui.spacing()
            Imgui.text("Extra information is currently hidden.")
            Imgui.text("Open and close this node to toggle visibility.")
        end

        Imgui.treePop()
    end

    -- Tree node 2: Combines all three behaviors
    Imgui.spacing()
    local nodeId2 = "combined_node"

    -- Initialize click counter if not exists
    if self.clickCounter[nodeId2] == nil then
        self.clickCounter[nodeId2] = 0
    end

    local isOpen2 = Imgui.treeNode("Combined example (hover, click, toggle)")

    -- Check if node was clicked (must be done immediately after creating the tree node)
    if Imgui.isItemClicked() then
        self.clickCounter[nodeId2] = self.clickCounter[nodeId2] + 1
    end

    -- Check if node is being hovered
    local isHovered = Imgui.isItemHovered()

    -- Check if node was just opened
    local wasJustToggled = Imgui.isItemToggledOpen()

    if isOpen2 then
        -- First check if this node was just opened
        if wasJustToggled then
            Imgui.text("Node was just opened!")
        end

        -- Show if the node is being hovered
        if isHovered then
            Imgui.text("Node is being hovered right now")
        end

        -- Show how many times this node has been clicked
        Imgui.text("This node has been clicked " .. self.clickCounter[nodeId2] .. " times")

        Imgui.treePop()
    end

    Imgui.endDialog()
end

    return ItemStateController