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
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
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
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.

Window Management

UNIGINE provides an advanced toolkit simplifying development of various visual tools, with a large number of widgets and capabilities.

For windows creation, the EngineWindow class is used. It allows managing engine windows components, relations with other windows, size, position, and other features.

All window management operations are performed via the WindowManager class enabling you to access any window of the application, group or stack windows, create various dialogs, and so on.

Notice
Usually the engine windows stay available during the whole UNIGINE Engine runtime, so their creation and management must be implemented as a part of the System Logic.

Creating Windows#

To create the engine window, one of the EngineWindow class constructors is used.

Source code (C#)
// create an engine window of the specified size with the specified name
EngineWindow window_0 = new EngineWindow("Window", 580, 300);
// create the main engine window of the specified size
EngineWindow window_1 = new EngineWindow(580, 300, EngineWindow.FLAGS.MAIN);

When the window is created, you can change its appearance and properties, specify the engine tools available for the window and add widgets to its client area. All these operations can be done by means of the EngineWindow class as well.

Source code (C#)
// set an icon and a title for the window 
window_1.SetIcon("icon.png");
window_1.Title = "Main Window";

// allow using the window as a nested one
window_1.NestedUsage = true;

// enable the console, profiler and visualizer for the window
window_1.ConsoleUsage = true;
window_1.ProfilerUsage = true;
window_1.VisualizerUsage = true;

// add widgets to the client area of the window
window_1.AddChild(new WidgetLabel(window.SelfGui,  String.Format("This is {0} window.", window_1.Title)));
window_1.AddChild(new WidgetButton(window.SelfGui, window_1.Title), Gui.ALIGN_CENTER);

For rendering of the engine window, the Show() function is used:

Source code (C#)
// render the window
window_1.Show();

Accessing Windows#

An application window can be accessed via the WindowManager.GetWindow() function.

Source code (C#)
// get the number of windows
int num = WindowManager.NumWindows;
// check each window
for (int i = 0; i < num; i++)
{
	// get the window with the current index
	EngineWindow window = WindowManager.GetWindow(i);
	// change its position and size if it is main
	if (window.Main)
	{
		window.Position = new ivec2(1020, 60);
		window.Size = new ivec2(305, 670);
	}
}

There are also some properties (like WindowManager.MainWindow) that allow accessing the specific windows (the main, focused, fullscreen window and so on). For example:

Source code (C#)
// get the main window
EngineWindow main_window = WindowManager.MainWindow;
// change its position and size
if (main_window)
{
	main_window.Position = new ivec2(1020, 60);
	main_window.Size = new ivec2(305, 670);
}

Grouping Windows#

The engine windows created via the EngineWindow class can be grouped. When two windows are grouped, a new window containing these windows is created. The new window is called a group. The number of windows in the group is unlimited.

There are three types of the window groups:

  • Vertical
  • Horizontal
  • Group of tabs

Within the group, all windows are stacked according to one of these types.

Notice
Grouping of the created windows can be done via the code or by using the mouse while the application is running.

The WindowManager class provides two main functions for grouping windows:

Source code (C#)
// create separate windows
EngineWindow horizontal_1 = new EngineWindow("Horizontal 1", 512, 256);
EngineWindow horizontal_2 = new EngineWindow("Horizontal 2", 512, 256);
EngineWindow horizontal_3 = new EngineWindow("Horizontal 3", 512, 256);
EngineWindow horizontal_4 = new EngineWindow("Horizontal 4", 512, 256);

// create 2 horizontal window groups 
EngineWindow horizontal_group_1 = WindowManager.Stack(horizontal_1, horizontal_2, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
EngineWindow horizontal_group_2 = WindowManager.Stack(horizontal_3, horizontal_4, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
// create a vertical group of 2 horizontal groups
EngineWindow vertical_group = WindowManager.StackGroups(horizontal_group_1, horizontal_group_2, EngineWindow.GROUP_TYPE.VERTICAL);
// specify position, size, title of the verical window group
vertical_group.Position = new ivec2(50, 60);
vertical_group.Size = new ivec2(565, 310);
vertical_group.Title = "Vertical Group";
// render the window group
vertical_group.Show();

Each window or window group has a state, so it changes after stacking.

There are also functions based on the WindowManager.Stack() function that should be used in specific cases to avoid additional checking of arguments:

  • WindowManager.StackToParentGroup() stacks the second window to the parent group of the first window. In the result, both windows passed as arguments will be on the same level in the group hierarchy.

    Source code (C#)
    // stack 2 separate windows
    EngineWindow group_0 = WindowManager.StackWindows(window_1, window_2, EngineWindow.GROUP_TYPE.HORIZONTAL);
    // stack a separate window to the parent group of "window_1"
    WindowManager.StackToParentGroup(window_1,window_3);

  • WindowManager.StackToWindow() stacks the window to the other window. If the first argument is the separate window, a new window group is returned. If the first argument is the nested window, the window is added to its group.

    Source code (C#)
    // create a group of 2 windows
    EngineWindow group_1 = WindowManager.Stack(window_1, window_2, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
    // stack a separate window to the window from the window group
    WindowManager.StackToWindow(window_1, window_3, EngineWindow.GROUP_TYPE.VERTICAL);

  • WindowManager.StackWindows() creates a group of the separate/nested windows. The windows are stacked in the default order.
  • WindowManager.StackToGroup() stacks the window or window group to another window group.

For ungrouping, the WindowManager.Unstack() function is used: it removes the window or the window group from the parent group. If only one window remains in the group, it is automatically removed from the group and the group is deleted.

Grouping Using the Mouse#

While the application is running, you can group and ungroup the existing windows by using the mouse.

To group two separate windows, do the following:

  1. Hold the mouse button while moving the window to the destination one. The destination window will be divided into 9 sectors.
  2. Choose the required sector and release the mouse button: the windows will be grouped.

To add the window to the existing group, you should hold the mouse button while moving the window and release it in one of the following areas:

  • For the horizontal group:

  • For the vertical group:

  • For the group of tabs:

To ungroup the window, move it outside the group.

Working with Dialogs#

To create a dialog window, use the corresponding functions of the class. For example:

Source code (C#)
using Unigine;

namespace UnigineApp
{
	class AppSystemLogic : SystemLogic
	{
		
		// create a window with widgets in the client area
		public EngineWindow create_window (string name)
		{
			EngineWindow window = new EngineWindow(name, 512, 256);

			window.AddChild(new WidgetLabel(window.SelfGui, String.Format("This is a {0}.", name)), Gui.ALIGN_TOP);
			window.AddChild(new WidgetButton(window.SelfGui, name), Gui.ALIGN_CENTER);

			return window;
		}

		public override bool Init()
		{
			// create a window
			EngineWindow window = create_window("Window");
			// get the child widget of the window
			Widget button = window.GetChild(1);
			// add a callback that shows the message dialog
			button.AddCallback(Gui.CALLBACK_INDEX.CLICKED, () => WindowManager.DialogMessage("Message", "The button has been pressed."));
			// show the window
			window.Position = new ivec2(50, 60);
			window.Show();
		
			// get the main window
			EngineWindow main_window = WindowManager.MainWindow;
			// change its position and size
			if (main_window)
			{
				main_window.Position = new ivec2(1020, 60);
				main_window.Size = new ivec2(305, 670);
			}
			
			return true;
		}
	}
}

If you press the button in the client area of the created window, the following dialog will be shown:

Last update: 2022-12-14
Build: ()