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
Landscape Tool
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.Widget Class

This base class is used to create graphical user interface widgets of different types.

See Also#

  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder

Widget Class

Enums

TYPE#

NameDescription
WIDGET_VBOX = 0Vertical box. See also: WidgetVBox.
WIDGET_HBOX = 1Horizontal box. See also: WidgetHBox.
WIDGET_VPANED = 3Vertical box that allows resizing of its children. See also: WidgetVPaned.
WIDGET_HPANED = 4Horizontal box that allows resizing of its children. See also: WidgetHPaned.
WIDGET_LABEL = 5Text label. See also: WidgetLabel.
WIDGET_BUTTON = 6Simple button. See also: WidgetButton.
WIDGET_EDIT_LINE = 7Text field. See also: WidgetEditline.
WIDGET_EDIT_TEXT = 8Multiline text field. See also: WidgetEdittext.
WIDGET_CHECK_BOX = 9Checkbox. See also: WidgetCheckbox.
WIDGET_COMBO_BOX = 10Combobox. See also: WidgetCombobox.
WIDGET_CANVAS = 11Canvas widget for drawing text, lines and polygons. See also: WidgetCanvas.
WIDGET_GROUP_BOX = 12Group box. See also: WidgetGroupBox.
WIDGET_GRID_BOX = 2Grid box. See also: WidgetGridBox.
WIDGET_LIST_BOX = 13List box. See also: WidgetListBox.
WIDGET_TREE_BOX = 14Tree box. See also: WidgetTreeBox.
WIDGET_TAB_BOX = 15Tabbed box. See also: WidgetTabBox.
WIDGET_SCROLL = 16A scrollbar: horizontal or vertical one. See also: WidgetScroll.
WIDGET_SCROLL_BOX = 17Box with scrolling. See also: WidgetScrollBox.
WIDGET_SPACER = 18Spacer: horizontal or vertical one. See also: WidgetSpacer.
WIDGET_SLIDER = 19A slider: horizontal or vertical one. See also: WidgetSlider.
WIDGET_SPIN_BOX = 20Spinbox. See also: WidgetSpinBox.
WIDGET_SPIN_BOX_DOUBLE = 21Spinbox with double values. See also: WidgetSpinBoxDouble.
WIDGET_ICON = 22Icon. See also: WidgetIcon.
WIDGET_SPRITE = 23Sprite. See also: WidgetSprite.
WIDGET_SPRITE_VIDEO = 24Video Sprite. See also: WidgetSpriteVideo.
WIDGET_SPRITE_SHADER = 25Shader Sprite. See also: WidgetSpriteShader.
WIDGET_SPRITE_VIEWPORT = 26Viewport Sprite. See also: WidgetSpriteViewport.
WIDGET_SPRITE_NODE = 27Node Sprite. See also: WidgetSpriteNode.
WIDGET_MENU_BAR = 28Menu bar. See also: WidgetMenuBar.
WIDGET_MENU_BOX = 29Menu. See also: WidgetMenuBox.
WIDGET_WINDOW = 30Window. See also: WidgetWindow.
WIDGET_DIALOG = 31Dialog window. See also: WidgetDialog.
WIDGET_DIALOG_MESSAGE = 32Message Dialog. See also: WidgetDialogMessage.
WIDGET_DIALOG_FILE = 33File Dialog. See also: WidgetDialogFile.
WIDGET_DIALOG_COLOR = 34Color Dialog. See also: WidgetDialogColor.
WIDGET_DIALOG_IMAGE = 35Image Dialog. See also: WidgetDialogImage.
WIDGET_MANIPULATOR = 36Manipulator widget. See also: WidgetManipulator.
WIDGET_MANIPULATOR_TRANSLATOR = 37Translator Manipulator. See also: WidgetManipulatorTranslator.
WIDGET_MANIPULATOR_ROTATOR = 38Rotator Manipulator. See also: WidgetManipulatorRotator.
WIDGET_MANIPULATOR_SCALER = 39Scaler Manipulator. See also: WidgetManipulatorScaler.
WIDGET_EXTERN = 40External widget.
WIDGET_ENGINE = 41Engine-specific widget (manipulator). See also: WidgetManipulator.
NUM_WIDGETS = 42Total number of widget types.

Properties

int NumChildren#

The number of child widgets.

int FontWrap#

The A value indicating if text wrapping to widget width is enabled.

int FontRich#

The A value indicating if rich text formatting is used.

int FontOutline#

The A value indicating if widget text is rendered casting a shadow. positive or negative values determine the distance in pixels used to offset the font outline.

int FontVOffset#

The vertical offset of the font used by the widget.

int FontHOffset#

The horizontal offset of the font used by the widget.

int FontVSpacing#

The spacing (in pixels) between widget text lines.

int FontHSpacing#

The spacing (in pixels) between widget text characters.

int FontPermanent#

The A flag indicating if color of the widget text is not changed (for example, when the widget becomes non-active or loses focus).

vec4 FontColor#

The color of the font used by the widget.

int FontSize#

The size of the font used by the widget.

int MouseCursor#

The current mouse pointer.

int MouseY#

The y coordinate of the mouse pointer position on the screen.

int MouseX#

The x coordinate of the mouse pointer position on the screen.

int Height#

The current widget height in pixels.

int Width#

The current widget width in pixels.

int ScreenPositionY#

The screen position of the widget (its top left corner) on the screen along the y axis.

int ScreenPositionX#

The screen position of the widget (its top left corner) on the screen along the x axis.

int PositionY#

The y coordinate of the widget position relative to its parent.

int PositionX#

The Relative X coordinate.

Widget NextFocus#

The A widget which will be focused next if the user presses TAB.

string Data#

The User data associated with the widget.

int Order#

The Rendering order (z-order) for the widget.

bool Hidden#

The A value indicating if the widget is hidden.

bool Enabled#

The A value indicating if the widget is enabled.

bool IntersectionEnabled#

The A value indicating if intersection detection is enabled for the widget.

int Flags#

The Widget flags.

Widget Parent#

The pointer to the parent widget.

Gui ParentGui#

The parent gui smart pointer.

Gui Gui#

The gui smart pointer.

string TypeName#

The A name of the widget type.

Widget.TYPE Type#

The A type of the widget.

Members


bool IsCallback ( int callback ) #

Returns a value indicating if there are any callbacks of the specified type set for the widget.

Arguments

  • int callback - One of the callbacks defined in the Gui class.

Return value

true if at least one callback of the specified type is set for the widget; otherwise, false.

IntPtr addCallback ( Gui.CALLBACK_INDEX callback, Callback0Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name();

Arguments

  • Gui.CALLBACK_INDEX callback
  • Callback0Delegate func - Callback function with the following signature: void Callback0Delegate()

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr addCallback ( Gui.CALLBACK_INDEX callback, Callback1Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name(Widget sender);
sender - the widget that caused the callback function to be called, i.e. the one on which the action took place (e.g. a button, that was clicked).

Arguments

  • Gui.CALLBACK_INDEX callback
  • Callback1Delegate func - Callback function with the following signature: void Callback1Delegate(Widget sender)

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr addCallback ( Gui.CALLBACK_INDEX callback, Callback2Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name(Widget sender, Widget pointer);
  • sender - the widget that caused the callback function to be called, i.e. the one on which the action took place (e.g. a button, that was clicked).
  • pointer - this parameter is used to identify a target widget of a Drag-and-Drop operation. You can find an example in the widgets/sprite_03 UnigineScript sample included in the SDK.

Arguments

  • Gui.CALLBACK_INDEX callback
  • Callback2Delegate func - Callback function with the following signature: void Callback2Delegate(Widget sender, Widget pointer)

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr addCallback ( Gui.CALLBACK_INDEX callback, Callback3Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name(Widget sender, Widget pointer, int data);
  • sender - the widget that caused the callback function to be called, i.e. the one on which the action took place (e.g. a button, that was clicked).
  • pointer - this parameter is used to identify a target widget of a Drag-and-Drop operation. You can find an example in the widgets/sprite_03 UnigineScript sample included in the SDK.
  • data - this parameter is used for getting mouse or keyboard button state, when a widget is clicked or pressed (callbacks: CLICKED, PRESSED, KEY_PRESSED).

Arguments

  • Gui.CALLBACK_INDEX callback
  • Callback3Delegate func - Callback function with the following signature: void Callback3Delegate(Widget sender, Widget pointer, int data)

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeCallback ( Gui.CALLBACK_INDEX callback, IntPtr id ) #

Removes the specified callback from the list of callbacks of the specified type added for the widget.

Arguments

Return value

True if the callback with the given ID was removed successfully; otherwise false.

void clearCallbacks ( Gui.CALLBACK_INDEX callback ) #

Clears all callbacks of the specified type added for the widget.

Arguments

void SetCallbackAccel ( Gui.CALLBACK_INDEX callback, uint key, int ctrl, int alt, int shift ) #

Assigns a hot key combination to a given callback function.

Arguments

  • Gui.CALLBACK_INDEX callback - One of the callbacks defined in the Gui class.
  • uint key - One of the standard ASCII keycodes or one of the APP_KEY_* pre-defined variables.
  • int ctrl - 1 to use the CTRL key modifier, 0 not to use.
  • int alt - 1 to use the ALT key modifier, 0 not to use.
  • int shift - 1 to use the SHIFT key modifier, 0 not to use.

bool GetCallbackAccel ( Gui.CALLBACK_INDEX callback, out uint key, out int ctrl, out int alt, out int shift ) #

Gets the current hot key combination for a given callback function.

Arguments

  • Gui.CALLBACK_INDEX callback - Callback number: one of the Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • out uint key - ASCII key code: one of the App:: Enumeration with KEY_* prefixes.
  • out int ctrl - CTRL key modifier.
  • out int alt - ALT key modifier.
  • out int shift - SHIFT key modifier.

Return value

true if the specified callback type exists; otherwise, false.

int IsCallbackAccel ( uint key, int ctrl, int alt, int shift ) #

Checks if the given key in combination with CTRL, ALT, or/and SHIFT buttons is assigned as a widget callback.

Arguments

  • uint key - One of the standard ASCII keycodes or one of the APP_KEY_* pre-defined variables.
  • int ctrl - 1 if the CTRL key modifier is used; otherwise, 0.
  • int alt - 1 if the ALT key modifier is used; otherwise, 0.
  • int shift - 1 if the SHIFT key modifier is used; otherwise, 0.

Return value

1 if it is used in combinations; otherwise, 0.

void SetCallbackEnabled ( Gui.CALLBACK_INDEX callback, bool enabled ) #

Enables or disables a given callback function.

Arguments

int IsCallbackEnabled ( Gui.CALLBACK_INDEX callback ) #

Returns a value indicating if a given callback is enabled.

Arguments

Return value

Returns 1 if the callback is disabled; otherwise, 0.

Widget GetChild ( int num ) #

Returns the widget child by its number.

Arguments

  • int num - Widget number.

Return value

Pointer to the child widget.

int IsChild ( Widget w ) #

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

Arguments

  • Widget w - Widget to check.

Return value

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

void SetFocus ( ) #

Sets focus on the widget.

int IsFocused ( ) #

Returns a value indicating if the widget is in focus.

Return value

1 if the widget is in focus; otherwise, 0.

void SetFont ( string name ) #

Sets a font that will be used to render text on the widget.

Arguments

  • string name - Font name.

int GetIntersection ( int x, int y ) #

Checks for an intersection with the widget's bounds for the given point.

Arguments

  • int x - Local X coordinate.
  • int y - Local Y coordinate.

Return value

1 if the input coordinate is inside the widget; otherwise, 0.

int GetKeyActivity ( uint key ) #

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

Arguments

  • uint key - One of the standard ASCII keycodes or one of the APP_KEY_* pre-defined variables.

Return value

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

void SetPermanentFocus ( ) #

Sets permanent focus on the widget (it means that the widget is always in focus).

void SetPosition ( int x, int y ) #

Sets a position of the widget relative to its parent.

Arguments

  • int x - X coordinate of the upper left corner of the widget.
  • int y - Y coordinate of the upper left corner of the widget.

void SetToolTip ( string str, int reset = 0 ) #

Sets a tooltip for the widget.

Arguments

  • string str - Tooltip text.
  • int reset - 1 to recalculate a tooltip location if the mouse cursor was relocated; otherwise - 0(by default).

string GetToolTip ( ) #

Returns the widget's tooltip text.

Return value

Tooltip text.

void AddAttach ( Widget w, string format = 0, int multiplier = 1, int flags = 0 ) #

Attaches a given widget to the current one. When applied to checkboxes, converts them into a group of radio buttons. A horizontal/vertical slider can be attached to a label or a text field. The text field can be attached to any of the sliders.

Arguments

  • Widget w - Widget to attach.
  • string format - Format string for values entered into the attached widget. If none specified, "%d" is implied. This is an optional parameter.
  • int multiplier - Multiplier value, which is used to scale values provided by the attached widget. This is an optional parameter.
  • int flags - One of the ATTACH_* pre-defined variables. This is an optional parameter.

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

Adds a child to the widget.

Arguments

  • Widget w - Child widget.
  • int flags - One of the ALIGN_* pre-defined variables. This is an optional parameter.

void Arrange ( ) #

Rearranges the widget and its children to lay them out neatly. This function forces to recalculate widget size and allows to get updated GUI layout data in the current frame. If this function is not called, widget modifications made in the current update() will be available only in the next frame (i.e. with one-frame lag), as GUI is calculated and rendered after the script update() function has been executed.

void Raise ( Widget w ) #

Brings a given widget to the top.
Notice
Works only for widgets added to GUI via the Gui.addChild() function with the Gui.ALIGN_OVERLAP flag specified (should not be Gui.ALIGN_FIXED).

Arguments

  • Widget w - Widget to be brought up.

void RemoveAttach ( Widget w ) #

Detaches a given widget from the current one.

Arguments

  • Widget w - Widget to detach.

void RemoveChild ( Widget w ) #

Removes a child widget from the list of the widget's children.

Arguments

  • Widget w - Child widget.

void RemoveFocus ( ) #

Removes focus from the widget.

void ReplaceChild ( Widget w, Widget old_w, int flags = 0 ) #

Replaces one child widget with another.

Arguments

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

void RunCallback ( int callback ) #

Runs a given callback function.

Arguments

  • int callback - One of the callbacks defined in the Gui class.
Last update: 2022-03-10
Build: ()