Files
cell/docs/api/modules/imgui.md
John Alanbrook 96ef8ccba3
Some checks failed
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Add camera and debug modules
2025-02-21 17:15:58 -06:00

1245 lines
23 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# imgui
### windowpos() <sub>function</sub>
Return the position of the current ImGui window as an ImVec2.
**Returns**: A 2-element array [x, y] representing the top-left corner of the current window in screen coordinates.
### plot2pixels(coords) <sub>function</sub>
Convert a point from plot coordinates to pixel coordinates in the current ImPlot.
**coords**: A 2-element array [x, y] in plot coordinates.
**Returns**: A 2-element array [x, y] in pixel coordinates, mapped from the current ImPlot.
### plotpos() <sub>function</sub>
Return the top-left corner of the current ImPlot region in screen (pixel) coordinates.
**Returns**: A 2-element array [x, y] representing the position of the current ImPlot in screen coordinates.
### plotlimits() <sub>function</sub>
Retrieve the current plots axis limits (min/max) for both X and Y axes.
**Returns**: An object { x: { min, max }, y: { min, max } } describing the current plots visible axis ranges.
### setaxes(xAxis, yAxis) <sub>function</sub>
Switch the active axes in ImPlot (useful if multiple axes exist).
**xAxis**: The x-axis index (0..2).
**yAxis**: The y-axis index (0..2).
**Returns**: None
### setupaxis(axis) <sub>function</sub>
Setup the specified axis in the current ImPlot (e.g., for customizing tick labels).
**axis**: The numeric index of the axis (0..2).
**Returns**: None
### inplot(coords) <sub>function</sub>
Check if the given point is within the current ImPlot's visible region.
**coords**: A 2-element array [x, y] in plot coordinates.
**Returns**: True if the point is within the visible plot region, otherwise false.
### window(title, callback) <sub>function</sub>
Create a new ImGui window with the given title and invoke the callback to render inside it.
**title**: The text displayed as the window title.
**callback**: A function called to render the contents of the window.
**Returns**: A boolean indicating if the window is still active (open) after rendering.
### menu(label, callback) <sub>function</sub>
Create a new menu entry in a menu bar or menu. The callback is invoked to populate the menu if opened.
**label**: The label of the menu (visible in the menubar).
**callback**: A function called to render menu items when the menu is open.
**Returns**: None
### sameline(offset) <sub>function</sub>
Place the next widget on the same line, optionally specifying a horizontal offset.
**offset**: A float offset from the current cursor position. If omitted, defaults to 0.
**Returns**: None
### int(label, value) <sub>function</sub>
Display an integer input box with a label.
**label**: The label text for the input.
**value**: The initial integer value.
**Returns**: The updated integer value after user edits.
### pushid(id) <sub>function</sub>
Push an integer ID onto the ImGui ID stack.
**id**: An integer used to differentiate widgets/items with the same label.
**Returns**: None
### popid() <sub>function</sub>
Pop an ID off the ImGui ID stack.
**Returns**: None
### slider(label, value, minValue, maxValue) <sub>function</sub>
Create a float slider (or multi-float sliders if given an array) within the specified range.
**label**: The slider label text.
**value**: A single float or an array of floats (e.g., [r,g,b,a]).
**minValue**: The minimum slider value.
**maxValue**: The maximum slider value.
**Returns**: The updated float or array of floats after user adjustment.
### intslider(label, value, minValue, maxValue) <sub>function</sub>
Create an integer slider (or multiple integer sliders if given a typed array) in the specified range.
**label**: The slider label text.
**value**: A single integer or a typed array of integers (for multi-component sliders).
**minValue**: The minimum integer value.
**maxValue**: The maximum integer value.
**Returns**: The updated integer or array of integers after user adjustment.
### menubar(callback) <sub>function</sub>
Begin rendering a menubar. The callback is invoked to create menu items. Ends automatically.
**callback**: A function that creates menu items within the menubar.
**Returns**: None
### mainmenubar(callback) <sub>function</sub>
Create the main menu bar at the top of the screen. The callback is invoked for populating it.
**callback**: A function to render items in the main menu bar.
**Returns**: None
### menuitem(label, shortcut, callback, selected) <sub>function</sub>
Create a menu item that can optionally be toggled. If selected, calls the provided callback.
**label**: The text label of the menu item.
**shortcut**: An optional shortcut text to display (e.g. "Ctrl+S").
**callback**: A function called if the user clicks or activates this item.
**selected**: A boolean indicating whether this menu item is toggled or not.
**Returns**: A boolean reflecting the toggled state.
### radio(label, active) <sub>function</sub>
Create a radio button.
**label**: The text label for the radio button.
**active**: Whether this radio button is currently selected.
**Returns**: True if this radio button is now selected by the user, otherwise false.
### image(texture) <sub>function</sub>
Render a texture as an image at a default size (100x100).
**texture**: The GPU texture to display.
**Returns**: None
### imagebutton(label, texture, callback) <sub>function</sub>
Create an ImageButton widget which displays a texture; calls the callback when clicked.
**label**: A string identifier (not visually used).
**texture**: The GPU texture to display on the button.
**callback**: A function called when the button is clicked.
**Returns**: None
### textinput(label, text) <sub>function</sub>
Show a single-line text input widget.
**label**: The label text next to the input box.
**text**: The current text. If undefined, the box starts empty.
**Returns**: The updated text string after user editing.
### textbox(label, text) <sub>function</sub>
Show a multi-line text input widget.
**label**: The label text next to the input box.
**text**: The current multi-line text. If undefined, starts empty.
**Returns**: The updated text after user editing.
### button(label, callback) <sub>function</sub>
Create a button. The callback fires if the user clicks it.
**label**: The text displayed on the button.
**callback**: The function called on click.
**Returns**: None
### checkbox(label, checked) <sub>function</sub>
Create a checkbox to toggle a boolean value.
**label**: The text label for the checkbox.
**checked**: The current boolean state.
**Returns**: The updated boolean state after user toggle.
### text(text) <sub>function</sub>
Render a line of text in the ImGui window.
**text**: The string to display.
**Returns**: None
### plot(title, callback) <sub>function</sub>
Begin a new ImPlot region with the specified title. Calls the callback to render plot contents.
**title**: The title (label) of the plot.
**callback**: A function that sets up and draws within the ImPlot region.
**Returns**: None
### lineplot(label, data, shaded, lastPoint) <sub>function</sub>
Plot a line graph in the current ImPlot.
**label**: The label for the line plot.
**data**: An array of [x,y] points or a single array of y-values.
**shaded**: Boolean indicating if the area under the line should be filled.
**lastPoint**: (Optional) Additional point or frame usage. (Currently partial/placeholder in code.)
**Returns**: None
### scatterplot(label, data, shaded, lastPoint) <sub>function</sub>
Plot a scatter graph in the current ImPlot.
**label**: The label for the scatter plot.
**data**: An array of [x,y] points or a single array of y-values.
**shaded**: Typically unused for scatter.
**lastPoint**: (Optional) Additional param if needed.
**Returns**: None
### stairplot(label, data, shaded, lastPoint) <sub>function</sub>
Plot a stair-step graph in the current ImPlot.
**label**: The label for the stair plot.
**data**: An array of [x,y] points or a single array of y-values.
**shaded**: A boolean to fill under the stair-step line.
**lastPoint**: (Optional) Extended data usage if needed.
**Returns**: None
### digitalplot(label, data, shaded, lastPoint) <sub>function</sub>
Plot a digital (step-like) graph in the current ImPlot.
**label**: The label for the digital plot.
**data**: An array of [x,y] points or a single array of y-values.
**shaded**: Typically not used for digital plots.
**lastPoint**: (Optional) Extended data usage if needed.
**Returns**: None
### barplot(label, data, width) <sub>function</sub>
Plot a bar chart in the current ImPlot.
**label**: The label for the bar series.
**data**: An array of [x,y] points or just an array of y-values.
**width**: The width of each bar in plot units.
**Returns**: None
### textplot(text, coords) <sub>function</sub>
Render text at the specified coordinates in plot space.
**text**: The string to render.
**coords**: A 2-element array [x, y] in plot coordinates.
**Returns**: None
### histogramplot(label, data) <sub>function</sub>
Plot a histogram from the given data array/typed array in the current ImPlot.
**label**: The label for the histogram.
**data**: A typed array (or numeric array) containing the values to bin/display.
**Returns**: None
### plotaxes(xLabel, yLabel) <sub>function</sub>
Set up labels for the X and Y axes of the current ImPlot.
**xLabel**: The label for the x-axis.
**yLabel**: The label for the y-axis.
**Returns**: None
### plotmousepos() <sub>function</sub>
Get the mouse cursors position in the current plots coordinate system.
**Returns**: A 2-element array [x, y] representing the mouse position in plot coordinates.
### plothovered() <sub>function</sub>
Check if the mouse is hovering over the current ImPlot.
**Returns**: True if the plot area is hovered, otherwise false.
### axeslimits(xMin, xMax, yMin, yMax) <sub>function</sub>
Set up the visible axis limits in the current ImPlot.
**xMin**: The left (min) bound of the x-axis.
**xMax**: The right (max) bound of the x-axis.
**yMin**: The bottom (min) bound of the y-axis.
**yMax**: The top (max) bound of the y-axis.
**Returns**: None
### prepend(commandBuffer) <sub>function</sub>
Prepare ImGui draw data for rendering, typically called after ImGui::Render().
**commandBuffer**: The SDL GPU command buffer where draw data will be queued.
**Returns**: None
### fitaxis(axis) <sub>function</sub>
Fit either the x-axis or y-axis to its data range on the next plot frame.
**axis**: 0 for X-axis, 1 for Y-axis.
**Returns**: None
### columns(count) <sub>function</sub>
Switch the layout to use a specified number of columns.
**count**: The number of columns to layout in the current region.
**Returns**: None
### nextcolumn() <sub>function</sub>
Advance to the next column in a multi-column layout.
**Returns**: None
### collapsingheader(label) <sub>function</sub>
Create a collapsible header. Returns true if it is open (expanded).
**label**: The text label of the header.
**Returns**: True if the header is expanded, otherwise false.
### tree(label, callback) <sub>function</sub>
Create a tree node. If opened, calls the callback for nested content.
**label**: The label for the tree node.
**callback**: A function called if the node is expanded.
**Returns**: None
### listbox(label, items, selectedIndex) <sub>function</sub>
Create a list box widget to select from a list of strings.
**label**: The label next to the list box.
**items**: An array of strings to display.
**selectedIndex**: The currently selected index.
**Returns**: The updated selected index after user selection.
### axisfmt(axis, callback) <sub>function</sub>
Set a custom formatter for a specified y-axis in ImPlot.
**axis**: The y-axis index (0..2) to format.
**callback**: A function(value) => string that converts axis values to text.
**Returns**: None
### tabbar(label, callback) <sub>function</sub>
Begin a tab bar container. The callback is invoked to create tabs.
**label**: The identifier label of the tab bar.
**callback**: A function that creates tab items.
**Returns**: None
### tab(label, callback) <sub>function</sub>
Create a tab item. If selected, calls the callback for tab content.
**label**: The name of the tab.
**callback**: A function to render the tabs content if active.
**Returns**: None
### open_popup(label) <sub>function</sub>
Open a popup by its identifier.
**label**: The identifier of the popup to open.
**Returns**: None
### modal(label, callback) <sub>function</sub>
Begin a modal popup. The callback is invoked to display contents if the modal is open.
**label**: The identifier of the modal popup.
**callback**: A function for rendering the modals UI if open.
**Returns**: None
### popup(label, callback) <sub>function</sub>
Begin a popup. The callback is invoked if the popup is open.
**label**: The identifier of the popup.
**callback**: A function for rendering the popups UI.
**Returns**: None
### close_popup() <sub>function</sub>
Close the current popup.
**Returns**: None
### context(label, callback) <sub>function</sub>
Create a popup context menu. The callback is invoked if the menu opens.
**label**: The identifier for the context menu.
**callback**: A function that renders menu items in the context.
**Returns**: None
### table(label, columns, callback, sortCallback) <sub>function</sub>
Create a table with multiple columns. Optionally enable sorting and pass a sort callback.
**label**: The identifier for the table.
**columns**: The number of columns.
**callback**: A function to populate the table (rows/cells).
**sortCallback**: An optional function(columnIndex, ascending) called if user sorts a column.
**Returns**: None
### tablenextcolumn() <sub>function</sub>
Move to the next column in a table row.
**Returns**: None
### tablenextrow() <sub>function</sub>
Move to the next row in a table.
**Returns**: None
### tableheadersrow() <sub>function</sub>
Create a row of headers in the current table (should be called once after column setup).
**Returns**: None
### tableangledheadersrow() <sub>function</sub>
Create an angled header row (for advanced usage). Typically not used as often.
**Returns**: None
### tablesetupcolumn(label) <sub>function</sub>
Setup configuration for a single column in the table.
**label**: The label/header text for this column.
**Returns**: None
### dnd(type, payload, callback) <sub>function</sub>
Begin a drag source for custom data payload.
**type**: A string identifier for the drag-drop payload type.
**payload**: A numeric payload stored in the drag-drop.
**callback**: (Currently unused) Placeholder if you want to do extra on drag start.
**Returns**: None
### dndtarget(type, callback) <sub>function</sub>
Create a drop target for matching drag-drop payload type. Invokes callback on drop.
**type**: A string identifier for the drag-drop payload type to accept.
**callback**: A function(payloadNumber) called when a matching payload is dropped.
**Returns**: None
### color(label, color) <sub>function</sub>
Create a color editor (3 or 4 floats). Returns the updated color.
**label**: The label for the color editor.
**color**: An array [r,g,b] or [r,g,b,a].
**Returns**: Updated color array after user input.
### startnode(callback, linkCreatedCallback, nodeHoveredCallback, linkHoveredCallback) <sub>function</sub>
Begin a node editor session with ImNodes. The callback defines nodes.
Additional callbacks handle link creation and hover events.
**callback**: A function to define node editor contents (adding nodes, etc).
**linkCreatedCallback**: A function(startAttr, endAttr) called when a new link is created.
**nodeHoveredCallback**: A function(nodeId) called when a node is hovered.
**linkHoveredCallback**: A function(linkId) called when a link is hovered.
**Returns**: None
### node(nodeId, callback) <sub>function</sub>
Begin a node with a unique ID, then call the callback to define its contents.
**nodeId**: A unique integer ID for this node.
**callback**: A function that populates the nodes UI.
**Returns**: None
### nodein(attributeId, callback) <sub>function</sub>
Create an input attribute in the current node.
**attributeId**: The attribute ID for this input.
**callback**: A function that defines the UI within the input attribute.
**Returns**: None
### nodeout(attributeId, callback) <sub>function</sub>
Create an output attribute in the current node.
**attributeId**: The attribute ID for this output.
**callback**: A function that defines the UI within the output attribute.
**Returns**: None
### nodelink(linkId, startAttributeId, endAttributeId) <sub>function</sub>
Link two node attributes by their IDs.
**linkId**: A unique integer ID for this link.
**startAttributeId**: The attribute ID where the link starts.
**endAttributeId**: The attribute ID where the link ends.
**Returns**: None
### nodemini(size) <sub>function</sub>
Show a minimap for the current node editor.
**size**: A float controlling the minimap size ratio.
**Returns**: None
### mousehoveringrect(min, max) <sub>function</sub>
Check if the mouse is hovering within the given rectangle.
**min**: A 2-element array [x, y] for the top-left corner.
**max**: A 2-element array [x, y] for the bottom-right corner.
**Returns**: True if the mouse is within that rectangle, otherwise false.
### mouseclicked(button) <sub>function</sub>
Check if a specific mouse button was clicked (went from up to down) this frame.
**button**: An integer for the mouse button index (0 = left, 1 = right, etc).
**Returns**: True if the button was clicked, otherwise false.
### mousedown(button) <sub>function</sub>
Check if the specified mouse button is currently held down.
**button**: The mouse button index.
**Returns**: True if the button is down, otherwise false.
### mousereleased(button) <sub>function</sub>
Check if the specified mouse button was released this frame.
**button**: The mouse button index.
**Returns**: True if the button was released, otherwise false.
### mousedragging(button) <sub>function</sub>
Check if the mouse is being dragged with the specified button.
**button**: The mouse button index.
**Returns**: True if the mouse is dragging, otherwise false.
### mousedelta() <sub>function</sub>
Get the mouse movement delta (difference) for the current frame.
**Returns**: A 2-element array [dx, dy] representing the mouse movement.
### rect(pMin, pMax, color) <sub>function</sub>
Draw a rectangle outline in the current windows draw list.
**pMin**: A 2-element array [x, y] for the top-left corner.
**pMax**: A 2-element array [x, y] for the bottom-right corner.
**color**: A 4-element array [r, g, b, a] specifying the outline color.
**Returns**: None
### rectfilled(pMin, pMax, color) <sub>function</sub>
Draw a filled rectangle in the current windows draw list.
**pMin**: [x, y] for the top-left corner.
**pMax**: [x, y] for the bottom-right corner.
**color**: [r, g, b, a] fill color.
**Returns**: None
### line(p1, p2, color) <sub>function</sub>
Draw a line between two points in the current windows draw list.
**p1**: [x, y] start position.
**p2**: [x, y] end position.
**color**: [r, g, b, a] line color.
**Returns**: None
### bezierquad(p1, p2, p3, color, thickness) <sub>function</sub>
Draw a quadratic bezier curve.
**p1**: [x, y] start point.
**p2**: [x, y] control point.
**p3**: [x, y] end point.
**color**: [r, g, b, a] color.
**thickness**: Line thickness.
**Returns**: None
### beziercubic(p1, p2, p3, p4, color, thickness) <sub>function</sub>
Draw a cubic bezier curve.
**p1**: [x, y] start point.
**p2**: [x, y] first control point.
**p3**: [x, y] second control point.
**p4**: [x, y] end point.
**color**: [r, g, b, a] color.
**thickness**: Line thickness.
**Returns**: None
### point(center, radius, color) <sub>function</sub>
Draw a filled circle (point) in the current windows draw list.
**center**: [x, y] center of the circle.
**radius**: The radius of the circle.
**color**: [r, g, b, a] fill color.
**Returns**: None
### drawtext(text, position, color) <sub>function</sub>
Draw text at the given screen position with a specified color.
**text**: The string to draw.
**position**: [x, y] in screen coordinates.
**color**: [r, g, b, a] text color.
**Returns**: None
### cursorscreenpos() <sub>function</sub>
Get the current ImGui cursor screen position.
**Returns**: A 2-element array [x, y] in screen coordinates.
### setcursorscreenpos(position) <sub>function</sub>
Set the ImGui cursor screen position.
**position**: A 2-element array [x, y] in screen coordinates.
**Returns**: None
### contentregionavail() <sub>function</sub>
Return the available space in the current windows content region.
**Returns**: A 2-element array [width, height] of available space.
### dummy(size) <sub>function</sub>
Add a dummy item (invisible) of the specified size to the layout.
**size**: A 2-element array [width, height].
**Returns**: None
### invisiblebutton(label, size) <sub>function</sub>
Create an invisible button that occupies a given size and can catch clicks.
**label**: The identifier for the button.
**size**: [width, height] specifying the button area.
**Returns**: None
### width(width) <sub>function</sub>
Set the width of the next item in the layout.
**width**: The width (in pixels) for the next item.
**Returns**: None
### setclipboard(text) <sub>function</sub>
Set the system clipboard text.
**text**: The string to put into the clipboard.
**Returns**: None
### newframe() <sub>function</sub>
Start a new ImGui frame. Should be called once per frame before rendering UI elements.
**Returns**: None
### endframe(commandBuffer, renderPass) <sub>function</sub>
Finalize and render the ImGui draw data to the specified command buffer and render pass.
**commandBuffer**: The SDL GPU command buffer to render into.
**renderPass**: The SDL GPU render pass used to draw ImGui data.
**Returns**: None
### wantmouse() <sub>function</sub>
Check if ImGui wants to capture the mouse (e.g., if a window or widget needs mouse events).
**Returns**: True if ImGui is capturing the mouse, otherwise false.
### wantkeys() <sub>function</sub>
Check if ImGui wants to capture the keyboard (e.g., if a text input is active).
**Returns**: True if ImGui is capturing the keyboard, otherwise false.
### init(gpuDevice, window) <sub>function</sub>
Initialize ImGui with SDL and SDL_gpu, creating the ImGui context and configuring it.
**gpuDevice**: The SDL_GPUDevice object.
**window**: The SDL_Window object to attach ImGui onto.
**Returns**: None
### render_menu(render) <sub>function</sub>
### prosperon_menu() <sub>function</sub>