How to use SDK to configure application UI
The SDK includes a UI builder. The UI builder lets you configure the visuals of the application UI.
You can change the UI by editing global settings that affect UI elements’ visuals — color, texture, and font. These properties group into a theme.
To swap the UI elements of the same type, you can use the widget wrappers — containers for created UI elements.
The UI builder contains 2 independent parts:
- Themes are responsible for working with visuals.
- Widget manager is responsible for working with widgets and lets you replace whole parts of the UI.
Work with themes
Theme is a
XsollaUtilsTheme type asset. It contains the list of colors, fonts, and textures that are used by the UI elements. Every list is a set of key-value pairs where the key is a unique name of a theme parameter, and the value is a corresponding color, font, or texture.
You can work with themes in
- To set the theme of the UI, select it in the
- To edit the selected theme, click the
🔎icon near the Interface Themefield.
- To create a new theme, click the + icon near the
- To delete a selected theme, click the × icon near the
Connect UI element to theme
To connect the UI element to the theme:
- In the UI element widget blueprint, get access to the theme by the following methods:
GetCurrentTheme— returns the current theme specified in the plug-in settings.
GetTheme— returns a theme by the name specified in the
- Use the following methods to get the values of definite parameters from the theme by passing the theme parameter name to them:
GetColor— gets color value.
GetFont— gets font.
GetBrush— gets texture.
In the demo project, every widget that supports themes has a set of
String type parameters with theme parameter names. These parameters are used for setting up a visual for the UI element.
To find examples of widgets that support themes, go to
Work with widget manager
The widget manager is a mechanism that lets you automatically replace the UI elements with the UI elements of the same type by changing their visuals and behavior.
To create the UI that supports the widget manager, the following conditions should be met:
- Create a widget with the specified unified interface for the UI element.
- Define the type name for the UI element widget in the widget library.
- Pass the widget type for the UI element to the wrapper. The wrapper is a container for creating the UI elements. The name of the widget type should be identical to the name in the library.
- When creating a UI, use the wrapper instead of the widget.
A wrapper is a container that creates a required widget in the area of the page that is occupied by the wrapper.
Using the widget wrappers when creating the UI lets you automatically change the UI elements within the whole UI. To do this, change the widget in the wrapper. The standard flow, that uses UI primitives, suggests replacing all widgets manually in this scenario.
Here are the following wrappers for different widget types:
W_ButtonWrapper— for a button
W_InputWrapper— for an input field
W_TextWrapper— for text
W_RichTextWrapper— for rich text
W_ImageWrapper— for an image
W_CheckBoxWrapper— for a box
You can find the widget wrappers blueprints in
The wrappers use the widget manager methods to interact with the widgets.
To make the UI primitives interact with the widget wrapper as they would with the usual widget, the wrappers use unified interfaces.
There are the following wrappers for different widget types:
BPI_PrimitivesButton— for a button
BPI_PrimitivesInput— for an input field
BPI_PrimitivesText— for text
BPI_PrimitivesRichText— for rich text
BPI_PrimitivesImage— for an image
BPI_PrimitivesCheckbox— for a box
You can configure interfaces for the UI elements widgets in the
You can find the widget interfaces in
The widget library is an asset of the
XsollaUtilsWidgetsLibrary type that contains the list of widget classes in a form of key-value pairs. The key contains the name of the widget type and the value contains the widget class that will be created by a corresponding wrapper with this key.
The widget library works as a connector between the wrappers and widget classes.
BP_DefaultWidgetLibrary default widget library is included in the SDK. This library contains the list of UI elements from the demo project.
You can work with the widget library in
- To install the current widget library, select it in the
- To edit the selected widget library, click the
🔎icon near the Widgets Libraryfield.
- To create a new widget library, click the + icon near the
- To delete the selected widget library, click the × icon near the
Use the following methods in the wrapper blueprints to get access to the widget library:
GetCurrentWidgetsLibrary— returns the current widget library specified in the plug-in settings.
GetWidgetsLibrary— returns the specified widget library by the name specified in the
GetWidget method in the wrapper blueprints, to get the widget type from the library.
Methods of widget manager
The following methods are used by the wrappers to interact with the widgets. Use them when creating your own wrappers and widgets that support themes.
Methods for working with buttons
|Sets the button state that defines whether the button reacts to the keyboard, mouse, timer events, etc.|
|Returns the button state that defines whether the button reacts to the keyboard, mouse, timer events, etc.|
|Returns the list of UI primitives that contain the widget. Is used for subscribing to the button-clicking event.|
|Initializes the button widget. Is used by the widget wrapper.|
|Sets a list of additional data for a button. Every widget processes the received data, demonstrates it, or uses it according to the inner logic. For example, you can use the set of additional data to pass the list of the drop-down menu elements to the button that has a drop-down menu.|
|Sets a list of icons to display for a button. Use this method to specify the icon size and the distance between the icon and other button elements.|
|Sets the toggle position. For example: on or off, in cart or not in cart, etc.|
|Returns the set of theme parameters used by the button widget.|
|Sets the text for a button.|
Methods for working with boxes
|Sets the state of the box whether it’s checked or unchecked.|
|Returns the state of the box.|
|Checks whether the cursor hovers the box area.|
|Initializes the box widget. Is used by the widget wrapper.|
|Returns the list of UI primitives contained by the widget. Used for subscribing to the box events.|
|Returns the set of theme parameters used by the box widget.|
|Sets the text for the box.|
|Receives the text for the box.|
Methods for working with text or rich text
|Returns the text value.|
|Sets the text value.|
|Returns the list of UI primitives contained by the widget. Used for subscribing to the text events.|
|Returns the set of theme parameters used by the text widget.|
|Initializes the text widget. Is used by the widget wrapper.|
Methods for working with images
|Returns the image.|
|Sets the image.|
|Returns the list of UI primitives contained by the widget. Used for subscribing to the image events.|
|Returns the set of theme parameters used by the image widget.|
|Initializes the image widget. Is used by the widget wrapper.|
Method for working with input fields
|Returns the text to the input field.|
|Sets the text to the input field.|
|Returns the list of UI primitives contained by the widget. Used for subscribing to the input field events.|
|Initializes the input field widget. Is used by the widget wrapper.|
|Returns the tip text for the input field.|
|Sets the tip text for the input field.|
|Sets the focus on the input field.|
|Returns the set of theme parameters used by the input field widget.|
Was this article helpful?
Rate this page
Don’t want to answer
Thank you for your feedback!
Found a typo or other text error? Select the text and press Ctrl+Enter.