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.
Gui Class
Enums
CALLBACK_INDEX#
Name | Description |
---|---|
SHOW = 0 | Callback is used when a widget is shown. Supported by all widgets. |
HIDE = 1 | Callback is used when a widget is removed via Gui::removeChild(). Supported by all widgets. |
FOCUS_IN = 2 | Callback is used when a widget is focused. Supported by all widgets. |
FOCUS_OUT = 3 | Callback is used when a widget loses focus. Supported by all widgets. |
CHANGED = 4 | Callback is used when a widget has changed its state. Supported by the following widgets:
|
CLICKED = 5 | Callback is used when the mouse is clicked somewhere on a widget. Supported by the following widgets:
|
DOUBLE_CLICKED = 6 | Callback is used when the mouse is double-clicked somewhere on a widget. Supported by the following widgets: |
PRESSED = 7 | Callback 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 = 8 | Callback is used when the mouse was released after clicking somewhere on a widget. Supported by the following widgets: |
KEY_PRESSED = 9 | Callback 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 = 10 | Callback 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 = 11 | Callback is used when the mouse pointer enters a widget. Supported by all widgets. |
LEAVE = 12 | Callback is used when the mouse pointer leaves a widget. Supported by all widgets. |
DRAG_MOVE = 13 | Callback is used when a focused widget is moved. |
DRAG_DROP = 14 | Callback 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 = 15 | Callback is used when a widget is removed. |
NUM_CALLBACKS = 16 | Number of GUI callbacks. |
Properties
int NumChildren#
int MouseGrab#
int MouseCursor#
WidgetSprite MouseSprite#
bool MouseEnabled#
float ToolTipTime#
float ToolTipAlpha#
vec4 ToolTipColor#
int ToolTipWidth#
int ToolTipSize#
bool ToolTipEnabled#
float TransparentAlpha#
vec4 TransparentColor#
bool TransparentEnabled#
float DisabledAlpha#
vec4 DisabledColor#
bool DisabledEnabled#
float FocusedAlpha#
vec4 FocusedColor#
bool FocusedPermanent#
bool FocusedEnabled#
float DefaultAlpha#
vec4 DefaultColor#
int DefaultSize#
float FadeOutSpeed#
float FadeInSpeed#
float ExposeSpeed#
mat4 Transform#
vec4 Color#
int Height#
int Width#
bool Hidden#
bool Enabled#
bool IsActive#
WidgetVBox VBox#
Widget PermanentFocus#
Widget OverlappedFocus#
Widget Focus#
int MouseDY#
int MouseDX#
int MouseY#
int MouseX#
int ToolTipY#
int ToolTipX#
string ToolTipText#
bool IsUnderCursor#
int MouseWheelHorizontal#
int MouseWheel#
bool MouseShow#
int MouseButtons#
bool WorldObject#
ulong WinHandle#
ivec2 Position#
ivec2 Size#
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.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.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
- 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
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.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.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.