Unigine.WindowManager Class
The class to manage windows enabling you to access any window of the appllication, group or stack windows, create various dialogs and so on.
Accessing Windows#
An application window can be accessed via the WindowManager.GetWindow() function. There are also some properties (like WindowManager.MainWindow) that allow accessing the specific windows (a focused window, a fullscreen window and so on).
// 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. There are three types of the window groups:
- Vertical
- Horizontal
- Group of tabs
The WindowManager class provides two main functions for grouping windows:
- WindowManager.Stack() creates a group of two windows.
- WindowManager.StackGroups() creates a group of two window groups.
// 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 = "Horizontal Group";
// render the window group
vertical_group.Show();
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.
- WindowManager.StackWindows() creates a group of the separate/nested windows. The windows are stacked in the default order.
- 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.
- 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.
Creating Dialog Windows#
To create a dialog window, use the corresponding functions of the class. For example:
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 {0} window.", 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", "Button has been clicked"));
// 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;
}
}
}
WindowManager Class
Enums
CALLBACKS#
Properties
EngineWindow MainWindow#
int NumWindows#
EngineWindow GuiFocusedWindow#
EngineWindow FullscreenWindow#
bool IsFullscreenMode#
bool IsMultipleWindowsSupported#
EngineWindow FocusedWindow#
EngineWindow UnderCursorWindow#
Members
EngineWindow GetWindow ( int index ) #
Returns the window by its index.Arguments
- int index - Index of the window.
Return value
Engine window.int GetWindowIndex ( EngineWindow window ) #
Returns the index of the specified window.Arguments
- EngineWindow window - Engine window.
Return value
Index of the window.EngineWindow Stack ( EngineWindow first, EngineWindow second, int index = -1, EngineWindow.GROUP_TYPE group_type = Enum.EngineWindow.GROUP_TYPE.TAB, bool decompose_second = false ) #
Returns the group of windows. If the first argument is a window, a new group is always created. If the first argument is a group, the second element is added to this group. The order of stacking can be changed by passing the index argument. To combine two groups into a new one, use the StackGroups() method.EngineWindow window_1 = new EngineWindow("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindow("Window 2", 512, 256);
// create a horizontal group of windows
EngineWindow group_1 = WindowManager.Stack(window_1, window_2, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
Arguments
- EngineWindow first - The first window or group for merging.
- EngineWindow second - The second window for merging.
- int index - A place where a window or a group should be placed in a group.
- EngineWindow.GROUP_TYPE group_type - Type of a group to be created, if the first argument is a window and not a group.
- bool decompose_second - Flag to decompose the second argument of the merge, if it is a group, and combine with the first window or a group.
Return value
Group of windows.EngineWindow StackToParentGroup ( EngineWindow destination, EngineWindow window, int index = -1, bool decompose_second = false ) #
Stacks the second window to the parent window group of the first window. In the result, both windows passed as arguments will be on the same level in the group hierarchy. If the first window has no parent group, the function will return it as is.EngineWindow window_1 = new EngineWindow("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindow("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindow("Window 3", 512, 256);
// 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);
Arguments
- EngineWindow destination - The window into the parent group of which the other window is stacked.
- EngineWindow window - The window to be stacked.
- int index - A place where a window or a group should be placed in a group.
- bool decompose_second - Flag to decompose the second argument of the merge, if it is a group, and combine with the first window or a group.
Return value
Group of windows.EngineWindow StackWindows ( EngineWindow first, EngineWindow second, EngineWindow.GROUP_TYPE group_type = Enum.EngineWindow.GROUP_TYPE.TAB ) #
Returns a newly created group of the separate and/or nested windows. You cannot stack the window group to the separate window, however, you can stack a window nested in the window group: in this case, the window will be unstacked from its parent group and added to the new one. The windows are stacked in the default order. For example:EngineWindow window_1 = new EngineWindow("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindow("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindow("Window 3", 512, 256);
// stack 2 separate windows
EngineWindow group_0 = WindowManager.StackWindows(window_1, window_2, EngineWindow.GROUP_TYPE.HORIZONTAL);
// stack a window from the window group to a separate window
EngineWindow group_1 = WindowManager.StackWindows(window_3, window_1, EngineWindow.GROUP_TYPE.VERTICAL);
Arguments
- EngineWindow first - The window to be stacked.
- EngineWindow second - The window to be stacked.
- EngineWindow.GROUP_TYPE group_type - Type of a group to be created.
Return value
Group of windows.EngineWindow StackGroups ( EngineWindow first, EngineWindow second, EngineWindow.GROUP_TYPE group_type = Enum.EngineWindow.GROUP_TYPE.TAB, bool decompose_second = false ) #
Returns the group of window groups. The second group is added to the first group. To combine two windows or a group and a window, use the Stack() method.EngineWindow window_1 = new EngineWindow("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindow("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindow("Window 3", 512, 256);
EngineWindow window_4 = new EngineWindow("Window 4", 512, 256);
// create 2 horizontal groups of windows
EngineWindow group_1 = WindowManager.Stack(window_1, window_2, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
EngineWindow group_2 = WindowManager.Stack(window_3, window_4, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
// stack one group to another to create a new vertical group
EngineWindow group_3 = WindowManager.StackGroups(group_1, group_2, EngineWindow.GROUP_TYPE.VERTICAL);
Arguments
- EngineWindow first - The first window group for merging.
- EngineWindow second - The second window group for merging.
- EngineWindow.GROUP_TYPE group_type - Type of a group to be created.
- bool decompose_second - Flag to decompose the second argument of the merge, if it is a group, and combine with the first group.
Return value
Group of windows.EngineWindow StackToWindow ( EngineWindow destination_window, EngineWindow window, EngineWindow.GROUP_TYPE group_type = Enum.EngineWindow.GROUP_TYPE.TAB, bool decompose_second = false ) #
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.EngineWindow window_1 = new EngineWindow("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindow("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindow("Window 3", 512, 256);
// 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);
Arguments
- EngineWindow destination_window - The parent window to which another window is stacked.
- EngineWindow window - The window to be stacked.
- EngineWindow.GROUP_TYPE group_type - Type of a group to be created.
- bool decompose_second - Flag to decompose the second argument of the merge, if it is a group, and combine with the first group.
Return value
Group of stacked windows.EngineWindow StackToGroup ( EngineWindow destination_group, EngineWindow group, int index = -1, bool decompose_second = false ) #
Stacks the window or window group to another window group. The updated group of windows is returned.EngineWindow window_1 = new EngineWindow("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindow("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindow("Window 3", 512, 256);
EngineWindow window_4 = new EngineWindow("Window 4", 512, 256);
// create 2 horizontal groups of windows
EngineWindow group_1 = WindowManager.Stack(window_1, window_2, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
EngineWindow group_2 = WindowManager.Stack(window_3, window_4, 1, EngineWindow.GROUP_TYPE.HORIZONTAL);
// stack one group to another
WindowManager.StackToGroup(group_1, group_2);
Arguments
- EngineWindow destination_group - The parent group to which another group is stacked.
- EngineWindow group - The window or window group to be stacked.
- int index - A place where a window or a group should be placed in a group.
- bool decompose_second - Flag to decompose the second argument of the merge and combine with the first group.
Return value
Group of stacked windows.void Unstack ( EngineWindow unstacked ) #
Removes a window or a group from a parent group. If there is only one window left, the group is automatically deleted after removing the window from it.Arguments
- EngineWindow unstacked - A window or a group to be removed from a parent group.
bool IsMultipleWindowsSupported ( ) #
Returns the value indicating if the engine can create more than one window. In addition to the settings defined by the user, it is currently impossible to create more than one window using Vulkan and DirectX 12. GL and DirectX 11, however, allow creating multiple windows.Return value
true if multiple windows are supported, otherwise false.EngineWindow GetWindowByID ( ulong win_id ) #
Returns the window by its ID.Arguments
- ulong win_id - Window ID.
Return value
Window with the specified ID, or null if the window is not found.bool DialogMessage ( string title, string message ) #
Displays a message dialog with the specified title and text.Arguments
- string title - Title of the message dialog to be displayed.
- string message - Message text to be displayed.
Return value
true if the message is displayed successfully; otherwise, false.bool DialogWarning ( string title, string warning ) #
Displays a warning dialog with the specified title and text.Arguments
- string title - Title of the warning dialog to be displayed.
- string warning - Warning message text to be displayed.
Return value
true if the message is displayed successfully; otherwise, false.bool DialogError ( string title, string error ) #
Displays an error dialog with the specified title and text.Arguments
- string title - Title of the error dialog to be displayed.
- string error - Error message text to be displayed.
Return value
true if the message is displayed successfully; otherwise, false.int ShowSystemDialog ( SystemDialog dialog ) #
Displays a custom system dialog with an arbitrary set of buttons.Arguments
- SystemDialog dialog - SystemDialog class instance representing the custom system dialog to be shown.
Return value
Number of the dialog button clicked by the user; or -1 if an error has occurred.string DialogOpenFolder ( string path ) #
Opens a common dialog enabling the user to specify a folder to open. When the dialog opens the specified default path shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
Return value
Resulting folder name specified by the user.string DialogOpenFolder ( ) #
Opens a common dialog enabling the user to specify a folder to open.Return value
Resulting folder name specified by the user.string[] DialogOpenFiles ( string path, string filter ) #
Opens a common dialog enabling the user to specify a list of filenames to open multiple files. When the dialog opens the specified default path and file filter shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
- string filter - File name filter string to be set by default when the dialog opens. This filter string determines file type choices to be displayed in the Files of type box.
Return value
Resulting list of filenames specified by the user.string[] DialogOpenFiles ( string path ) #
Opens a common dialog enabling the user to specify a list of filenames to open multiple files. When the dialog opens the specified default path shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
Return value
Resulting list of filenames specified by the user.string[] DialogOpenFiles ( ) #
Opens a common dialog enabling the user to specify a list of filenames to open multiple files.Return value
Resulting list of filenames specified by the user.string DialogOpenFile ( string path, string filter ) #
Opens a common dialog enabling the user to specify a filename to open a file. When the dialog opens the specified default path and file filter shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
- string filter - File name filter string to be set by default when the dialog opens. This filter string determines file type choices to be displayed in the Files of type box.
Return value
Resulting filename specified by the user.string DialogOpenFile ( string path ) #
Opens a common dialog enabling the user to specify a filename to open a file. When the dialog opens the specified default path shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
Return value
Resulting filename specified by the user.string DialogOpenFile ( ) #
Opens a common dialog enabling the user to specify a filename to open a file.Return value
Resulting filename specified by the user.string DialogSaveFile ( string path, string filter ) #
Opens a common dialog enabling the user to specify a filename to save a file as. When the dialog opens the specified default path and file filter shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
- string filter - File name filter string to be set by default when the dialog opens. This filter string determines file type choices to be displayed in the Save as file type or Files of type box.
Return value
Resulting filename specified by the user.string DialogSaveFile ( string path ) #
Opens a common dialog enabling the user to specify a filename to save a file as. When the dialog opens the specified default path shall be set displaying the corresponding elements.Arguments
- string path - Path to be set by default when the dialog opens.
Return value
Resulting filename specified by the user.string DialogSaveFile ( ) #
Opens a common dialog enabling the user to specify a filename to save a file as.Return value
Resulting filename specified by the user.EngineWindow GetUnderCursorWindow ( ) #
Returns the window which is currently under cursor.Return value
The window which is currently under cursor.EngineWindow GetFocusedWindow ( ) #
Returns the window which is currently in focus.Return value
The window which is currently in focus.EngineWindow GetIntersection ( ivec2 global_pos, EngineWindow[] excludes ) #
Returns the window the intersection with which is detected.Arguments
- ivec2 global_pos - The position of the intersection point in global coordinates.
- EngineWindow[] excludes - The windows to be excluded from the intersection detection.
Return value
The window the intersection with which is detected.EngineWindow GetIntersection ( ivec2 global_pos ) #
Returns the window the intersection with which is detected.Arguments
- ivec2 global_pos - The position of the intersection point in global coordinates.
Return value
The window the intersection with which is detected.void ForceUpdateWindowOrders ( ) #
Updates the Z order of all windows.void SetEventsFilter ( IntPtr func ) #
Sets a callback function to be executed on receiving input events. This input event filter enables you to reject certain input events for the Engine and get necessary information on all input events.Arguments
- IntPtr func - Input event callback.