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 number of windows in the group is unlimited.
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 EngineWindowViewport("Horizontal 1", 512, 256);
EngineWindow horizontal_2 = new EngineWindowViewport("Horizontal 2", 512, 256);
EngineWindow horizontal_3 = new EngineWindowViewport("Horizontal 3", 512, 256);
EngineWindow horizontal_4 = new EngineWindowViewport("Horizontal 4", 512, 256);
// create 2 horizontal window groups
EngineWindowGroup horizontal_group_1 = WindowManager.Stack(horizontal_1, horizontal_2, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
EngineWindowGroup horizontal_group_2 = WindowManager.Stack(horizontal_3, horizontal_4, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
// create a vertical group of 2 horizontal groups
EngineWindow vertical_group = WindowManager.StackGroups(horizontal_group_1, horizontal_group_2, EngineWindowGroup.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();
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.
- WindowManager.StackWindows() creates a group of the separate/nested windows. The windows are stacked in the default order.
- WindowManager.Stack() 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.
Follow the links to see the code examples.
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:
public EngineWindowViewport create_window (string name)
{
EngineWindowViewport window = new EngineWindowViewport(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;
}
private void Init()
{
// create a window
EngineWindowViewport 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);
}
}
WindowManager Class
Enums
CALLBACKS#
DPI_AWARENESS#
Properties
EngineWindowViewport MainWindow#
int NumWindows#
bool IsFullscreenMode#
bool IsMultipleWindowsSupported#
EngineWindowViewport FocusedWindow#
EngineWindow UnderCursorWindow#
EngineWindowViewport SystemFocusedWindow#
bool IsAutoDpiScaling#
WindowManager.DPI_AWARENESS DpiAwareness#
WindowManager.DPI_AWARENESS CurrentDpiAwareness#
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.EngineWindowGroup Stack ( EngineWindow first_window, EngineWindow second_window, EngineWindowGroup.GROUP_TYPE group_type, int index = -1, 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 EngineWindowViewport("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindowViewport("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindowViewport("Window 3", 512, 256);
// create a group of 2 windows
EngineWindowGroup group_1 = WindowManager.Stack(window_1, window_2, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
// stack a separate window to the window from the window group
WindowManager.Stack(window_1, window_3, EngineWindowGroup.GROUP_TYPE.VERTICAL);
Arguments
- EngineWindow first_window - The parent window to which another window is stacked.
- EngineWindow second_window - The window to be stacked.
- EngineWindowGroup.GROUP_TYPE group_type - Type of a group to be created.
- int index
- 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.EngineWindowGroup StackToParentGroup ( EngineWindow window_in_group, 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.EngineWindowViewport window_1 = new EngineWindowViewport("Window 1", 512, 256);
EngineWindowViewport window_2 = new EngineWindowViewport("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindowViewport("Window 3", 512, 256);
// stack 2 separate windows
EngineWindowGroup group_0 = WindowManager.StackWindows(window_1, window_2, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
// stack a separate window to the parent group of "window_1"
WindowManager.StackToParentGroup(window_1,window_3);
Arguments
- EngineWindow window_in_group - 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.EngineWindowGroup StackWindows ( EngineWindowViewport first_viewport, EngineWindowViewport second_viewport, EngineWindowGroup.GROUP_TYPE group_type = Enum.EngineWindowGroup.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:EngineWindowViewport window_1 = new EngineWindowViewport("Window 1", 512, 256);
EngineWindowViewport window_2 = new EngineWindowViewport("Window 2", 512, 256);
EngineWindowViewport window_3 = new EngineWindowViewport("Window 3", 512, 256);
// stack 2 separate windows
EngineWindow group_0 = WindowManager.StackWindows(window_1, window_2, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
// stack a window from the window group to a separate window
EngineWindow group_1 = WindowManager.StackWindows(window_3, window_1, EngineWindowGroup.GROUP_TYPE.VERTICAL);
Arguments
- EngineWindowViewport first_viewport - The window to be stacked.
- EngineWindowViewport second_viewport - The window to be stacked.
- EngineWindowGroup.GROUP_TYPE group_type - Type of a group to be created.
Return value
Group of windows.EngineWindowGroup StackWithWindow ( EngineWindowViewport window_viewport, EngineWindow window, EngineWindowGroup.GROUP_TYPE group_type, bool decompose_second = false ) #
Returns a newly created group of the engine window viewport and any other engine window — another viewport or a window group.Arguments
- EngineWindowViewport window_viewport - The window viewport to be stacked.
- EngineWindow window - The window to be stacked.
- EngineWindowGroup.GROUP_TYPE group_type - Type of a window 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.EngineWindowGroup StackGroups ( EngineWindowGroup first_group, EngineWindowGroup second_group, EngineWindowGroup.GROUP_TYPE group_type ) #
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 EngineWindowViewport("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindowViewport("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindowViewport("Window 3", 512, 256);
EngineWindow window_4 = new EngineWindowViewport("Window 4", 512, 256);
// create 2 horizontal groups of windows
EngineWindowGroup group_1 = WindowManager.Stack(window_1, window_2, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
EngineWindowGroup group_2 = WindowManager.Stack(window_3, window_4, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
// stack one group to another to create a new vertical group
EngineWindow group_3 = WindowManager.StackGroups(group_1, group_2, EngineWindowGroup.GROUP_TYPE.VERTICAL);
Arguments
- EngineWindowGroup first_group - The first window group for merging.
- EngineWindowGroup second_group - The second window group for merging.
- EngineWindowGroup.GROUP_TYPE group_type - Type of a group to be created.
Return value
Group of windows.EngineWindowGroup StackToGroup ( EngineWindowGroup 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 EngineWindowViewport("Window 1", 512, 256);
EngineWindow window_2 = new EngineWindowViewport("Window 2", 512, 256);
EngineWindow window_3 = new EngineWindowViewport("Window 3", 512, 256);
EngineWindow window_4 = new EngineWindowViewport("Window 4", 512, 256);
// create 2 horizontal groups of windows
EngineWindowGroup group_1 = WindowManager.Stack(window_1, window_2, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
EngineWindow group_2 = WindowManager.Stack(window_3, window_4, EngineWindowGroup.GROUP_TYPE.HORIZONTAL);
// stack one group to another
WindowManager.StackToGroup(group_1, group_2);
Arguments
- EngineWindowGroup 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 IsFullscreenWindow ( EngineWindow window ) #
Returns the value indicating if the specified window is in a fullscreen state.Arguments
- EngineWindow window - The window to be checked.
Return value
true if the engine window is the fullscreen state, false if it is in the window mode.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.EngineWindowViewport GetFocusedWindow ( ) #
Returns the window viewport which is currently in focus.Return value
The window viewport which is currently in focus.EngineWindowViewport GetSystemFocusedWindow ( ) #
Returns the engine window viewport that has the IsSystemFocused flag enabled, either a window itself or its parent group with the system focus is enabled. If there is no window with such a flag, null is returned.Return value
The engine window viewport that has the IsSystemFocused flag enabled, or null if there is no such window.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.