ImGi entire API uses static functions and attributes
BasicImGi.Beginvoid ImGi.Begin()
Call only once per frame and make sure to call End() after.
ImGi.Endvoid ImGi.End()
Call only once per frame, after Begin() is called.
Layout SystemImGi uses a row based layout system. Each row can have a number of columns (up to 16 columns), each with it's own width, and also a height.
Controls then will be placed in this cell. If you don't change how rows are, it's assumed to keep same LayoutRow.
If you don't specify a height, it will use your style size and padding. Places elements relative to the bottom. Controls may make height bigger than what you set.
If your column width is 0, it will your style size and padding. A negative width will try to place that element at that distance relative from the rights.
Some special Controls can force the width of it's specific column, ignoring the positive values you set, this can be useful if you don't know before hand their sizes.
ImGi.LayoutRow1ImGi.LayoutRow2ImGi.LayoutRow3ImGi.LayoutRow4void ImGi.LayoutRow1(int width, int height = 0)
void ImGi.LayoutRow2(int w1, int w2, int height = 0)
void ImGi.LayoutRow3(int w1, int w2, int w3, int height = 0)
void ImGi.LayoutRow4(int w1, int w2, int w3, int w4, int height = 0)
Functions to configure the next LayoutRow to use, from a single column (LayoutRow1) up to four columns (LayoutRow4). Use these if you know you want either of these number of columns.
You can optionally specify a height.
ImGi.LayoutRowvoid ImGi.LayoutRow(int count, int widths[], int height = 0)
Pass an array of widths with count elements to configure the columns in a row. You can optionally specify a height.
This is useful if you are reading an array of things or have 5 or more columns in your layout. The maximum number of widths is 16.
int row[];
row = new int[2];
row[0] = 60; // set a predefined column width size per element in row
row[1] = 70; // this is the width of other column
ImGi.LayoutRow(2 /*n columns*/, row); // rows after this line have such column config
ImGi.LayoutBeginColumnImGi.LayoutEndColumnvoid ImGi.LayoutBeginColumn()
void ImGi.LayoutEndColumn()
Allows subdividing a cell in a row in more rows and columns. You start the column with ImGi.LayoutBeginColumn(), and it's void, so ALWAYS call LayoutEndColumn() after (you don't check it's return value because it's void!).
WindowA window can be created by a
BeginWindow and if this is successful (returns any non false value), it has to call
EndWindow to specify where it logically ends.
All controls must exist within a window. An example of normal usage is below:
if(ImGi.BeginWindow("My First Window!", 32, 32, 130, 60))
{
ImGi.Text("Hi!"); // your controls are here ...
ImGi.EndWindow();
}
ImGi.BeginWindowImGi_Res ImGi.BeginWindow(String title, int x, int y, int width, int height, ImGi_Opt opt = 0)
Creates a window, make sure to call a matching EndWindow() if this method return is not false.
ImGi.EndWindowvoid ImGi.EndWindow()
Has to be called each time a BeginWindow is successful once all elements inside the window are listed
ImGi.OpenWindowvoid ImGi.OpenWindow(String title)
If a window of matching title is closed, it opens again.
ImGi.Closevoid ImGi.Close()
Closes what is the current scope (Window, Popup, ...). Don't call it outside of a Window, a Popup, ...
ImGi.BeginPopupImGi.EndPopupImGi.OpenPopupImGi_Res ImGi.BeginPopup(String title)
void ImGi.EndPopup()
void OpenPopup(String name)
Popups are like windows, but you can't move or resize them, and they have no headers. They open where the mouse is when calling OpenPopup by default.
Popups open on top of everything, and they close if you click outside of them. Clicks outside of the popup that hit no window will be forwarded to the rest of your game to handle.
ImGi.BeginPanelImGi.EndPanelImGi_Res ImGi.BeginPanel(String name, ImGi_Opt opt = 0)
void ImGi.EndPanel()
If you need a scrollable area inside a window that is not the window itself, you can use panels! A panel has to be inside of a window, it will use the LayoutRow cell size for it's size. If it returns successful, you have to call EndPanel() after.
if(ImGi.BeginPanel("Pan")){
ImGi.Text("Hi panel!"); // your controls are here ...
ImGi.EndPanel();
}
ControlsControls are things you can place inside a window. Controls cannot exist outside of windows.
Every controls takes a string as label, this string can't be empty and can't match the label of other control. The exception is if the control can take an icon or graphic, then if you pass null as the string and the control has an icon, it will use the icon if possible. Each window or similar will be a new scope, used to compose this identification, so two different windows can have controls with matching labels.
ImGi comes with a limited number of icons, whenever you can provide an icon as a parameter, you can alternatively pass a sprite number, and in this case it will use that sprite instead of the icon. The default icons use negative numbers, so they don't conflict with your sprite ID.
ImGi.Emptyvoid ImGi.Empty()
This control does nothing and is invisible. Use it when you don't want to place anything in cell to advance the layout.
ImGi.Labelvoid ImGi.Label(String label)
(https://raw.githubusercontent.com/ericoporto/ImGi/main/docs/images/ctrl_label.gif)
This control is a Label containing the specified text. It has no interaction.
ImGi.Textvoid ImGi.Text(String text)
(https://raw.githubusercontent.com/ericoporto/ImGi/main/docs/images/ctrl_text.gif)
This control is a Multiline Label for visualization only. It has no interaction.
ImGi.TextBoxString ImGi.TextBox(String label, String buf, int bufsz, ImGi_Result* res = 0, ImGi_Opt opt = 0)
This control is an editable TextBox. Click on it to give focus and enter the text input with the keyboard. Enter exits focus.
The character limit is defined in
bufsz. This function will return the
buf String modified, just assign it to the same String so it's content can be updated.
ImGi.ButtonImGi_Res ImGi.Button(String label, ImGi_Icon icon = 0, ImGi_Opt opt = eImGi_Opt_AlignCenter)
(https://raw.githubusercontent.com/ericoporto/ImGi/main/docs/images/ctrl_button.gif)
This control is a Button. When clicked, it will return a value different than false.
ImGi.ButtonImageImGi_Res ImGi.ButtonImage(String label, int graphic_normal, int graphic_over, int graphic_pressed, ImGi_Opt opt = 0)
Pass a sprite for the Button normal state, one for when mouse is over, and a graphic for when it's clicked. You can set label null if it's the only button in the window with same graphics.
ImGi.CheckBoxImGi_Res ImGi.CheckBox(String label, CheckBoxState* chkst, ImGi_Icon icon = eImGi_Icon_Check)
(https://raw.githubusercontent.com/ericoporto/ImGi/main/docs/images/ctrl_checkbox.gif)
This control is a CheckBox. It doesn't store state, so make sure to pass it's state. You optionally pass a different icon to it.
ImGi.NumberImGi.NumberIImGi_Res ImGi.Number(String label, ImGi_Real* value, float step = 0, String format = 0, ImGi_Opt opt = 0)
ImGi_Res ImGi.NumberI(String label, ImGi_Int* value, int step = 0, String format = 0, ImGi_Opt opt = 0)
(https://raw.githubusercontent.com/ericoporto/ImGi/main/docs/images/ctrl_number.gif)
This control shows a Number, set step to allow quick mouse drag adjustments. Holding shift and clicking it allows entering input with the keyboard.
You can pass a format string similar to the one used with String.Format to specify how the number should be rendered. It's a float, so make sure to use either
"%f" or
"%g".
NumberI is the same control but for integer (
int) numbers, it's not the same control just wrapped, so it's format string default is
"%d".
ImGi.SliderImGi.SliderIImGi_Res ImGi.Slider(String label, ImGi_Real* value, float low, float high, float step = 0, String format = 0, ImGi_Opt opt = 0)
ImGi_Res ImGi.SliderI(String label, ImGi_Int* value, int low, int high, int step = 0, String format = 0, ImGi_Opt opt = 0)
(https://raw.githubusercontent.com/ericoporto/ImGi/main/docs/images/ctrl_slider.gif)
This control is a Slider. You can adjust it manually with the mouse or you can hold shift and click to specify a value with the keyboard.
You can pass a format string similar to the one used with String.Format to specify how the number should be rendered. It's a float, so make sure to use either
"%f" or
"%g".
SliderI is the same control but for integer (
int) numbers, it's not the same control just wrapped, so it's format string default is
"%d".
OptionsSome controls and other elements can take options. Below is the list of available options. If you wish to pass two or more options, you can combine them with the bitfield or operator |
ImGi.Button("centered text and non-interactive",0, eImGi_Opt_AlignCenter | eImGi_Opt_NoInteract)
eImGi_Opt_AlignCenter | The header of a window or the control will have text aligned to center. |
eImGi_Opt_AlignRight | The header of a window or the control will have text aligned to right. |
eImGi_Opt_NoInteract | Disables interaction with the control. |
eImGi_Opt_NoFrame | If the control or window has any frame, it's not drawn. |
eImGi_Opt_NoResize | You can't resize the window by click-dragging it's bottom right corner. |
eImGi_Opt_NoScroll | Window has no scrollbars. |
eImGi_Opt_NoClose | Window has no close button. |
eImGi_Opt_NoTitle | Window has to title bar. |
eImGi_Opt_HoldFocus | Controls with this option will require clicking on a different control to remove focus. Default of some controls. |
eImGi_Opt_AutoSize | Makes the window resize to fit content. |
eImGi_Opt_PopUp | Closes the container when clicking out of it. This is used by default in Popus. |
eImGi_Opt_Closed | Makes the container start closed by default. |
eImGi_Opt_Expanded | These are for tree elements, which are not implemented yet. |
UtilitiesImGi.SetFocusLastControlvoid ImGi.SetFocusLastControl()
Places the focus on what is the last control. Some controls behave differently when focused - like Number and TextBox. Focus is only reggarding input, but won't scroll or move things at center.
Style and Design customizationImGi.StyleImGi_Style* ImGi.Style
Holds the Current Style for ImGi.