VisUI allows to create nice looking UI in libGDX using scene2d.ui. Library contains scene2d.ui skin, useful widgets like color picker and file chooser, it also contains modified scene2d.ui widgets to provide some extra functionality like focus borders, background change on over and click, etc.
VisUI is licensed under Apache2 license meaning that you can use it for free in both commercial and non-commercial projects.
CHANGES file (definitely read before updating!)
Please refer to libGDX documentation if you don't know how to manage dependencies with Gradle. Alternatively JAR can be downloaded from Maven repository. If you are creating new project, you can use gdx-setup to automatically add VisUI for you. (press 'Show Third Party Extension' button)
Open build.gradle in project root.
In ext
section under allprojects
add:
visuiVersion = '1.X.X'
Look at CHANGES file to see what version of VisUI you can use for your version of libGDX. Note that using not matching versions is likely to cause runtime exceptions.
Core dependency
api "com.kotcrab.vis:vis-ui:$visuiVersion"
HTML dependency (only if you are using GWT):
api "com.kotcrab.vis:vis-ui:$visuiVersion:sources"
GdxDefinition.gwt.xml
and GdxDefinitionSuperdev.gwt.xml
:
<inherits name='com.kotcrab.vis.vis-ui' />
Refresh Gradle dependencies.
Using VisUI is pretty simple, to load or unload the skin call:
VisUI.load();
VisUI.dispose();
Create your UI like always, for extra skin features you have to use Vis widgets instead of standard scene2d.ui:
VisUI | Standard scene2d.ui |
---|---|
VisLabel | Label |
LinkLabel | - |
VisCheckBox | CheckBox |
VisList | List |
VisProgressBar | ProgressBar |
VisRadioButton | - |
VisScrollPane | ScrollPane |
VisSelectBox | SelectBox |
VisSlider | Slider |
VisSplitPane | SplitPane |
VisTextArea | TextArea |
VisTextButton | TextButton |
VisImageTextButton | ImageTextButton |
VisImageButton | ImageButton |
VisTextField | TextField |
VisValidatableTextField | - |
VisTree | Tree |
VisWindow | Window |
VisTable | Table |
DragPane | - |
GridGroup | - |
ListView | - |
TabbedPane | - |
Spinner | - |
CollapsibleWidget | - |
ButtonBar | - |
FlowGroups | - |
Using Vis widgets is necessary for proper focus border management. All VisUI widgets constructors do not have Skin argument, they are using VisUI.skin field.
VisTable allows to easily set default spacing for vis components, construct it like this:
VisTable table = new VisTable(true);
VisTable also allows adding vertical and horizontal separators to table:
table.addSeparator() //horizontal
table.addSeparator(true) //vertical
Default VisUI skin can be too small for high resolution screens or mobile devices, in that case you can load a upscaled skin version simply by calling:
VisUI.load(SkinScale.X2);
Classes inside com.kotcrab.vis.[...].internal
packages are considered private and aren't part of public API. Changes to that classes won't be listed in change log.
Default title align for VisWindow and VisDialog is Align.left
this can be changed by calling:
VisUI.setDefaultTitleAlign(int align)
Calling this method does not affect windows that have been already created.
Raw skin files are available if you would like to modify them. After you pack them using libGDX texture packer, add generated atlas to your project with uiskin.json, default.fnt and font-small.fnt and load it by calling:
VisUI.load(Gdx.files.internal("path/to/your/modified/files/uiskin.json"))
Consider using USL if you want to extend existing VisUI styles. Read more
- vis-ui-contrib - Community driven extension, utilities and skins for VisUI
- ktx - Kotlin utilities for libGDX applications. The ktx-vis and ktx-style-vis modules provide Kotlin APIs for VisUI.