This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Gui Class

Interface for GUI.

To use this class, include the UnigineGUI.h file.

Gui Class

Members


float getToolTipTime ()

Returns the delay before tooltip appearing.

Return value

Delay in cycles per second.

void setToolTipSize (int size)

Sets a font size for widgets.

Arguments

  • int size - Font size.

int getMouseCursor ()

One of the CURSOR_* pre-defined variables.

Return value

Returns the type of mouse pointer currently displayed.

Ptr<Widget> getPermanentFocus ()

Returns a widget that is always in focus.

Return value

Widget always in focus.

void setTransparentAlpha (float alpha)

Sets an alpha value for transparent widgets. A widget is transparent, if it uses blending. The default is 0.8 (translucent).

Arguments

  • float alpha - Alpha value. 0 means completely transparent.

int isTransparentEnabled ()

Returns a 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.

Return value

1 if the widget can be rendered as transparent; otherwise, 0.

Ptr<Gui> create (const char * name = 0)

GUI constructor.

Arguments

  • const char * name - GUI skin name.

Return value

Pointer to the created GUI.

int getToolTipHeight (const char * str)

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

Arguments

  • const char * str - A tooltip text.

Return value

Height of the given tooltip (in pixels).

float getFadeOutSpeed ()

Returns the duration of fade-out animation played when a widget loses focused.

Return value

Duration in cycles per second.

void setFadeOutSpeed (float speed)

Sets a duration of fade-out animation played when the widget loses focused.

Arguments

  • float speed - Duration in cycles per second, for example, 4 means that the duration is a 1/4 of a second.

void setMouseGrab (int grab)

Sets a value indicating if the mouse pointer is bound to the GUI.

Arguments

  • int grab - 1 if the mouse pointer cannot leave the GUI; otherwise, 0.

int isToolTipEnabled ()

Returns a value indicating if tooltips are available or not.

Return value

Return 1 if tooltips are enabled; otherwise, 0.

Math::vec4 getTransparentColor ()

Returns the font color of a transparent widget. A widget is transparent, if it uses blending.

Return value

Font color of a transparent widget.

void setToolTipEnabled (int enabled)

Sets a value indicating whether tooltips are available or not.

Arguments

  • int enabled - 1 to enable tooltips; otherwise, 0.

Math::mat4 getTransform ()

Returns GUI transformation matrix.

Return value

GUI transformation matrix.

Math::vec4 getDefaultColor ()

Returns the standard font color of a widget.

Return value

Font color.

int isMouseEnabled ()

Returns a value indicating if the mouse cursor is rendered.

Return value

1 if the mouse is rendered; otherwise, 0.

void setExposeSpeed (float speed)

Sets a duration of animation played when the widget appears.

Arguments

  • float speed - Duration in cycles per second, for example, 6 means that the duration is a 1/6 of a second.

void setEnabled (int enabled)

Sets a value indicating if a widget should be enabled / disabled.

Arguments

  • int enabled - 1 to enable the GUI, 0 to disable it.

void setFocusedColor (const Math::vec4 & color)

Sets an font color for focused widgets. The default is equivalent to #ffffff (white).

Arguments

  • const Math::vec4 & color - Font color.

Ptr<Widget> getFocus ()

Returns the widget that is currently in focus.

Return value

Focused widget smart pointer.

int getMouseGrab ()

Returns a value indicating if the mouse pointer is bound to the GUI.

Return value

1 if the mouse pointer cannot leave the GUI; otherwise, 0.

int isFocusedPermanent ()

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

Return value

1 if the font color is overridden with the global GUI focused color; 0 if the font color is unchanged.

void update (float ifps)

Updates GUI.

Arguments

  • float ifps - Inverse FPS counter.

void setTransparentColor (const Math::vec4 & color)

Sets a font color for transparent widgets. A widget is transparent, if it uses blending. The default is equivalent to #869caa (light bluish).

Arguments

  • const Math::vec4 & color - Font color.

int getMouseY ()

Returns the current Y-coordinate of the mouse pointer in the coordinate system of the application window.

Return value

Y-coordinate of the mouse pointer.

Math::vec4 getColor ()

Returns the color of the global color multiplier.

Return value

Color multiplier.

void setColor (const Math::vec4 & color)

Sets a color for the global color multiplier. The default is equivalent to #ffffff (white).

Arguments

  • const Math::vec4 & color - Color multiplier.

int isChild (const Ptr<Widget> & widget)

Checks if a given widget is a child of the current GUI.

Arguments

  • const Ptr<Widget> & widget - Widget to check.

Return value

Returns 1 if the given widget is a child; otherwise, 0.

int setFont (const char * name)

Changes the font used in the system GUI.

Arguments

  • const char * name - Path to the font file.

Return value

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

int setResource (const char * name)

Changes the resource skin file used in the system GUI.

Arguments

  • const char * name - Path to the rc file.

Return value

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

void setDefaultColor (const Math::vec4 & color)

Sets a standard font color for widgets. The default is equivalent to #ddddff (blue-white).

Arguments

  • const Math::vec4 & color - Font color.

int hasTranslation (const char * arg1)

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

Arguments

  • const char * arg1 - String to check.

Return value

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

void setTransform (const Math::mat4 & transform)

Sets the global GUI transformation matrix. This 2D matrix can be tilted, rotated, moved or modified in many ways in 3D space.

Arguments

  • const Math::mat4 & transform - Transformation matrix.

void setFocusedPermanent (int permanent)

Changes the permanent color of the focused widget.

Arguments

  • int permanent - 1 - a font color is overridden with the global GUI focused color; 0 - a font color is unchanged.

void setToolTipColor (const Math::vec4 & color)

Sets a font color for tooltips. The default is equivalent to #000000 (black).

Arguments

  • const Math::vec4 & color - Font color.

int getToolTipX ()

Gets GUI ToolTip X position.

Return value

GUI ToolTip X position.

void setHidden (int hidden)

Sets a value indicating if a widget should not be rendered.

Arguments

  • int hidden - 1 to show the GUI, 0 to hide it.

int saveDictionary (const char * name, const char * language = 0)

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

Arguments

  • const char * name - Name of the dictionary language.
  • const char * language - Dictionary language name.

Return value

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

void render (int mouse_x, int mouse_y, int mouse_button, int mouse_show)

Renders GUI with specified parameters.

Arguments

  • int mouse_x - X mouse position.
  • int mouse_y - Y mouse position.
  • int mouse_button - Pressed mouse button.
  • int mouse_show - Show mouse cursor flag.

int getMouseButton ()

Returns the mouse button, which input is received.

Return value

APP_BUTTON_LEFT or APP_BUTTON_RIGHT or APP_BUTTON_MIDDLE.

void setDefaultSize (int size)

Sets a standard font size for widgets.

Arguments

  • int size - Font size.

void setFocusedAlpha (float alpha)

Sets an alpha value for focused widgets. The default is 1 (completely opaque).

Arguments

  • float alpha - Alpha value. 0 means completely transparent.

void setDisabledEnabled (int enabled)

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

Arguments

  • int enabled - Positive value if the widget can be rendered as disabled; otherwise, 0.

void setMouseEnabled (int enabled)

Enables or disables rendering of the mouse cursor.

Arguments

  • int enabled - 1 to enable the mouse, 0 to disable it.

int getDefaultSize ()

Returns the standard font size of a widget.

Return value

Font size.

int clearTexture (const char * name)

Clears the specified GUI texture file cache.

Arguments

  • const char * name - Texture name.

Return value

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

int getToolTipWidth (const char * str)

Returns the current width of the tooltip.

Arguments

  • const char * str - A tooltip text.

Return value

Width of the tooltip.

float getFadeInSpeed ()

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

Return value

Duration in cycles per second.

int addDictionary (const char * name, const char * language = 0)

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

Arguments

  • const char * name - Path to the dictionary file.
  • const char * language - Name of the dictionary language.

Return value

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

void setToolTipAlpha (float alpha)

Sets an alpha value for tooltips. The default is 0.95 (translucent).

Arguments

  • float alpha - Alpha value. 0 means completely transparent.

void setTransparentEnabled (int enabled)

Sets a value indicating if a widget can be rendered as transparent (i.e. change its color accordingly), when necessary. For example, this function allows to control whether the drop-down list of combobox is transparent or not.

Arguments

  • int enabled - Positive value if the widget can be rendered as transparent; otherwise, 0.

int getToolTipWidth ()

Returns the current width of the tooltip.

Return value

Width of the tooltip.

void setToolTipWidth (int width)

Sets the width for the tooltip.

Arguments

  • int width - New tooltip width.

void removeFocus ()

Removes focus from the GUI.

Math::vec4 parseColor (const char * str)

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

Arguments

  • const char * str - Color string in the Web format.

Return value

Color value in vec4.

int getKeyActivity (unsigned int key)

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

Arguments

  • unsigned int key - One of the standard ASCII control codes or one of the APP_KEY_* pre-defined variables.

Return value

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

Math::vec4 getFocusedColor ()

Returns the font color of a focused widget.

Return value

Font color.

float getToolTipAlpha ()

Returns the alpha value of a tooltip.

Return value

Alpha value.

int getMouseDY ()

Returns the difference between the previous position of the mouse pointer and the current one along the Y-axis.

Return value

Difference along the Y-axis.

void setDisabledAlpha (float alpha)

Sets an alpha value for disabled widgets.

Arguments

  • float alpha - Alpha value. 0 means completely transparent.

int getMouseX ()

Returns the current X-coordinate of the mouse pointer in the coordinate system of the application window.

Return value

X-coordinate of the mouse pointer.

Ptr<WidgetSprite> getMouseSprite ()

Returns the custom mouse pointer currently in use.

Return value

Sprite with a custom mouse pointer, or NULL if the standard mouse pointer is used.

void addChild (const Ptr<Widget> & widget, int flags = 0)

Adds a given widget to the GUI.

Arguments

  • const Ptr<Widget> & widget - Widget to add.
  • int flags - One of the ALIGN_* pre-defined variables. This is an optional parameter.

Ptr<Widget> getOverlappedFocus ()

Returns the widget placed under the currently focused widget.

Return value

Overlapped widget.

float getDefaultAlpha ()

Returns the standard alpha value of a widget.

Return value

Alpha value.

float getDisabledAlpha ()

Returns the alpha value of a disabled widget.

Return value

Alpha value.

const char * translate (const char * str)

Translates the string using dictionary.

Arguments

  • const char * str - String to translate.

Return value

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

void setToolTip (int x, int y, const char * str)

Sets a tooltip.

Arguments

  • int x - X coordinate of the tooltip position.
  • int y - Y coordinate of the tooltip position.
  • const char * str - ToolTip text.

float getFocusedAlpha ()

Returns the alpha value of a focused widget.

Return value

Alpha value.

void destroy ()

Destroys all GUI resources.

const char * getToolTipText ()

Gets GUI ToolTip text.

Return value

GUI ToolTip text.

int setSkin (const char * name)

Changes the GUI skin used in the system GUI.

Arguments

  • const char * name - Path to the skin file (an RC file and textures).

Return value

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

int getNumChildren ()

Returns the number of widgets in the GUI.

Return value

Number of widgets.

int getWidth ()

Returns the current screen width.

Return value

Screen width, in pixels.

int isDisabledEnabled ()

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

Return value

1 if the widget can be rendered as disabled; otherwise, 0.

int getToolTipY ()

Gets GUI ToolTip Y position.

Return value

GUI ToolTip Y position.

int getToolTipSize ()

Returns the font size of a tooltip.

Return value

Font size.

void setDefaultAlpha (float alpha)

Sets a standard alpha value for widgets.

Arguments

  • float alpha - Alpha value. 0 means completely transparent.

void enable (int width, int height)

Enables GUI rendering.

Arguments

  • int width - GUI width.
  • int height - GUI height.

float getExposeSpeed ()

Returns the duration of animation played when a widget appears.

Return value

Duration in cycles per second.

int getMouseDX ()

Returns the difference between the previous position of the mouse pointer and the current one along the X-axis.

Return value

Difference along the X-axis.

void setToolTipTime (float time)

Sets a delay before tooltip appearance.

Arguments

  • float time - Delay in cycles per second.

int isFocusedEnabled ()

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

Return value

1 if the widget can be rendered as focused on; otherwise, 0.

Math::vec4 getToolTipColor ()

Returns the font color of a tooltip.

Return value

Font color.

void removeChild (const Ptr<Widget> & widget)

Removes a child widget from the list of children.

Arguments

  • const Ptr<Widget> & widget - Child widget to be removed.

int getHeight ()

Returns the current screen height.

Return value

Screen height, in pixels.

void clearDictionaries ()

Clears all dictionaries.

void replaceChild (const Ptr<Widget> & widget, const Ptr<Widget> & old_widget, int flags = 0)

Replaces a given widget in the GUI with another widget.

Arguments

  • const Ptr<Widget> & widget - Replacement widget.
  • const Ptr<Widget> & old_widget - Widget to be replaced.
  • int flags - One of the ALIGN_* pre-defined variables. This is an optional parameter.

Ptr<Gui> get ()

Returns a pointer to the GUI.

Return value

Pointer to the GUI.

void setMouseSprite (const Ptr<WidgetSprite> & sprite)

Sets a custom mouse pointer.

Arguments

  • const Ptr<WidgetSprite> & sprite - Sprite with a custom mouse pointer, or NULL to fall back to the standard mouse pointer.

void setDisabledColor (const Math::vec4 & color)

Sets a font color for disabled widgets. The default is equivalent to #869caa (light bluish).

Arguments

  • const Math::vec4 & color - Font color.

float getTransparentAlpha ()

Returns the alpha value of a transparent widget. A widget is transparent, if it uses blending.

Return value

Alpha value.

void setMouseCursor (int cursor)

Sets a mouse pointer to display.

Arguments

  • int cursor - One of the CURSOR_* pre-defined variables.

void disable ()

Disables GUI rendering.

Math::vec4 getDisabledColor ()

Returns the font color of a disabled widget.

Return value

Font color.

void setFocusedEnabled (int enabled)

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

Arguments

  • int enabled - Positive value if the widget can be rendered as focused on; otherwise, 0.

int isEnabled ()

Returns a value indicating if the GUI is enabled.

Return value

Return 1 if the GUI is enabled; otherwise, 0 is returned.

int isHidden ()

Returns a value indicating if a widget is rendered visible.

Return value

1 if the widget is rendered; otherwise, 0.

int getActivity ()

Returns a value indicating if any widget in the GUI is in focus.

Return value

1 if any widget is focused; otherwise, 0.

void setMouseButton (int button)

Sets a mouse button, which input should be received.

Arguments

Ptr<Widget> getChild (int num)

Returns a child widget with a given number.

Arguments

  • int num - Child widget number.

Return value

Child widget.

void setFadeInSpeed (float speed)

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

Arguments

  • float speed - Duration in cycles per second, for example, 8 means that the duration is a 1/8 of a second.

int SHOW

Description

Callback is used when a widget is shown. Supported by all widgets.

int HIDE

Description

Callback is used when a widget is removed via Gui::removeChild(). Supported by all widgets.

int FOCUS_IN

Description

Callback is used when a widget is focused. Supported by all widgets.

int FOCUS_OUT

Description

Callback is used when a widget loses focus. Supported by all widgets.

int CHANGED

Description

Callback is used when a widget has changed its state. Supported by the following widgets:

int CLICKED

Description

Callback is used when the mouse is clicked somewhere on a widget. Supported by the following widgets:

int DOUBLE_CLICKED

Description

Callback is used when the mouse is double-clicked somewhere on a widget. Supported by the following widgets:

int PRESSED

Description

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:

int RELEASED

Description

Callback is used when the mouse was released after clicking somewhere on a widget.

int KEY_PRESSED

Description

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

int ENTER

Description

Callback is used when the mouse pointer enters a widget. Supported by all widgets.

int LEAVE

Description

Callback is used when the mouse pointer leaves a widget. Supported by all widgets.

int DRAG_MOVE

Description

Callback is used when a focused widget is moved.

int DRAG_DROP

Description

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.

int NUM_CALLBACKS

int VERTICAL

Description

Widget has vertical orientation.

int HORIZONTAL

Description

Widget has horizontal orientation.

int VALIDATOR_ANY

Description

Input control accepts any data.

int VALIDATOR_INT

Description

Input control accepts only integer data.

int VALIDATOR_UINT

Description

Input control accepts only unsigned integer data.

int VALIDATOR_FLOAT

Description

Input control accepts only floating point data.

int VALIDATOR_ASCII

Description

Input control accepts only ASCII based symbols.

int ATTACH_LOG10

Description

Attached slider uses a logarithmic scale with the base ten.

int ATTACH_MIN_EXPAND

Description

Minimum value of the attached slider can be lowered.

int ATTACH_MAX_EXPAND

Description

Maximum value of the attached slider can be raised.

int ALIGN_CENTER

Description

Widget is centered relative to its container.

int ALIGN_LEFT

Description

Widget is aligned to the left side of its container.

int ALIGN_RIGHT

Description

Widget is aligned to the right side of its container.

int ALIGN_TOP

Description

Widget is aligned to the top of its container.

int ALIGN_BOTTOM

Description

Widget is aligned to the bottom of its container.

int ALIGN_EXPAND

Description

Widget occupies all available space inside its container.

int ALIGN_OVERLAP

Description

Widget is rendered over other widgets, on the foreground (or over the contents of the parent container). Overlapping widgets are sorted between each other (i.e. pop up when focused on). This flag also makes the window movable.

int ALIGN_BACKGROUND

Description

Widget is always placed under other widgets. If clicken on, it does not pop up. Use this flag together with GUI_ALIGN_OVERLAP one.

int ALIGN_FIXED

Description

Widget in focus stays on the background or on the foreground (depending on where it was created). This flag is valid only if GUI_ALIGN_OVERLAP is also set. Non-fixed overlapping windows can pop over the fixed ones, while the latter cannot do it.

int BUFFER_RED

Description

Mask that specifies the red channel.

int BUFFER_GREEN

Description

Mask that specifies the green channel.

int BUFFER_BLUE

Description

Mask that specifies the blue channel.

int BUFFER_ALPHA

Description

Mask that specifies the alpha channel.

int BUFFER_ALL

Description

Mask that specifies all channels.

int BLEND_NONE

Description

No blending is used for a widget.

int BLEND_ZERO

Description

Components of each widget color are multiplied by zero.

int BLEND_ONE

Description

Components of each widget color are multiplied by one.

int BLEND_SRC_COLOR

Description

Components of each widget color are multiplied by these factors (per component): (wR, wG, wB, wA) .

int BLEND_ONE_MINUS_SRC_COLOR

Description

Components of each widget color are multiplied by these factors (per component): (1 - wR, 1 - wG, 1 - wB, 1 - wA) .

int BLEND_SRC_ALPHA

Description

Components of each widget color are multiplied by wA .

int BLEND_ONE_MINUS_SRC_ALPHA

Description

Components of each widget color are multiplied by 1- wA .

int BLEND_DEST_COLOR

Description

Components of each widget color are multiplied by these factors (per component): (bR, bG, bB, bA) .

int BLEND_ONE_MINUS_DEST_COLOR

Description

Components of each widget color are multiplied by these factors (per component): (1 - bR, 1 - bG, 1 - bB, 1 - bA) .

int BLEND_DEST_ALPHA

Description

Components of each widget color are multiplied by bA .

int BLEND_ONE_MINUS_DEST_ALPHA

Description

Components of each widget color are multiplied by 1- bA .

int CURSOR_NONE

Description

Mouse pointer is not displayed.

int CURSOR_ARROW

Description

Default arrow pointer is displayed.

int CURSOR_NA

Description

Pointer indicating that an operation is not available is displayed.

int CURSOR_DND

Description

Pointer for a drag-and-drop operation is displayed.

int CURSOR_WIDTH

Description

Pointer for horizontal resizing is displayed.

int CURSOR_HEIGHT

Description

Pointer for vertical resizing is displayed.

int CURSOR_NESW

Description

Pointer for top-right / bottom-left resizing is displayed.

int CURSOR_NWSE

Description

Pointer for top-left / bottom-right resizing is displayed.

int CURSOR_MOVE

Description

Pointer for move operation is displayed.

int CURSOR_ROTATE

Description

Pointer for rotation operation is displayed.

int CURSOR_SCALE

Description

Pointer for operation of object scaling is displayed.

int NUM_CURSORS

Last update: 2017-07-03
Build: ()