This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
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::Widgets

Unigine::Widgets are user classes that allow to code user interface only once and use them for both internal GUI (in-app) and external one (rendered in separate windows):

  • If the Unigine-based application is run without the Interface plugin, widgets will be created inside the window, in the same way as default GUI is usually rendered.
  • If the Interface plugin is loaded on the application start-up (via extern_plugin console command), widgets will be automatically created in separate windows in addition to the main application window.

Available Widgets

Unigine::Widgets act identical to UnigineScript widgets and support completely the same interface:

Also, there are three additional widgets available:

  • Unigine::Widgets::DockBox — a widget that can be dragged and docked inside a window.
  • Unigine::Widgets::Graph — a widget to create flow graphs. Unigine::Schemer editor is implemented based on this class.
  • Unigine::Widgets::MdiBox — a widget to create multiple windows inside other windows

How to Use Unigine::Widgets Widgets

  1. Include the necessary headers for widgets you are going to create in your script:
    Source code (UnigineScript)
    #include <core/systems/widgets/widget.h>
    #include <core/systems/widgets/widget_window.h>
  2. Create a widget:
    Source code (UnigineScript)
    int init() {
    	
    	// You can declare the namespace for convenience
    	using Unigine::Widgets;
    	
    	// Create Unigine::Widgets::Window
    	Window window = new Window("Unigine::Widgets::Window");
    	
    	// Add the widget to the rendered GUI
    	addChild(window,ALIGN_OVERLAP | ALIGN_CENTER);
    	
    	return 1;
    }
    When the application is run, either internal WidgetWindow or external InterfaceWidgetWindow will be automatically created depending on whether the Interface plugin is used or not.
Last update: 2017-07-03
Build: ()