This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine.Gui Class

Creates a GUI. Different types of GUI widgets can be either added to one of the following:

  • To the system GUI (Unigine user interface) that is rendered on top of application window.
  • To the GUI object positioned in the world. In this case, any postprocessing filter can be applied.
Default values returned by the following methods can be overridden via RC files defining a custom GUI.

Gui Class

Enums

CALLBACK_INDEX#

NameDescription
SHOW = 0Callback is used when a widget is shown. Supported by all widgets.
HIDE = 1Callback is used when a widget is removed via Gui::removeChild(). Supported by all widgets.
FOCUS_IN = 2Callback is used when a widget is focused. Supported by all widgets.
FOCUS_OUT = 3Callback is used when a widget loses focus. Supported by all widgets.
CHANGED = 4Callback is used when a widget has changed its state. Supported by the following widgets:
CLICKED = 5Callback is used when the mouse is clicked somewhere on a widget. Supported by the following widgets:
DOUBLE_CLICKED = 6Callback is used when the mouse is double-clicked somewhere on a widget. Supported by the following widgets:
PRESSED = 7Callback is used when a mouse button or ENTER (RETURN) is pressed, while the mouse pointer is somewhere on a widget. Supported by the following widgets:
RELEASED = 8Callback is used when the mouse was released after clicking somewhere on a widget. Supported by the following widgets:
KEY_PRESSED = 9Callback us used when a key (by scan code) is pressed while a widget is in focus. Supported by the following widgets:

Scan code - is a code assigned to avery key on the keyboard. Keyboard drivers use scan codes to detect which key is pressed. Scan codes are assigned to leys on the hardware level and are not affected by the states of modifiers like Caps Lock, Num Lock, Scroll Lock, Shift, Alt, and Ctrl making it possible to implement identical control on different types of keyboards (QWERTY, AZERTY, QWERTC, etc.). Scan codes are used when only a physical position of a key (a button) is important (e.g. in the ControlsApp class or Console key.

TEXT_PRESSED = 10Callback us used when a virtual key is pressed while a widget is in focus. Supported by the following widgets:

Virtual key - is a value to which a scan code was converted by an Operating System (e.g., the Q scan code will have the Q virtual key on a QWERTY-keyboard, while on an AZERTY-keyboard it will have the A virtual key; or NUMPAD_DIGIT_7 scan code can be translated into virtual NUMPAD_HOME or NUMPAD_DIGIT_7 depending on the current Num Lock state. Virtual keys are used, when it is important to know what exactly did user type (not just the physical button, but rather a letter).

ENTER = 11Callback is used when the mouse pointer enters a widget. Supported by all widgets.
LEAVE = 12Callback is used when the mouse pointer leaves a widget. Supported by all widgets.
DRAG_MOVE = 13Callback is used when a focused widget is moved.
DRAG_DROP = 14Callback is used when a drag-and-drop operation is performed with a widget. Supported by all widgets. A callback can receive dragged widgets inside additional arguments. Clicked or pressed callbacks receive a mouse button or a key inside an additional callback argument.
REMOVE = 15Callback is used when a widget is removed.
NUM_CALLBACKS = 16Number of GUI callbacks.

Properties

int NumChildren#

The number of widgets in the GUI.

int MouseGrab#

The value indicating if the mouse pointer is bound to the GUI.

int MouseCursor#

The mouse cursor value, one of the CURSOR_* pre-defined variables.

WidgetSprite MouseSprite#

The custom mouse pointer currently in use.

bool MouseEnabled#

The value indicating if the mouse cursor is rendered.

float ToolTipTime#

The delay before tooltip appearing.

float ToolTipAlpha#

The alpha value of a tooltip.

vec4 ToolTipColor#

The font color of a tooltip.

int ToolTipWidth#

The current width of the tooltip.

int ToolTipSize#

The font size of a tooltip.

bool ToolTipEnabled#

The value indicating if tooltips are available or not.

float TransparentAlpha#

The alpha value of a transparent widget. a widget is transparent, if it uses blending.

vec4 TransparentColor#

The font color of a transparent widget. a widget is transparent, if it uses blending.

bool TransparentEnabled#

The value indicating if a widget can be rendered as transparent (i.e. change its color accordingly), when necessary. For example, it can indicate whether the drop-down list of combobox is transparent or not.

float DisabledAlpha#

The alpha value of a disabled widget.

vec4 DisabledColor#

The font color of a disabled widget.

bool DisabledEnabled#

The value indicating if a widget can be rendered as disabled (i.e. change its color accordingly), when necessary.

float FocusedAlpha#

The alpha value of a focused widget.

vec4 FocusedColor#

The font color of a focused widget.

bool FocusedPermanent#

The value indicating if the permanent color of the focused widget is changed.

bool FocusedEnabled#

The value indicating if a widget can be rendered as focused on (i.e. change its color accordingly), when necessary.

float DefaultAlpha#

The standard alpha value of a widget.

vec4 DefaultColor#

The standard font color of a widget.

int DefaultSize#

The standard font size of a widget.

float FadeOutSpeed#

The duration of fade-out animation played when a widget loses focus.

float FadeInSpeed#

The duration of fade-in animation played when a widget gets focused.

float ExposeSpeed#

The duration of animation played when a widget appears.

mat4 Transform#

The GUI transformation matrix.

vec4 Color#

The color of the global color multiplier.

int Height#

The current screen height.

int Width#

The current screen width.

bool Hidden#

The value indicating if a widget is rendered visible.

bool Enabled#

The value indicating if the GUI is enabled.

bool IsActive#

The value indicating if any widget in the GUI is in focus.

WidgetVBox VBox#

The root widget of the GUI.

Widget PermanentFocus#

The value indicating if the widget is always in focus.

Widget OverlappedFocus#

The value indicating if the widget placed under the currently focused widget.

Widget Focus#

The value indicating if the widget is currently in focus.

int MouseDY#

The difference between the previous position of the mouse pointer and the current one along the y axis.

int MouseDX#

The difference between the previous position of the mouse pointer and the current one along the x axis.

int MouseY#

The current y coordinate of the mouse pointer in the coordinate system of the application window.

int MouseX#

The current x coordinate of the mouse pointer in the coordinate system of the application window.

int ToolTipY#

The GUI tooltip Y position.

int ToolTipX#

The GUI tooltip X position.

string ToolTipText#

The GUI tooltip text.

bool IsUnderCursor#

The true if the GUI object is under cursor; otherwise, false.

int MouseWheelHorizontal#

The horizontal mouse scroll value in the [-1;1] range.

int MouseWheel#

The mouse scroll value in the [-1;1] range.

bool MouseShow#

The value indicating if the OS mouse pointer is displayed.

int MouseButtons#

The mouse buttons the input of which is received.

bool WorldObject#

The value indicating if the GUI object is available in the hierarchy and rendered as a world object.

ulong WinHandle#

The window handle.

ivec2 Position#

The GUI object position.

ivec2 Size#

The GUI object size (width and height).

Members


Gui GetCurrent ( ) #

Returns the current GUI instance.

Return value

Current GUI instance.

Widget GetChild ( int num ) #

Returns a child widget with a given number.

Arguments

  • int num - Widget number.

Return value

Child widget.

int IsChild ( Widget widget ) #

Checks if a given widget belongs to the GUI.

Arguments

  • Widget widget - Widget to check.

Return value

true if the widget belongs to the GUI; otherwise, false.

int SetFont ( string name ) #

Changes the font used in the system GUI.

Arguments

  • string name - Path to the font file.

Return value

1 if the font is successfully changed; otherwise, 0.

int GetKeyActivity ( uint key ) #

Checks if a given key already has a special purpose for the widget in focus.

Arguments

  • uint key - One of the standard ASCII control codes or one of the KEY_* pre-defined variables.

Return value

1 if the key cannot be used; otherwise, 0.

int SetResource ( string name ) #

Changes the resource skin file used in the system GUI.

Arguments

  • string name - Path to the *.rc file.

Return value

1 if the resource file is successfully changed; otherwise, 0.

int SetSkin ( string name ) #

Changes the GUI skin used in the system GUI.

Arguments

  • string name - Path to the directory where the skin files are stored (an RC file and textures).

Return value

1 if the skin is successfully changed; otherwise, 0.

void SetToolTip ( int x, int y, string str ) #

Sets a tooltip.

Arguments

  • int x - Screen position along the X axis.
  • int y - Screen position along the Y axis.
  • string str - Tooltip to display.

int GetToolTipHeight ( string str ) #

Returns a height of the given tooltip.
Notice
Height of a single-line tooltip is equal to 21 pixels.

Arguments

  • string str - A tooltip text.

Return value

Height of the given tooltip (in pixels).

int GetToolTipWidth ( string str ) #

Returns the current width of the tooltip.

Arguments

  • string str - A tooltip text.

Return value

Width of the tooltip.

void AddChild ( Widget widget, int flags = 0 ) #

Adds a given widget to the GUI.

Arguments

  • Widget widget - Widget to add.
  • int flags - One of the GUI_ALIGN_* pre-defined variables. This is an optional parameter.

int AddDictionary ( string name, string language = 0 ) #

Adds a new dictionary with localized interface strings. Dictionaries cannot be modified in run-time.

Arguments

  • string name - Path to the dictionary file.
  • string language - Name of the dictionary language.

Return value

Returns 1 if the dictionary is added successfully; otherwise, 0.

void ClearDictionaries ( ) #

Clears all dictionaries.

int ClearTexture ( string name ) #

Clears the specified GUI texture file cache.

Arguments

  • string name - Name of the texture.

Return value

1 if the texture is successfully cleared; otherwise, 0.

Gui create ( string name = 0 ) #

GUI constructor.

Arguments

  • string name - GUI skin name.

Return value

Pointer to the created GUI.

void Destroy ( ) #

Destroys all GUI resources.

void Disable ( ) #

Disables GUI rendering.

void Enable ( ) #

Enables GUI rendering.

int HasTranslation ( string arg1 ) #

Returns a value indicating if there is translation for a given string in the localization dictionary.

Arguments

  • string arg1 - String to check.

Return value

1 if there is translation for the given string; otherwise, 0.

vec4 ParseColor ( string str ) #

Converts a color string in the Web format (RRGGBB / #RRGGBB or RRGGBBAA / #RRGGBBAA) into its vec4 equivalent.

Arguments

  • string str - Color string in the Web format.

Return value

Color value as a vec4 vector (R, G, B, A).

void RemoveChild ( Widget widget ) #

Removes the specified widget from the GUI.

Arguments

  • Widget widget - Child widget to be removed.

void RemoveFocus ( ) #

Removes focus from the GUI.

void Render ( ) #

Renders the GUI.

void Render ( int custom_mouse_buttons ) #

Renders the GUI.

Arguments

  • int custom_mouse_buttons - Pressed mouse button.

void ReplaceChild ( Widget widget, Widget old_widget, int flags = 0 ) #

Replaces a given widget in the GUI with another widget.

Arguments

  • Widget widget - Replacement widget.
  • Widget old_widget - Widget to be replaced.
  • int flags - One of the GUI_ALIGN_* pre-defined variables. This is an optional parameter.

int SaveDictionary ( string name, string language = 0 ) #

Saves the current dictionary on disk. This function can be used to save the currently loaded dictionary into another file.

Arguments

  • string name - Path to a dictionary file.
  • string language - Name of the dictionary language.

Return value

1 if the dictionary is saved successfully; otherwise, 0.

string Translate ( string str ) #

Returns the source string translated using the dictionary.

Arguments

  • string str - String to translate (source).

Return value

Target (translated) string if it is found in the localization dictionary; otherwise, the source string.

void Update ( ) #

Updates GUI.

void UpdateHierarchy ( ) #

Updates the hierarchy for all widgets — the widgets are arranged, expanded to the required sizes and then their positions are updated. Updating the hierarchy may be required, for example, for getting the screen position immediately after the widget has been added to the hierarchy.

bool IsRenderingBootScreen ( ) #

Returns a value indicating if the GUI currently renders the boot screen.

Return value

true if the GUI currently renders the boot screen; otherwise, false.

bool IsRenderingSplashScreen ( ) #

Returns a value indicating if the GUI currently renders the splash screen.

Return value

true if the GUI currently renders the splash screen; otherwise, false.

bool IsRenderingLoadingScreen ( ) #

Returns a value indicating if the GUI currently renders the loading screen.

Return value

true if the GUI currently renders the loading screen; otherwise, false.

void FocusGained ( ) #

The focus is set on the GUI object.

void FocusLost ( ) #

The focus is removed from the GUI.

bool IsHover ( int global_pos_x, int global_pos_y ) #

Returns a value indicating if the cursor is hovering over the GUI object.

Arguments

  • int global_pos_x - The X coordinate of the cursor in global coordinates.
  • int global_pos_y - The Y coordinate of the cursor in global coordinates.

Return value

true if the cursor is hovering over the GUI object; otherwise, false.

Widget GetWidgetIntersection ( int global_pos_x, int global_pos_y ) #

Returns the intersected widget that is visually perceptible (not empty, not transparent).

Arguments

Return value

The intersected widget that is visually perceptible.

Widget GetUnderCursorWidget ( ) #

Returns the visually perceptible widget, over which the cursor is currently hovering.

Return value

The widget, over which the cursor is currently hovering.

Gui GetFocusGui ( ) #

Returns the GUI object that is currently in focus.

Return value

The GUI object currently in focus.

Gui GetGuiIntersection ( int global_pos_x, int global_pos_y ) #

Returns the intersected GUI object.
Notice
This method takes Z-ordering into consideration: if the GUI object is overlapped by any other window, the method returns null.

Arguments

  • int global_pos_x - The X coordinate of the intersection point in global coordinates.
  • int global_pos_y - The Y coordinate of the intersection point in global coordinates.

Return value

The intersected GUI object.

Gui GetUnderCursorGui ( ) #

Returns the GUI object that is currently under cursor.
Notice
If case of dragging or resizing a window, this method returns null. To receive the intersected GUI in such a case, use getGuiIntersection().

Return value

GUI object currently under cursor.

void GetWorldGuiInstances ( Gui[] ret_instances ) #

Returns all GUI instances that are available in the scene hierarchy and rendered as world objects.

Arguments

  • Gui[] ret_instances - All GUI instances that are available in the scene hierarchy and rendered as world objects.

int GetAndClearMouseWheel ( ) #

Returns the mouse scroll value and clears the mouse scroll state info.

Return value

The mouse scroll value in the [-1;1] range.

void ForceSetMouseWheel ( int value ) #

Sets the mouse scroll value.

Arguments

  • int value - The mouse scroll value in the [-1;1] range.

int GetMouseWheelHorizontal ( ) #

Returns the current horizontal mouse scroll value.

Return value

The horizontal mouse scroll value in the [-1;1] range.

int GetAndClearMouseWheelHorizontal ( ) #

Returns the mouse horizontal scroll value and clears the mouse scroll state info.

Return value

The horizontal mouse scroll value in the [-1;1] range.

void ForceSetMouseWheelHorizontal ( int value ) #

Sets the mouse vertical scroll value.

Arguments

  • int value - The horizontal mouse scroll value in the [-1;1] range.

bool GetKey ( Input.KEY key ) #

Returns the value indicating if the specified key is pressed.

Arguments

  • Input.KEY key - One of the standard ASCII control codes or one of the KEY_* pre-defined variables.

Return value

true if the key is pressed; otherwise, false.

bool GetAndClearKey ( Input.KEY key ) #

Returns the value indicating if the specified key is pressed and clears the key state info.

Arguments

  • Input.KEY key - One of the standard ASCII control codes or one of the KEY_* pre-defined variables.

Return value

true if the key is pressed; otherwise, false.
Last update: 2023-02-17
Build: ()